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

getCardNonce causes an app crash on iOS when an error message is returned #91

Open
craigcartmell opened this issue Apr 5, 2018 · 4 comments

Comments

@craigcartmell
Copy link

Issue
Calling getCardNonce on an iOS device causes the full app to crash when an error message is returned from the request.

This appears to be an error in the way the library is attempting to serialise the response from the getCardNonce request.

Maybe it needs to use NSJSONSerialization isValidObject (Disclaimer, I'm no objective-c expert)?

Step to replicate
Send any invalid data to BTClient.getCardNonce(), e.g. an empty object or invalid card number.

Versions
[email protected]
[email protected]

Stacktrace

 Uncaught exception: Invalid type in JSON write (NSHTTPURLResponse)
2018-04-05 11:32:13.439544+0100 ed4[412:78845] invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
2018-04-05 11:32:14.320270+0100 ed4[412:80350] [] nw_connection_get_connected_socket 147 Connection has no connected handler
2018-04-05 11:32:14.320389+0100 ed4[412:80350] TCP Conn 0x1cc171f40 Failed : error 0:61 [61]
2018-04-05 11:32:18.439619+0100 ed4[412:78845] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSHTTPURLResponse)'
*** First throw call stack:
(0x184b66d8c 0x183d205ec 0x184b66c6c 0x18563c8d4 0x18563eb40 0x184ba4654 0x18563e11c 0x18563c584 0x18563d5d4 0x1010c9e00 0x10119f5d0 0x1011968dc 0x1026c1260 0x1026c1220 0x1026c5db0 0x184b0f070 0x184b0cbc8 0x184a2cda8 0x186a0f020 0x18ea0d78c 0x100b30b18 0x1844bdfc0)
libc++abi.dylib: terminating with uncaught exception of type NSException
@craigcartmell
Copy link
Author

Example of response which we're attempting to JSON serialise:

{
  BTCustomerInputBraintreeValidationErrorsKey =     {
    error =         {
      message = "Credit card is invalid";
};
  fieldErrors =         (
    {
      field = creditCard;
  fieldErrors =                 (
    {
      code = 81703;
  field = number;
  message = "Credit card type is not accepted by this merchant account";
}
);
}
);
};

@craigcartmell
Copy link
Author

Feel free to use craigcartmell@32a2523 if you're finding the same issue and are desperate for a solution.

It will just return a single failure string, e.g. Credit card type is not accepted by this merchant account

simonasdev referenced this issue in simonasdev/react-native-braintree-xplat Apr 17, 2018
Remove JSON incompatible objects from error object which is passed back to JS
@Talkwondo
Copy link

+1

1 similar comment
@paul-apacio
Copy link

+1

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

Successfully merging a pull request may close this issue.

3 participants