#Liuzhibin-iOS
1 messages · Page 1 of 1 (latest)
Hi, I am searching for resources
Have you checked this video? https://www.youtube.com/watch?v=NOceh42ZNEY
Is that what you are referring to?
I checked this video and I found that the 3DSv2 verification UI is not evoked in this video
I use STPPaymentOptionsViewController for 3DSv2 verification
But I don’t know how to evoke the 3DSv2 verification UI
you have to confirm a PaymentIntent
STPPaymentOptionsViewController is just to pick a PaymentMethod, it doesn't process a payment so it doesn't do anything with 3D Secure
the idea usually is in your paymentOptionsViewControllerDidFinish delegate you create and confirm a SetupIntent to set up the card (which might run 3D Secure), or create and confirm a PaymentIntent to process a payment.
func paymentOptionsViewControllerDidFinish(_ paymentOptionsViewController: STPPaymentOptionsViewController) {
print("didFinish");
if let card = selectedPaymentOption as? STPPaymentMethod {
self.customerContext?.retrieveCustomer({ (customer, error) in
guard let customer = customer else {
print(error!)
return
}
MyAPIClient.sharedClient.createSetupIntent(customerId: customer.stripeID) { (setupIntentClientSecret, error) in
guard let clientSecret = setupIntentClientSecret, error == nil else {
print("Error contacting backend(create)")
return
}
let setupIntentParams = STPSetupIntentConfirmParams(clientSecret: clientSecret)
setupIntentParams.paymentMethodID = card.stripeId
STPPaymentHandler.shared().confirmSetupIntent(setupIntentParams, with: self, completion: { (status, setupIntent, error) in
...
...
...
I tested it, this is a normal payment process, but it will not evoke the UI of the 3DSv2 process
and what happened exactly? can you share the code you used?
and an example PaymentIntent pi_xxx you tested with
This is my code
Hold on
I don't really read objective-c, but do you implement the STPAuthenticationContext protocol?
also , what happened exactly when you run this code?
Yes, it implements require Method
does it popup a UI, does it does crash, are there errors in the logs, is the completion function called and what's the status returned if so?
has present STPPaymentOptionsViewController
But it doesn't evoke 3dSV2-related UI
paymentHandler confirmPayment:withAuthenticationContext: completion:
always return STPPaymentHandlerActionStatusFailed
does it work for cards like 4000000000003063 that use 3DSv1 instead of v2?
if so and it's only broken for v2 , then you probably haven't installed the library correctly somehow and you're missing the Stripe3DS2.xcframework part of it, perhaps, since that's what creates the native 3DSv2 interface https://github.com/stripe/stripe-ios#releases
I just tested it 4000000000003063
and?
Also return STPPaymentHandlerActionStatusFailed
How should achieve STPPaymentOptionsViewController 3 dsv2 pay
process
😢
the code you have seems like mostly the right approach really
what's in the NSError *error ?
like dump it out and see what the specific error that's happening is
what's the question?
my code is different than yours yes(it uses Swift and I use a SetupIntent, you use Obj-C and a PaymentIntent) but it shouldn't be related, it's just different ways to use the API and should be separate from this 3D Secure issue.
what's in the NSError *error in the completion block when you get back the STPPaymentHandlerActionStatusFailed status? That's the next step, inspect that error to see what's happening and why it fails, and I can try to go from there in helping you! (also you never shared an example pi_xxx ID like I asked for, that would help too).
why?
why what? Sorry, it's hard to answer one-word questions.
I can try to help you!
can you share an example PaymentIntent pi_xxx you tested with?
what is the contents of the NSError's userInfo dictionary?
Wait a moment
also you said this but I don't see authenticationPresentingViewController being implemented anywhere in the code you shared
pi_3JhYhaF3t6jWU2aX0nHh0auu_secret_NCh2Oku3Eg76s65a3Afv6XK9r
pm_1JhYZdF3t6jWU2aX085PrdGK
Error Domain=com.stripe.lib Code=50 "No such setupintent: '(null)'" UserInfo={com.stripe.lib:ErrorMessageKey=No such setupintent: '(null)', com.stripe.lib:StripeErrorCodeKey=resource_missing, com.stripe.lib:StripeErrorTypeKey=invalid_request_error, com.stripe.lib:ErrorParameterKey=intent, NSLocalizedDescription=No such setupintent: '(null)'}
ok so that error seems clear
whatever [NCStripePaySupportTool sharedTool].client_secret is in the code you shared earlier, it's null. Does that make sense?
also you must not be using that code you shared anymore, right? Since this error talks about a SetupIntent , so you must be calling confirmSetup now instead, right?
I only implemented this method
ok, let's ignore that for now then
yep but you need to implement it, like
# pragma mark STPAuthenticationContext
- (UIViewController *)authenticationPresentingViewController {
return self;
}
in your .m file
but putting that aside, do you understand the point I made above? about your client_secret being null?
yep so the error message you shared is quite clear I think, right?
whatever [NCStripePaySupportTool sharedTool].client_secret is in that code, it's null.
that's why you get an error No such setupintent: '(null)', .
I mean that is what you're doing right?
Of course,
ok! So I don't understand the question. If that's what you want to use, you can.
but overall why not just start from the first page of our docs (https://stripe.com/docs/payments/accept-a-payment?platform=ios) and build that (the PaymentSheet integration) if you're starting something from scratch? It's probably easier.
yep that's a PaymentIntent ID which is wrong.
the client_secret nonull
because you're calling confirmSetupIntent, so you need to create a SetupIntent on your backend instead of a PaymentIntent
you were using PaymentIntents when we started this conversation but you changed the frontend to SetupIntents at some point it seems!
so if that's what you want to use then you need to change your backend server to create and return a SetupIntent (will look like seti_xxx_secret_yyy) instead.
I did it a different way
STPPaymentHandlerActionStatusFailed
<STPPaymentIntent: 0x2828db7a0; stripeId = pi_3JhZCBF3t6jWU2aX0dhjjnig; amount = 2439; canceledAt = (null); captureMethod = manual; clientSecret = <redacted>; confirmationMethod = automatic; created = 2021-10-06 12:26:03 +0000; currency = usd; description = Orders #702426925; lastPaymentError = (null); livemode = NO; nextAction = <STPIntentAction: 0x28174b3f0; type = use_stripe_sdk; useStripeSDK = <STPIntentActionUseStripeSDK: 0x283d6db60; directoryServer = visa; directoryServerID = A000000003; directoryServerKeyID = (null); serverTransactionID = d5d4383a-96e4-4f15-b780-d375925a07ca; directoryServerCertificate = <redacted>; rootCertificateStrings = <redacted>; threeDS2SourceID = src_1JhZCKF3t6jWU2aXCChT4HMH; type = stripe_3ds2_fingerprint; redirectURL = (null)>>; paymentMethodId = pm_1JhYZdF3t6jWU2aX085PrdGK; paymentMethodTypes = (
card
); receiptEmail = qwe125@163.com; setupFutureUsage = on_session; shipping = {
address = {
city = ctr;
country = US;
line1 = djcbcbsbxxxxc;
line2 = 78455555;
"postal_code" = 466868344;
state = Texas;
};
name = "dxcc, iudxs";
}; sourceId = (null); status = requires_action>
------------- error -----------------------------------
Error Domain=STPPaymentHandlerErrorDomain Code=7 "There was an unexpected error -- try again in a few seconds" UserInfo={com.stripe.lib:ErrorMessageKey=authenticationPresentingViewController is not in the window hierarchy. You should probably return the top-most view controller instead., NSLocalizedDescription=There was an unexpected error -- try again in a few seconds}
yep so
authenticationPresentingViewController is not in the window hierarchy. You should probably return the top-most view controller instead.,
is the error message.
so it's to do with your authenticationPresentingViewController — the VC you're using here is not the top-level one. Hard for me to help since I don't know how your app's view hierarchy is set up exactly.
oh, thanks
I try again
STPPaymentOptionsViewController
should use a push or present show STPPaymentOptionsViewController?
this
Error Domain=STPPaymentHandlerErrorDomain Code=7 "There was an unexpected error -- try again in a few seconds" UserInfo={com.stripe.lib:ErrorMessageKey=authenticationPresentingViewController is already presenting. You should probably dismiss the presented view controller in prepareAuthenticationContextForPresentation., NSLocalizedDescription=There was an unexpected error -- try again in a few seconds}
this usually means you're calling confirmPayment twice basically, for example your code calls it again before it completes.
Should I implement <STPAuthenticationContext> Protocol Other Method?
no, the only one you have to complement is authenticationPresentingViewController() .
thanks