#benkass
1 messages · Page 1 of 1 (latest)
yes. In confirmHandler I have:
const error = {
code: "card_declined",
decline_code: "insufficient_funds",
doc_url: "https://stripe.com/docs/error-codes/card-declined",
message: "Your card has insufficient funds.",
payment_method: {
billing_details: [Object],
card: [Object],
created: 1696015586,
customer: null,
id: "pm_1NvmKUCg0bBEGiBdXi8Gg2Oy",
livemode: false,
metadata: [Object],
object: "payment_method",
type: "card"
},
type: "card_error"
}
intentCreationCallback({ error });
I checked out stripe-react-native and I believe it should be the correct way to pass the error
export type IntentCreationCallbackParams =
| {
clientSecret: string;
error?: never;
}
| {
clientSecret?: never;
error: IntentCreationError;
};
export type IntentCreationError = StripeError<'Failed'>;
and finally
export interface StripeError<T> {
code: T;
message: string;
localizedMessage?: string;
declineCode?: string;
stripeErrorCode?: string;
type?: ErrorType;
}
Hm that does seem to be the default message: https://github.com/stripe/stripe-react-native/blob/master/ios/StripeSdk.swift#L151
Not an expert in our react native sdk, but based on that doesn't seem unexpected
When localizedMessage isn't set, we use that default
In the error object you shared, I don't see localizedMessage
indeed
Do you know if there's a card decline that will provide a localizedMessage?
insufficient funds doesn't
I don't off the top of my head
I wonder if other errors do
You can try the other cards
yeah trying
The stripe node_module (8.222.0) doesn't have any localizedMessage in its type definitions
export interface StripeError<T> {
code: T;
message: string;
localizedMessage?: string;
declineCode?: string;
stripeErrorCode?: string;
type?: ErrorType;
}
It does in the one you shared right above
So I'm thinking maybe it's something that is unique to the RN lib
Ah you said node my bad
maybe the call that the RN lib makes to the stripe server also provides back that value
Yeah it should afaik
it's a bit of a black box tbh
Can you please check if the types of localizedMessages are listed anywhere
Maybe it's the same as the message? I have no idea
We don't list them anywhere
It's mostly just a localized message that's easy to read for the user
so basically the message translated for the user?
I'm just confused why stripe.paymentIntents.create doesn't return it
maybe it does but swaps the message to the localied one?
That's a server-side call, right?
yes
Yeah localizedmessages are for the client in rn sdk
yeah afaik
to receive a message in the user's language
otherwise it's always in english
Anyway, i was just curious. Right now I don't cae
care
Not for server side calls like creating a PI
ok cool
I have a question for you. I am able to send back errors to intentCreationCallback and it works as expected. Because I create a PI with a cloned PM which is different than the one the RN paymentsheet generates, the success call of the sdk fails. Since I use confirm: true on my PI, I don't need the payment sheet 's NativeStripeSdk.intentCreationCallback to fire the check at all. I just want it to show success. Can you think of a way I can make it do that?
practically if the PI worked, I need the payment sheet pay button to show success and the payment sheet to close, just like it does when I create a PI on the platform using the payment sheet's PM
Let me get a colleague who's better with react native to help on this then
One moment
👋 Afaik, there's no way to do that
😦
Hello again!
Sorry for the issues around this, but the PaymentSheet just doesn't have the functionality you need for your specific use case.
The Payment Element on the web does, but the PaymentSheet is more rigid, and has stricter requirements.
Hi Rubeus. What’s up? Yeah. It’s very frustrating. It’s 99% done. I only need a way to close that damn sheet
Yeah makes sense
I posted on GitHub about it. I hope they will consider allowing verification of a PI on a connected account soon. Otherwise we’d need to recreate this entire UI for no good reason.
If this was in JS, I would be already finished but they created the bottom sheet natively.
Nonetheless, you are the one who thought about this flow in the first place and it works. So thanks for that.
Sorry it's not a complete solution. Your use case is rather unusual, which is why you're running into friction here. Express accounts and destination charges are more common for this type of thing, and would make this considerably easier.
Obviously but it doesn’t make sense financially. We will make very little per connected account and not enough to cover those.
But would it make any difference? We would still need to clone the PM and use the clone to generate a PI, no?
With Express accounts and destination charges all of the payment objects live on your platform. There is no cloning.
Backing up a bit, you've tried the custom flow here, correct? https://stripe.com/docs/payments/accept-a-payment-deferred?platform=react-native&type=payment&integration=paymentsheet-flowcontroller#react-native-collect-payment-details
Yes got all this done but needed to deviate at step 5 because we want to have the connected account paid and us collect the application fee
Right, but specifically the custom flow bit, under this tab:
You tried that specific approach?
Yes I have that
Two buttons. Top is to add or select pms and the bottom is the pay button
But why is it listed under custom?
When I pass custom: true, the pay button disappears
Normally the PaymentSheet handles both collecting info and confirming the payment. The custom flow allows you to separate those two things.
You handle the pay button instead of the PaymentSheet handling it for you.
I was curious about the specific issue you had with the custom flow?
Give me 5 min. I’ll have a look and reply or ping you
ok so when I add customFlow: true, to initPaymentSheet, it opens the sheet with no button at all
just the payment methods at the top.
The default card is selected and circled in blue and there's an add button
When I press the default card, the sheet closes
const { error: initPaymentSheetError } = await initPaymentSheet({
merchantDisplayName: 'DineDen',
customerId: user?.stripe?.customer,
customerEphemeralKeySecret: ephemeralKey,
intentConfiguration: {
mode: {
amount: breakdown.total_with_tip,
currencyCode: 'USD',
},
confirmHandler,
},
customFlow: true
});
Right, that's expected behavior for that flow. My question is around why this approach won't work for you?
Or have you not tried this flow before?
Haven't yet tried
what do I do? 🙂
What's the flow without getting into specifics?
Basically after collecting the payment info you handle everything server-side and then display success or failure. You ignore the confirmHandler.
You need to handle displaying success or failure in your own UI in this flow.
But the PaymentSheet can still be used.
I didn't know if handling that stuff outside of the PaymentSheet was a dealbreaker for you or not?
How are things going?
Sorry, my kid decided to come home from school earlier. Surprise! 🙂
I'll work on it and ping you if (and when) I get stuck. But in theory, I believe this could work. It's not as nice as having both buttons in the same sheet, but it's better than nothing.
Sounds good! Good luck with it!
thank you!