#ryon-reactnative-googlepay
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- ryon-reactnative-savedcards, 1 day ago, 90 messages
Hey there, is this happening with all payments or this specific test card or what other cases?
Are there any errors logged that you can share?
Only test cards that fail. Before we go further I got to thinking after I submitted my request for help. Let me try something server side first
Alright, sure -- I was going to also ask for details of your integration here. Once you poke at things, share how you're initializing the Payment Sheet and confirming the payment (plus any of the relevant server code you mentioned).
ryon-reactnative-googlepay
I have found exactly where the error is but I am not sure how to stop the payment sheet processing. Here is my code. Look at the last IF block where I attempt to handle a situation where a intentID was not returned from the server (indicating an error of sorts). I show the message in a toast to the user. Code: https://pastebin.com/m44S1Rqd
I don't really understand the question I'm sorry. Why aren't you checking before calling initPaymentSheet?
I am using this method https://stripe.com/docs/payments/accept-a-payment-deferred
But that doesn't require an intentId at all
Like our code there does const { error } = await initPaymentSheet({
I must be misunderstanding something in your setup. Why do you call initPaymentSheet twice?
I only called it once. And I didnt pass an intentID. Maybe I showed wrong code?
I don't know you sahred almost 200 lines of code and asked me to look at the last if
let { intentID, intentSecret, message } = await initPaymentIntent(``` I don't understand what this means
Which part of our doc are you following that gives you this? There are like sub tabs of sub tabs so maybe you didn't link to the correct place in the docs?
Ahhh. Sorry about that. Actually that is a server call to setup the payment intent. From the sever I get the intentID and intent Secret.
I later pass the intent secret to
intentCreationCallback({ clientSecret: intentSecret });
Ah my bad the name is just so close
So I don't really understand your question overall I'm sorry
My fault bad naming conventions.
uhh... In a case where the card is declined. The payment sheet is stuck on processing. I am not sure if need to do some manual call to cancel the process or...
Maybe I need to pass in an error? Just saw this https://stripe.dev/stripe-react-native/api-reference/modules/PaymentSheet.html#IntentCreationCallbackParams
IntentCreationCallbackParams
IntentCreationCallbackParams: { clientSecret: string; error?: never } | { clientSecret?: never; error: IntentCreationError }
Dangit
// Call the intentCreationCallback with the client secret or error
intentCreationCallback({clientSecret})
It said so in the docs
looking
Check the https://stripe.com/docs/payments/accept-a-payment-deferred?platform=react-native&type=payment#initialize-paymentsheet. The last section. It said return client secret or error. I didn't read
to be fair it's so hard to notice
I don't get why we don't have a clear example of handleConfirmation()
Yeah. It would be good to show the cases. One look at it and I thought it only took an intent secret.
I think when error is passed the lib will handle it and stop the process. Let me try it now
I did this and it crashed intentCreationCallback({ error: message });
Isn't that how its done?
👋 hopping in here to take a look as well - where are you pulling message from? What type is it?
it's a string from their own call to their server
@wise yarrow can you share the code for initPaymentIntent?
Message is what is returned from our server when the payment was declined. This specific one is "Your card was declined."
Code for initPaymentIntent - https://pastebin.com/eSdVkW44
You mentioned that it crashed - were you able to see what was in the logs? I'm guessing it's failing because you're passing in a string instead of an IntentCreationError type for message
Yeah I figure but how do i structire a IntentCreationError message?
ERROR Your app just crashed. See the error below.
com.facebook.react.bridge.UnexpectedNativeTypeException: Value for error cannot be cast from String to ReadableNativeMap
com.facebook.react.bridge.ReadableNativeMap.checkInstance(ReadableNativeMap.java:143)
com.facebook.react.bridge.ReadableNativeMap.getNullableValue(ReadableNativeMap.java:131)
com.facebook.react.bridge.ReadableNativeMap.getMap(ReadableNativeMap.java:175)
com.facebook.react.bridge.ReadableNativeMap.getMap(ReadableNativeMap.java:23)
com.reactnativestripesdk.PaymentSheetFragment$onViewCreated$createIntentCallback$1.onCreateIntent(PaymentSheetFragment.kt:151)
com.reactnativestripesdk.PaymentSheetFragment$onViewCreated$createIntentCallback$1$onCreateIntent$1.invokeSuspend(Unknown Source:16)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
android.os.Handler.handleCallback(Handler.java:942)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loopOnce(Looper.java:226)
android.os.Looper.loop(Looper.java:313)
android.app.ActivityThread.main(ActivityThread.java:8762)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
I don't have a react native integration handy with me right now, but I think it'd be something like this?
intentCreationCallback({ error: {code:'Failed', message: message} });
Testing
It seems to work. The error message does not appear though. It just shows "Something went wrong"
Hmm... Do you still get the same behavior if you try and hardcode a string for message?
I think I know what to do.
It takes these params
export interface StripeError<T> {
code: T;
message: string;
localizedMessage?: string;
declineCode?: string;
stripeErrorCode?: string;
type?: ErrorType;
}
I console logged the full error response from stripe on the server and I see all these. I am going to forward all these parameters and use them in the app and see if it reads better. Will update
Anyidea what this one would be? stripeErrorCode
I believe it's the code (so from the screenshot it'd be card_declined)
So declineCode and stripeErrorCode would be same thing hmm
They're different in the screenshot right? the declineCode is generic_decline and the stripeErrorCode would be card_declined?
Shux... I saw it and went on to say something else. sorry
no worries!
My server response now looks like this
{
code: 'card_declined',
message: 'Your card was declined.',
localizedMessage: 'Your card was declined.',
declineCode: 'generic_decline',
stripeErrorCode: 'card_declined',
type: 'StripeCardError'
}
code and stripeErrorCode is the same
OH! Sorry I think I led you astray a bit (we have code multiple places and they mean different things so it got a bit mixed up). The code you get from your server response should be used as the stripeErrorCode when you're constructing StripeError, but the StripeError.code should be Failed (I believe this is necesary to match the IntentCreationError type (https://github.com/stripe/stripe-react-native/blob/e1fb2b57a520150b4297764dfaad9a8396e507da/src/types/PaymentSheet.ts#L315)
So you likely want this:
{
code: 'Failed',
message: 'Your card was declined.',
localizedMessage: 'Your card was declined.',
declineCode: 'generic_decline',
stripeErrorCode: 'card_declined',
type: 'StripeCardError'
}
Thank you. testing
I think that works. Shows "Your card was declined in tiny red text" Ill see if I can make that more prominent
https://i.is.cc/1AYSNeZ.jpg
Super simple and lightning fast image sharing. Upload clipboard images with Copy & Paste and image files with Drag & Drop
yay! Glad you were able to get it working!
Yeah! Thank you very much. I recommend editing the docs so its a little easier to understand the usage.
Totally agree! I had recently struggled to get this working with our iOS sdk and the docs were pretty much the same there and hard to follow
I'll flag to some folks internally to improve it
Ah. That reminds me I should test this on iOS, the lib been action funny over there.
Thanks again Karbi have a great evening