Stripe-ios: Stripe Framework 6.0.0 Release: Crash when calling createTokenWithCard() with STPCardParams

Created on 9 Dec 2015  路  4Comments  路  Source: stripe/stripe-ios

We've been using an older version of the Stripe code in a previous app but I've started integrating the Stripe iOS 6.0.0 release framework into our latest app and I'm getting a crash.

It happens when calling createTokenWithCard() using STPCardParams (which is new , we used to use STPCard in our old app).

Essentially I'm sending the card number, expiration month and year, cvc, and name and I get a crash.

Here's the crash error and stack trace:

2015-12-09 09:30:49.566 Avvo[30841:8728593] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString stringByAppendingString:]: nil argument'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010999df45 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000109349deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010999de7d +[NSException raise:format:] + 205
    3   Foundation                          0x0000000108ef890a -[NSString stringByAppendingString:] + 96
    4   Avvo                                0x0000000107613bc7 linkStripeApplePayCategory + 35744
    5   Avvo                                0x0000000107613a29 linkStripeApplePayCategory + 35330
    6   Avvo                                0x00000001076139c3 linkStripeApplePayCategory + 35228
    7   libdispatch.dylib                   0x000000010c9c349b _dispatch_client_callout + 8
    8   libdispatch.dylib                   0x000000010c9aee28 dispatch_once_f + 543
    9   Avvo                                0x000000010761399b linkStripeApplePayCategory + 35188
    10  Avvo                                0x000000010726ecbf _TFC4Avvo16PaymentProcessor14processPaymentfS0_FTCS_5Offer13clientDetailsCS_13ClientDetails_T_ + 2815
    11  Avvo                                0x000000010732c060 _TFC4Avvo11AppDelegate11applicationfS0_FTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVSs10DictionaryCSo8NSObjectPSs9AnyObject____Sb + 4128
    12  Avvo                                0x000000010732c1d3 _TToFC4Avvo11AppDelegate11applicationfS0_FTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVSs10DictionaryCSo8NSObjectPSs9AnyObject____Sb + 179
    13  UIKit                               0x000000010a40ef24 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272
    14  UIKit                               0x000000010a4100ca -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3415
    15  UIKit                               0x000000010a4169c3 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1750
    16  UIKit                               0x000000010a413ba3 -[UIApplication workspaceDidEndTransaction:] + 188
    17  FrontBoardServices                  0x000000010dd59784 -[FBSSerialQueue _performNext] + 192
    18  FrontBoardServices                  0x000000010dd59af2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    19  CoreFoundation                      0x00000001098ca011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    20  CoreFoundation                      0x00000001098bff3c __CFRunLoopDoSources0 + 556
    21  CoreFoundation                      0x00000001098bf3f3 __CFRunLoopRun + 867
    22  CoreFoundation                      0x00000001098bee08 CFRunLoopRunSpecific + 488
    23  UIKit                               0x000000010a4134f5 -[UIApplication _run] + 402
    24  UIKit                               0x000000010a41830d UIApplicationMain + 171
    25  Avvo                                0x000000010733263d main + 109
    26  libdyld.dylib                       0x000000010c9f792d start + 1
    27  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

I am using a test credit card and valid params (but no address params, are they required?) but I'd expect it to nicely error instead of crashing if the params were wrong or empty in some way.

Should I not be using the release and use the source itself? I noticed the 6.0.0 release was released in October....

Most helpful comment

So I'm an idiot. If you get this error, make sure you're setting your publishable API Key before making the call ;)

Closing this.

All 4 comments

That last stack trace was just putting it directly in the App Delegate because I thought maybe it was a unit test problem....but looks like not. So here's the unit test stack trace:

2015-12-10 09:16:50.983 Avvo[92256:7149909] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString stringByAppendingString:]: nil argument'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000110ec4e65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000011086fdeb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000110ec4d9d +[NSException raise:format:] + 205
    3   Foundation                          0x000000011041e85a -[NSString stringByAppendingString:] + 96
    4   Avvo                                0x000000010ea29387 linkStripeApplePayCategory + 35744
    5   Avvo                                0x000000010ea291e9 linkStripeApplePayCategory + 35330
    6   Avvo                                0x000000010ea29183 linkStripeApplePayCategory + 35228
    7   libdispatch.dylib                   0x0000000113f0a4a7 _dispatch_client_callout + 8
    8   libdispatch.dylib                   0x0000000113ef7c7b dispatch_once_f + 76
    9   Avvo                                0x000000010ea2915b linkStripeApplePayCategory + 35188
    10  AvvoTests                           0x00000001267470b4 _TFC9AvvoTests16PaymentProcessor14processPaymentfS0_FTCS_5Offer13clientDetailsCS_13ClientDetails_T_ + 2836
    11  AvvoTests                           0x00000001267a466e _TFC9AvvoTests21PaymentProcessorTests18testProcessPaymentfS0_FT_T_ + 1182
    12  AvvoTests                           0x00000001267a49d2 _TToFC9AvvoTests21PaymentProcessorTests18testProcessPaymentfS0_FT_T_ + 34
    13  CoreFoundation                      0x0000000110db31cc __invoking___ + 140
    14  CoreFoundation                      0x0000000110db301e -[NSInvocation invoke] + 286
    15  XCTest                              0x0000000120df7080 __24-[XCTestCase invokeTest]_block_invoke_2 + 159
    16  XCTest                              0x0000000120e2ab14 -[XCTestContext performInScope:] + 184
    17  XCTest                              0x0000000120df6fd0 -[XCTestCase invokeTest] + 169
    18  XCTest                              0x0000000120df746b -[XCTestCase performTest:] + 443
    19  XCTest                              0x0000000120df5131 -[XCTestSuite performTest:] + 377
    20  XCTest                              0x0000000120df5131 -[XCTestSuite performTest:] + 377
    21  XCTest                              0x0000000120de2181 __25-[XCTestDriver _runSuite]_block_invoke + 51
    22  XCTest                              0x0000000120e02b5b -[XCTestObservationCenter _observeTestExecutionForBlock:] + 615
    23  XCTest                              0x0000000120de20cd -[XCTestDriver _runSuite] + 408
    24  XCTest                              0x0000000120de2e2c -[XCTestDriver _checkForTestManager] + 263
    25  XCTest                              0x0000000120e2be99 _XCTestMain + 628
    26  CoreFoundation                      0x0000000110df0a1c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    27  CoreFoundation                      0x0000000110de66a5 __CFRunLoopDoBlocks + 341
    28  CoreFoundation                      0x0000000110de5e02 __CFRunLoopRun + 850
    29  CoreFoundation                      0x0000000110de5828 CFRunLoopRunSpecific + 488
    30  GraphicsServices                    0x0000000113575ad2 GSEventRunModal + 161
    31  UIKit                               0x000000011194b610 UIApplicationMain + 171
    32  Avvo                                0x000000010e73434d main + 109
    33  libdyld.dylib                       0x0000000113f3992d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

code that triggers the crash:

let stripeCard = STPCardParams()
        stripeCard.number = "4242424242424242"
        stripeCard.expMonth = 9
        stripeCard.expYear = 2020
        stripeCard.cvc = "123"
        stripeCard.name = "John Doe"

STPAPIClient.sharedClient().createTokenWithCard(stripeCard) { [weak self] (token: STPToken?, error: NSError?) -> Void in

            ....
        }

Crash happens upon calling createTokenWithCard()

So I'm an idiot. If you get this error, make sure you're setting your publishable API Key before making the call ;)

Closing this.

You're not an idiot, @valheru7 - we should have a better error message when this happens! Sorry for the trouble you encountered, and thanks for the detailed bug report.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidme-stripe picture davidme-stripe  路  6Comments

mansoorshahsaid picture mansoorshahsaid  路  4Comments

xuzhe picture xuzhe  路  3Comments

imhugofonseca picture imhugofonseca  路  7Comments

provTheodoreNewell picture provTheodoreNewell  路  5Comments