#jean-baptiste-r_code

1 messages Β· Page 1 of 1 (latest)

uneven nacelleBOT
#

πŸ‘‹ Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

πŸ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1329775528756117564

πŸ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

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.

sharp timber
#

hi there!

#

how are you accepting payments? Checkout Session, Payment Element, something else?

scenic patrol
#

Hey, gonne give you code and screenshots I couldn't send in the form :x

sharp timber
#

I don't really need the code for now

scenic patrol
#

Hello πŸ‘‹

I was implementing the solution that tarzan gave me: https://discord.com/channels/841573134531821608/1329729155478196257

Here my frontend code:

      const elements: StripeElements | undefined = stripeJs.elements({
        mode: 'setup',
        currency: 'eur',
        payment_method_types: ['card', 'customer_balance', 'sepa_debit']
      })
      const paymentElement: StripePaymentElement | undefined = elements.create('payment')
      paymentElement.mount(elementWrapper)

And here is my backend code:

  public createPaymentIntent(payload: IPaymentIntentPayload): DataWrapper<Promise<IPaymentResponse>> {
    const paymentIntentPromise = (async (): Promise<IPaymentResponse> => {
      const stripe = this._stripe[payload.vmcCompanyAccountName]

      const createdPaymentIntent = await stripe.paymentIntents.create({
        amount: Math.round(payload.amountInEuros * 100),
        currency: payload.currency || 'eur',
        customer: payload.customerId,
        payment_method: payload.creditCardId,
        payment_method_options: {
          card: {
            setup_future_usage: payload.setupFutureUsage,
          },
          sepa_debit: {
            setup_future_usage: payload.setupFutureUsage,
          },
        },
        automatic_payment_methods: {
          enabled: true,
        },
        confirm: payload.confirm || false,
        metadata: {
          ...payload.documentData,
          ...(payload.metadata || {}),
        },
      })

      // convert payment intent to inner response format
      return {
        paymentIdClientSecret: createdPaymentIntent.client_secret || undefined,
        status: this.convertStripeStatusesToPaymentProviderStatuses(createdPaymentIntent.status),
        paymentId: createdPaymentIntent.id,
      }
    })()

    return DataWrapper.fromData(paymentIntentPromise)
  }
#

So I'm not using the payment_method_types property anymore. If I'm right, this means that I'm handling payment thanks to the Stripe Dashboard.
So I got to the dashboard and added bank transfers as a payment method. But on my application, I can't see the bank transfer.

#

Ah, well sorry, here is if needed πŸ˜…

sharp timber
#

thanks for the details, having a look

scenic patrol
#

Just checked to be sure: I'm using the test keys and I activated the payment method in test mode

sharp timber
#

I'm a bit confused. if you are creating a PaymentIntent, why use mode: 'setup'?

scenic patrol
sharp timber
#

no. mode:setup means you are trying to save the payment method without making a payment.

scenic patrol
#

Euh

#

So I'm not in the right code

#

Oh true, I was modifying the wrong code !

#

Okay, so here is the right code:

      const elements: StripeElements = stripeJs.elements({
        mode: 'payment',
        currency: 'eur',
        amount: Math.round(amount * 100)
      })
      const paymentElement: StripePaymentElement = elements.create('payment')
      paymentElement.mount(elementWrapper)

When adding payment_method_types: ['card', 'customer_balance'], there is a new choice for bank transfer.
Why it doesn't show my this choice without this line then ?

#

I don't know if my message if really understandable...
Here are examples:
With this code:

      const elements: StripeElements = stripeJs.elements({
        mode: 'payment',
        currency: 'eur',
        amount: Math.round(amount * 100)
      })
      const paymentElement: StripePaymentElement = elements.create('payment')
      paymentElement.mount(elementWrapper)

I'm not using the payment_method_types property, so Stripe should automatically show the payment methods. But it doesn't show the bank transfer method. (first screenshot)

When I had the payment_method_types property like this:

      const elements: StripeElements = stripeJs.elements({
        mode: 'payment',
        currency: 'eur',
        amount: Math.round(amount * 100),
        payment_method_types: ['card', 'customer_balance']
      })
      const paymentElement: StripePaymentElement = elements.create('payment')
      paymentElement.mount(elementWrapper)

Now, I can see the bank transfer method... (second screenshot)
But I don't want to use the payment_method_types property, I'd like to handle my payment methods with the dashboard.

uneven nacelleBOT
scenic patrol
#

Welcome πŸ‘‹

somber laurel
#

What's your acct_xxx ID?

scenic patrol
#

Where can I find this information please ?

#

Found it: acct_1FHsJ8FrwhyGApwd

somber laurel
#

To confirm, you're unclear why bank transfer PM is missing from your Payment Element?

scenic patrol
#

Exactly

somber laurel
#

Ah, ok. This is a Connect setup? Can you show me how you're initialising Stripe.js?

scenic patrol
#
  public static getStripeJs = async (companyProfile: EStripePublicKeyEnv): Promise<Stripe> => {
    const stripePublicKey = useConfig().get(companyProfile)
    /* eslint-disable */
    if (!StripeHelper.stripeJsInstancesMap.get(companyProfile)) StripeHelper.stripeJsInstancesMap.set(companyProfile, await loadStripe(stripePublicKey))
    if (!StripeHelper.stripeJsInstancesMap.get(companyProfile)) throw new Error('Erreur lors du chargement de Stripe')
     /* eslint-enable */

    return StripeHelper.stripeJsInstancesMap.get(companyProfile) as Stripe // Cast as Stripe because it cannot be null here
  }

(I need to handle multiple Stripe JS instance, so that's why there's a map. Stripe.js is initialised using await loadStripe(stripePublicKey))

somber laurel
#

OK, thanks. What about an example pi_xxx you create?

scenic patrol
#

Here is: pi_3QiCiGFrwhyGApwd0xEiBgzy
I created it this morning and use the SEPA method

#

But for the bank transfer method, I create my payment intent in my backend application, so after clicking in the "confirm payment" button... so I don't have payment intent for this method

somber laurel
#

Yeah you're using the deferred intent flow in the code above

#

Is there somewhere I can reproduce this?

scenic patrol
#

Sadly no sorry 😦
I can't give you the app source code, it's not my property

somber laurel
#

Or, can you do me a favour and refresh the page where you have the Payment Element and remove the payment_method_types param so it uses the Dashboard configf

scenic patrol
#

Done. The result is the same as mentionned above

somber laurel
#

Yeah just checking the logs that fire, one second

#

Still looking at this

scenic patrol
#

Don't hesitate to ask anything that could help you πŸ™‚

somber laurel
#

Hmm, are you using your live pk_xxx key with Stripe.js?

scenic patrol
#

I hope I don't 🧐
Lemme check

somber laurel
#

Seems like it...

#

I wonder if that is influencing things somehow. That's literally all I can think of right now

scenic patrol
#

I'm sure I'm using the right keys πŸ˜…

somber laurel
#

The logs indicate pk_live_xxx was passed in some scenarios. Not sure if/why that would affect available PMs, but you should be using test keys anyway

scenic patrol
#

they start with pk_test_xxx and sk_test_xxx and values are correct

somber laurel
#

I guess you have an integration live on this account then?

scenic patrol
#

Yes I do

somber laurel
#

Ah, ignore me then

somber laurel
#

Otherwise I'm at a loss – nothing in our logs to indicate the problem so I'd recommend you write in and we can take a further look async

uneven nacelleBOT
#

Hello @scenic patrol, we have sent you a direct message, please check it at https://discord.com/channels/@me/1329797929132757161

  • πŸ”—The message has instructions on how to open a direct support case with our Developer Support team, in order to help you more effectively.
scenic patrol
#

Alright thank you for your time though πŸ™

#

Have a good day !

somber laurel
#

No problem, glad I could help!

#

OH, I know the problem

#

You need a Customer object associated with the payment/session in order for Bank Transfers to work:

You must associate a Customer object to reconcile each bank transfer payment. If you have an existing Customer object, you can skip this step. Otherwise, create a new Customer object.

Use the Payment Intents API to accept bank transfer payments.

#

Trying to figure out how that works in the deferred intent scenario

uneven nacelleBOT