#mykola5123

1 messages · Page 1 of 1 (latest)

analog geyserBOT
iron pawn
#

Hi there!

#

Can you past your other message in this thread?

timid ember
#

hello

#

sure

#

should I remove the message in the main chat?

#

so I try to display this form for the customers

#

right now I get only card payment methods

iron pawn
#

What exactly is your question? Is it this?

How can I create a payment Intent for the connected account and use this payment intent in the initPaymentSheet method?

timid ember
iron pawn
#

You do the same as usual:

  • Create the customer with customers.create()
  • Rquest the ephemeral key with ephemeralKeys.create()
    But in both cases you need to make sure you set the Stripe-Account header
timid ember
#

after add stripeAccount parameter I bekome the error on the UI side.


        const paymentIntent = await this.stripeService.paymentIntents.create(
            {
                amount: Number(10) * 100,
                currency: 'eur',
                automatic_payment_methods: {
                    enabled: true
                }
            },
            {
                stripeAccount: connected_account_id
            }
        )
iron pawn
timid ember
#

Thank you I will try

#

sorry but I get siimilar error. My App.js

   <StripeProvider
      publishableKey={skimpel_publisable_key}
      stripeAccountId={connected_account_id}
    >
      ...
 
   </StripeProvider>
iron pawn
timid ember
#

req_6rgVUnQRFaDgWe

iron pawn
#

This is a dashboard request, which has nothing to do with the error you shared above.

#

I need the request ID that generated the error "no such customer ..."

timid ember
#

from marketplace stripe account?

iron pawn
#

I don't understand your question.

#

Or can you just copy-paste the customer ID in your screenshot above?

timid ember
#

I have such architecture with stripe accounts. On the top there is a stripe account for marketplace.

#

where should I look for req_xxx?

iron pawn
#

Exactly, and it looks like you are using Direct Charges https://stripe.com/docs/connect/direct-charges
So when you create a PaymentIntent or a Customer, you need to make sure you use the secret key of the platform account, and then set the Stripe-Account header to the ID of the connected account. Both in the backend and the frontend, and it should work.

#

where should I look for req_xxx?
When using the Stripe-Account header, it should be visible on the connected account

timid ember
#

Exact, Im using Direct Charges.

"the secret key of the platform account" means secret key from main stripe account (on the top) right?

iron pawn
#

Yes

timid ember
#

OK then it looks good.
But why should I set connected account ID to the Stripe-Account header??? I can read it directly on the backend.

iron pawn
#

I'm not sure I understand your question. But when you want to interact with a connected account, you always have to set the Stripe-Account header, both on the backend and on the frontend.

timid ember
#

right now I hardcoded the connected account ID on the backend and use it by the payment intent creation

async createPaymentSheet() {
        const connected_account_id = 'acct_xxxxxxxxxxx'

        const customer = await this.stripeService.customers.create()

        const ephemeralKey = await this.stripeService.ephemeralKeys.create(
            { customer: customer.id },
            { apiVersion: '2020-08-27' }
        )

        const paymentIntent = await this.stripeService.paymentIntents.create(
            {
                amount: Number(10) * 100,
                currency: 'eur',

                automatic_payment_methods: {
                    enabled: true
                }
            },
            {
                stripeAccount: connected_account_id
            }
        )

        return {
            paymentIntent: paymentIntent.client_secret,
            ephemeralKey: ephemeralKey.secret,
            customer: customer.id
        }
    }
#

The same account ID Im using on the UI

<StripeProvider
      publishableKey={skimpel_publisable_key}
      stripeAccountId={connected_account_id}
    >
      ...
 
   </StripeProvider>

#

can you follow me or is it too much code?

iron pawn
#

I can follow. What's your question?

timid ember
#

Why I get the error message on the UI?

#

No such customer: 'cus_OIA6oTGinfYYvL'

iron pawn
#

Thanks, that customer wasn't created with the Stripe-Account header.

#

This line is missing the Stripe-Account header:

const customer = await this.stripeService.customers.create()

#

And this one too:

const ephemeralKey = await this.stripeService.ephemeralKeys.create(...)

analog geyserBOT
timid ember
#

Ufffff I hope you are getting money for your support 😀

#

this code works

async createPaymentSheet() {
        const connected_account_id = 'acct_xxxxxxxxxx'

        const customer = await this.stripeService.customers.create({
            stripeAccount: connected_account_id
        })

        const ephemeralKey = await this.stripeService.ephemeralKeys.create(
            { customer: customer.id },
            {
                stripeAccount: connected_account_id,
                apiVersion: '2020-08-27'
            }
        )

        const paymentIntent = await this.stripeService.paymentIntents.create(
            {
                amount: Number(10) * 100,
                currency: 'eur',

                automatic_payment_methods: {
                    enabled: true
                }
            },
            {
                stripeAccount: connected_account_id
            }
        )

        return {
            paymentIntent: paymentIntent.client_secret,
            ephemeralKey: ephemeralKey.secret,
            customer: customer.id
        }
    }
iron pawn
#

So did you solve the issue?

timid ember
#

yes, but the form display only one payment method

#

how you see Im using automatic_payment_methods

#

how can I get all payment methods from the connected account?

#

this is the request ID req_E1UvfsyjpUIuGz

strong epoch
#

Hey ther,e taking a look. Payment Methods available depend on a number of factors.

timid ember
#

Hey there, waht should I look exactly?

strong epoch
#

It looks like that connected account only has that payment method enabled

timid ember
#

no its not

strong epoch
timid ember
#

the account has another payment methods

timid ember
strong epoch
#

Those are not the same settings I see enabled for the account of the request you shared, in particular paypal is not on

#

only cards (plus apple pay and google pay, which are cards, but require the device to be configured with a card in that wallet)

timid ember
#

My fail, sorry. I was sure that I turn them all. But right now I get the same form (only with cards methods) even I turned the payment methods on

#

Connected account ID: acct_1NUGPsQq5m6X6BPf

strong epoch
#

And if you create a new payment intent now using automatic payment methods, can you share that ID/request again?

timid ember
#

yes sure

#

one minute more please

#

req_bM2gxEfp4SgW1t

#

/payment_intents

analog geyserBOT
timid ember
#

I found also this /payment_methods request with "type" parameter equal "card"

#

but this request was made not from my side

potent quest
#

Thanks for the request new request ID, checking in to that

strong epoch
#

Ok, this request we see the other payment method types in the payment intent and automatic payment method result

#

That payment method creation request is different/separate

potent quest
#

Can you send your code for setting up the payment sheet on the client? It looks like this may be a client-side issue now that the intent itself shows other payment methods

timid ember
#

sure

#

import { fetchPaymentSheetParams } from '@/store/basket/requests'
import React, { useEffect, useState } from 'react'
import { Text, View, Button, SafeAreaView, Alert } from 'react-native'
import { useStripe } from '@stripe/stripe-react-native'

export const PaymentScreen = ({ navigation }) => {
  const orderId = navigation.getParam('orderId')

  const { initPaymentSheet, presentPaymentSheet } = useStripe()
  const [loading, setLoading] = useState(false)

  const initializePaymentSheet = async () => {
    const resp = await fetchPaymentSheetParams(orderId)

    const { paymentIntent, ephemeralKey, customer } = resp.data

    const { error } = await initPaymentSheet({
      customerId: customer,
      customerEphemeralKeySecret: ephemeralKey,
      paymentIntentClientSecret: paymentIntent,
      testEnv: true,
      allowsDelayedPaymentMethods: true,
      defaultBillingDetails: {
        name: 'Jane Doe',
      },
    })

    if (!error) {
      setLoading(true)
    }
  }

  const openPaymentSheet = async () => {
    const { error } = await presentPaymentSheet()

    if (error) {
      Alert.alert(`Error code: ${error.code}`, error.message)
    } else {
      Alert.alert('Success', 'Your order is confirmed!')
    }
  }

  useEffect(() => {
    initializePaymentSheet()
  }, [])

  return (
    <SafeAreaView>
      <Button
        variant="primary"
        disabled={!loading}
        title="Checkout"
        onPress={openPaymentSheet}
      />
    </SafeAreaView>
  )
}



potent quest
#

Thank you, looking over your code...

#

And what stripe-react-native version are you using?

timid ember
#

0.19.0

potent quest
#

Thank you, not seeing any patch notes since that release that obviously point to a fix for this. Also not immediately seeing anything in your code. Still looking.

timid ember
#

Thank you

potent quest
#

Hey, apologies for the delay. I am still looking, just unsure what else may be affecting your client here.

Can you test this again, print out the ID of the payment intent that you are getting back and send that ID to me?

timid ember
#

sure

#

sorry ist a wrong one

#

req_muYk8f8KHzpfIH

potent quest
#

Yeah those calls still look right. Would you mind sending your code for Would you mind sending your code for fetchPaymentSheetParams as well? I imagine it just reaches out to the server and returns the response but it may help to see

timid ember
#

sure

potent quest
#

At this point I am wondering if it is possible for there to be some mixup or hardcoding client-side though the fact that your server is actually making these calls each time makes that seem very unlikely

timid ember
#

export const fetchPaymentSheetParams = async orderId => {
  return axios.get(`/orders/${orderId}/payment-sheet`)
}
potent quest
#

Going to pull in some colleagues to look at this as well.

#

Gotcha, thanks for confirming

timid ember
#
    @UseGuards(AuthGuard('jwt'), RoleGuard)
    @Get(':orderId/payment-sheet')
    getPaymentSheetParams(@ReqUser() userId: number, @Param('orderId') orderId: number) {
        return this.ordersCheckoutService.getPaymentSheetParams(userId, orderId)
    }

    async getPaymentSheetParams(userId: number, orderId: number) {
        return this.transactionsRequestsService.createPaymentSheet()
    }
#

backend

potent quest
#

So it turns out that all of the non-card payments are not supported in that version of the RN SDK for one reason or another. Link was added in 0.20, Paypal was added in 0.26, and AliPay + WeChat pay are still not supported on the mobile payment sheet
https://github.com/stripe/stripe-react-native/blob/master/CHANGELOG.md#0200---2022-11-03
https://github.com/stripe/stripe-react-native/blob/master/CHANGELOG.md#0260---2023-03-16
https://stripe.com/docs/payments/payment-methods/integration-options#support-wallets

#

So if you upgrade to 0.26, Link and PayPal will show up at least. Future versions will probably be needed for WeChat and AliPay

timid ember
#

Are there another way (maybe better one) how can I create a payment form for the user?

potent quest
#

Gotcha, sorry to hear. This would be the only native app way that I am aware of for presenting this sheet. You may also be able to use a WebView and direct your users to a payment page on Stripe though I'm not sure if that UX would work well with what you have in mind.

timid ember
#

Hmmm maybe I will try to upgrade the apps targeting to 13. Then I will try the last version of stripe-react-native.

#

Thank you a lot for your time an help!

potent quest
#

Sounds good, thank you for your patience! Apologies it took a bit to diagnose this