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

STPPaymentHandler crashed when confirm PaymentIntent (automatic flow) #1242

Closed
letrongtriet opened this issue Jul 23, 2019 · 11 comments
Closed
Assignees
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@letrongtriet
Copy link

letrongtriet commented Jul 23, 2019

Summary

App crashed right away when try to confirm a payment intent (created by Backend)

Card used: 4000000000003253

Code to reproduce

extension WhimWheelViewController: STPAuthenticationContext {
func authenticationPresentingViewController() -> UIViewController {
        return self
    }
    
    private func book(_ booking: Booking, paymentSourceId: PaymentSourceId, choices: [ConfiguratorChoice]?) {
        BookingManager.shared.bookV2(booking: booking, paymentSourceId: paymentSourceId, successfulCallback: { [weak self] object in
            guard let self = self else { return }
            
            guard let clientSecret = object.paymentParameters?.clientSecret else {
                return
            }
            
            self.confirmPayment(with: clientSecret)
            
            }, errorCallback: { [weak self] error in
                log.error(error)
                self?.stopAnimating()
        })
    }
    
    private func confirmPayment(with clientSecret: String) {
        let paymentIntentParams = STPPaymentIntentParams(clientSecret: clientSecret)
        paymentIntentParams.returnURL = WhimNetworkPantry.Payment.stripeRedirectURL
        
        let paymentManager = STPPaymentHandler.shared()
        
        var stripeClient: STPAPIClient {
            let key = WhimNetworkManager.shared.environment.isTest ? WhimNetworkManager.shared.stripeTestApiKey : WhimNetworkManager.shared.stripeLiveApiKey
            return STPAPIClient(publishableKey: key)
        }
        
        paymentManager.apiClient = stripeClient
        
        paymentManager.confirmPayment(paymentIntentParams, with: self, completion: { (status, paymentIntent, error) in
            self.close()
            
            if let error = error {
                log.error(error)
            }
            
            switch status {
            case .failed:
                log.debug("++++++ failed")
            case .canceled:
                log.debug("++++++ canceled")
            case .succeeded:
                log.debug("++++++ succeeded")
            @unknown default:
                log.debug("++++++ @unknown default")
            }
        })
    }
}

iOS version

12.3.1

Installation method

Cocoapods

SDK version

16.0.0

Other information

Crash log:

2019-07-23 10:28:51.206562+0300 whim-ios[1669:643384] -[TVg isChallengeMandated]: unrecognized selector sent to instance 0x10ddb17a0
2019-07-23 10:30:06.638493+0300 whim-ios[1669:643384] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TVg isChallengeMandated]: unrecognized selector sent to instance 0x10ddb17a0'
*** First throw call stack:
(0x1a716a3a8 0x1a636fd00 0x1a70829f8 0x1a716fd54 0x1a7171b50 0x106e031d8 0x106dadfb8 0x106db1e70 0x109fdf1f8 0x109fe0778 0x109fee158 0x1a70fa024 0x1a70f4cd4 0x1a70f4254 0x1a9333d8c 0x1d443c4c0 0x102941cd4 0x1a6bb0fd8)
libc++abi.dylib: terminating with uncaught exception of type NSException

Last step before crash:

#import "STPDispatchFunctions.h"

void stpDispatchToMainThreadIfNecessary(dispatch_block_t block) {
    if ([NSThread isMainThread]) {
        block();
    }
    else {
        dispatch_async(dispatch_get_main_queue(), block);
    }
}
@tombates-pdr
Copy link

tombates-pdr commented Jul 23, 2019

@letrongtriet thanks for raising this, I was literally just having this issue and was about to raise it myself.
The crash seems to be happening in STPPaymentHandler.m L:473 for me

I am attempting to use the following card: 4000000000003220

@tombates-pdr
Copy link

Digging a little deeper and it looks like it could be the object that is returned from:
STDSAuthenticationResponseFromJSON
being called in:
STP3DS2AuthenticateResponse.h
on line:
32

The authenticationResponseJSON that it is attempting to use to create the TVg object does, however, contain acsChallengeMandated = Y;

@yuki-stripe
Copy link
Collaborator

Thanks for reporting this!

I haven't been able to reproduce this crash so far. Are you able to breakpoint on line 473 in STPPaymentHandler and inspect the aRes variable there? I'm wondering what it looks like in the debugger, and if it responds to isChallengeMandated.

@letrongtriet
Copy link
Author

letrongtriet commented Jul 23, 2019

@yuki-stripe Please see the attachment below for all information

NOTE:

  • I am using card 4000 0000 0000 3253
  • I added card by using Source ID (old JS SDK since Chargebee did not update their APIs yet)
  • App DID NOT crash if using card 4242 4242 4242 4242

Screen Shot 2019-07-23 at 21 09 27

@yuki-stripe
Copy link
Collaborator

Thanks @letrongtriet! We've identified an issue with our code obfuscation, and are working on a fix.

@yuki-stripe
Copy link
Collaborator

@letrongtriet @DrTomBates This should be fixed on 5cfa3dc - you can point your Podfile to that commit until the next version is released. Please let me know if that resolves this issue!

@letrongtriet
Copy link
Author

letrongtriet commented Jul 24, 2019

@yuki-stripe It did fix the problem 👍
Thanks for you super fast support.

@tombates-pdr
Copy link

@yuki-stripe This looks like it has solved the issue for me as well, thanks!

@mshafrir-stripe mshafrir-stripe added the triaged Issue has been reviewed by Stripe and is being tracked internally label Jul 24, 2019
@denglei022
Copy link

@yuki-stripe It didn't help me...

@yuki-stripe
Copy link
Collaborator

@denglei022 Can you make a new issue with your crash and details?

The fix for this is in v16.0.1.

@denglei022
Copy link

denglei022 commented Jul 26, 2019 via email

wooj-stripe pushed a commit that referenced this issue Jul 5, 2022
* Don't show autocomplete if default shipping values are present

* Use only line 1 for keyboard suggestions for auto complete

* Revert "Use only line 1 for keyboard suggestions for auto complete"

This reverts commit afe896269b3337792687be3f771d8e2d196ba696.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally
Projects
None yet
Development

No branches or pull requests

5 participants