Skip to content

Commit

Permalink
Detect errors when creating a Source in the 3DS example (#936)
Browse files Browse the repository at this point in the history
Two problems:

* This `error` was never being checked and reported
* When `source` or `source.cardDetails` is `nil`, `source.cardDetails.threeDSecure == STPSourceCard3DSecureStatusRequired`
because `STPSourceCard3DSecureStatusRequired == 0` and Obj-C's `nil` -> 0 conversion.
  • Loading branch information
danj-stripe authored May 16, 2018
1 parent 45b9f53 commit 6bf2c15
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ - (void)pay {
STPAPIClient *stripeClient = [STPAPIClient sharedClient];
STPSourceParams *sourceParams = [STPSourceParams cardParamsWithCard:self.paymentTextField.cardParams];
[stripeClient createSourceWithParams:sourceParams completion:^(STPSource *source, NSError *error) {
if (source.cardDetails.threeDSecure == STPSourceCard3DSecureStatusRequired) {
if (error) {
[self.delegate exampleViewController:self didFinishWithError:error];
} else if (source.cardDetails && source.cardDetails.threeDSecure == STPSourceCard3DSecureStatusRequired) {
STPSourceParams *threeDSParams = [STPSourceParams threeDSecureParamsWithAmount:1099
currency:@"usd"
returnURL:@"payments-example://stripe-redirect"
Expand Down

0 comments on commit 6bf2c15

Please sign in to comment.