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

Detect errors when creating a Source in the 3DS example #936

Merged
merged 1 commit into from
May 16, 2018

Conversation

danj-stripe
Copy link
Contributor

Summary

Reporting errors creating the Source, and fixing crash that happens when source.cardDetails == nil.

Motivation

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.

This resulted in passing a nil card id into the threeDSecureParamsWithAmount:... method,
which crashed when it tried to put it into an NSDictionary

Testing

This is the example code, so it doesn't have automated testing. Manually tested by using
a livemode publishable key (pk_live_...) and the auto-filled test card #, which
causes the initial Source creation to fail:

{
  "error": {
    "code": "card_declined",
    "doc_url": "https://stripe.com/docs/error-codes/card-declined",
    "message": "Your card was declined. Your request was in live mode, but used a known test card.",
    "type": "invalid_request_error"
  }
}

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.
@danj-stripe danj-stripe merged commit 6bf2c15 into master May 16, 2018
@danj-stripe danj-stripe deleted the danj/bugfix/detect-3ds-errors branch May 16, 2018 19:15
mludowise-stripe added a commit that referenced this pull request Apr 2, 2022
Tint icons on consent screen with adaptive 
color so they're visible in dark mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants