Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid SnapRequest sent by mobile sdk #39

Open
imrenagi opened this issue Jun 17, 2019 · 4 comments
Open

Invalid SnapRequest sent by mobile sdk #39

imrenagi opened this issue Jun 17, 2019 · 4 comments

Comments

@imrenagi
Copy link

Hi,

I'm using this module with version (v0.0.0-20190513104831-ff7f567d2249) in my golang backend. However, when we receive the snap request from our android app, we found out that credit_card.authentication sent by the android sdk is not a boolean, but string. Meanwhile in go-midtrans module, it is defined as boolean in here.

We are using struct SnapReq to decode the json sent by the android and to do some validation against the request sent by android app. However we got error due to the issue i explained above.

decoder := json.NewDecoder(r.Body)
var snapRequest go-midtrans.SnapReq
err := decoder.Decode(&snapRequest)
if err != nil {
.....
}

Is this expected?

@rizdaprasetya
Copy link
Contributor

rizdaprasetya commented Jun 18, 2019

Actually the credit_card.authentication API wise accept both string & boolean, to maximize compatibility. The quick solution will be to change the type to string, which should be safe for both:

Authentication bool `json:"authentication,omitempty"`

Or any other alternative to define type that both accept bool and string from JSON on Go?

@imrenagi
Copy link
Author

I dont think so.. is it possible to promote this changes on the new version of this library?

@rizdaprasetya
Copy link
Contributor

Yes make sense, this should be changed to string for next version. But first will need to make proper versioning of this library. Currently we're prioritizing some other development, we'll get back to this once we have proper allocation.
We'll leave this issue open for now, Pull Request from anyone is welcome to address this.

@imrenagi
Copy link
Author

Yep. Adding version number will be a good thing to have. I will try to make a PR for changing this to string tho. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants