#benkass

1 messages · Page 1 of 1 (latest)

frosty marshBOT
gilded light
#

Can you share your code?

#

Want to understand exactly what you mean

solar mulch
#

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;
}
gilded light
#

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

solar mulch
#

indeed

#

Do you know if there's a card decline that will provide a localizedMessage?

#

insufficient funds doesn't

gilded light
#

I don't off the top of my head

solar mulch
#

I wonder if other errors do

gilded light
#

You can try the other cards

solar mulch
#

yeah trying

#

The stripe node_module (8.222.0) doesn't have any localizedMessage in its type definitions

gilded light
#

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

solar mulch
#

So I'm thinking maybe it's something that is unique to the RN lib

gilded light
#

Ah you said node my bad

solar mulch
#

maybe the call that the RN lib makes to the stripe server also provides back that value

gilded light
#

Yeah it should afaik

solar mulch
#

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

gilded light
#

We don't list them anywhere

#

It's mostly just a localized message that's easy to read for the user

solar mulch
#

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?

gilded light
#

That's a server-side call, right?

solar mulch
#

yes

gilded light
#

Yeah localizedmessages are for the client in rn sdk

solar mulch
#

aha

#

So what I wrote above is right? they are just message translated?

gilded light
#

yeah afaik

solar mulch
#

ok cool

#

I wonder whether the server side call has a way to pass the locale?

gilded light
#

For what?

#

nothing should need to be localized to create a payment intent

solar mulch
#

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

gilded light
#

Not for server side calls like creating a PI

solar mulch
#

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

gilded light
#

Let me get a colleague who's better with react native to help on this then

#

One moment

winter jungle
#

👋 Afaik, there's no way to do that

frosty marshBOT
solar mulch
#

😦

grave river
#

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.

solar mulch
#

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.

grave river
#

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.

solar mulch
#

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?

grave river
#

With Express accounts and destination charges all of the payment objects live on your platform. There is no cloning.

solar mulch
#

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

grave river
#

Right, but specifically the custom flow bit, under this tab:

#

You tried that specific approach?

solar mulch
#

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

grave river
#

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?

solar mulch
#

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
      });
grave river
#

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?

solar mulch
#

Haven't yet tried

#

what do I do? 🙂

#

What's the flow without getting into specifics?

grave river
#

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?

solar mulch
#

I'm also reading the docs now

#

OK, going to test now...

grave river
#

How are things going?

solar mulch
#

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.

grave river
#

Sounds good! Good luck with it!

solar mulch
#

thank you!