#Liuzhibin-iOS

1 messages · Page 1 of 1 (latest)

indigo lodge
night dove
#

hey

#

can you help me?

indigo lodge
#

Hi, I am searching for resources

#

Is that what you are referring to?

night dove
#

I haven't watched this video

#

oh,Thank you

night dove
#

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

lofty rover
#

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
                    ...
                    ...
                  ...
night dove
#

oh, thank you

#

very much

night dove
lofty rover
#

it should if you use a card that supports it

#

did you try 4000000000003220 ?

night dove
#

4000000000003220

#

4000000000003238

lofty rover
#

and what happened exactly? can you share the code you used?

#

and an example PaymentIntent pi_xxx you tested with

night dove
#

This is my code

#

Hold on

lofty rover
#

I don't really read objective-c, but do you implement the STPAuthenticationContext protocol?

#

also , what happened exactly when you run this code?

night dove
#

Yes, it implements require Method

lofty rover
#

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?

night dove
#

has present STPPaymentOptionsViewController

#

But it doesn't evoke 3dSV2-related UI

#

paymentHandler confirmPayment:withAuthenticationContext: completion:

#

always return STPPaymentHandlerActionStatusFailed

lofty rover
#

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

night dove
#

I just tested it 4000000000003063

lofty rover
#

and?

night dove
#

Also return STPPaymentHandlerActionStatusFailed

#

How should achieve STPPaymentOptionsViewController 3 dsv2 pay

#

process

#

😢

lofty rover
#

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

lofty rover
#

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).

night dove
night dove
lofty rover
#

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?

night dove
#

Wait a moment

lofty rover
night dove
#

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)'}

lofty rover
#

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?

lofty rover
#

ok, let's ignore that for now then

night dove
lofty rover
#

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?

night dove
#

Wait a moment

lofty rover
#

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)', .

night dove
#

Should I implement this Integration?

lofty rover
#

I mean that is what you're doing right?

night dove
#

Of course,

lofty rover
#

ok! So I don't understand the question. If that's what you want to use, you can.

night dove
#

you look

lofty rover
#

yep that's a PaymentIntent ID which is wrong.

night dove
#

the client_secret nonull

lofty rover
#

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.

night dove
#

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}

lofty rover
#

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.

night dove
#

oh, thanks

#

I try again

#

STPPaymentOptionsViewController

#

should use a push or present show STPPaymentOptionsViewController?

night dove
#

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}

lofty rover
#

this usually means you're calling confirmPayment twice basically, for example your code calls it again before it completes.

night dove
#

Should I implement <STPAuthenticationContext> Protocol Other Method?

lofty rover
#

no, the only one you have to complement is authenticationPresentingViewController() .

night dove
#

thanks