#mykola5123
1 messages · Page 1 of 1 (latest)
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
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?
You can do this with the Stripe-Account header, as explained on this page: https://stripe.com/docs/connect/authentication
Thanks. How to use such payment intent by the initPaymentSheet methons on the UI side.
From the documentation
https://stripe.com/docs/payments/accept-a-payment
I need to provide
customerId
customerEphemeralKeySecret
where can I get it?
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
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
}
)
You also need to add the Stripe-Account header to your frontend: https://stripe.com/docs/connect/authentication#adding-the-connected-account-id-to-a-client-side-application
Thank you I will try
sorry but I get siimilar error. My App.js
<StripeProvider
publishableKey={skimpel_publisable_key}
stripeAccountId={connected_account_id}
>
...
</StripeProvider>
Can you share the request ID (req_xxx)? You can find it here https://dashboard.stripe.com/test/logs
req_6rgVUnQRFaDgWe
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 ..."
from marketplace stripe account?
I don't understand your question.
Or can you just copy-paste the customer ID in your screenshot above?
I have such architecture with stripe accounts. On the top there is a stripe account for marketplace.
where should I look for req_xxx?
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
Exact, Im using Direct Charges.
"the secret key of the platform account" means secret key from main stripe account (on the top) right?
Yes
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.
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.
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?
I can follow. What's your question?
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(...)
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
}
}
So did you solve the issue?
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
Hey ther,e taking a look. Payment Methods available depend on a number of factors.
Hey there, waht should I look exactly?
It looks like that connected account only has that payment method enabled
no its not
You can influence settings for your connected accounts here: https://dashboard.stripe.com/test/settings/payment_methods/connected_accounts
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
What are your settings here?
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)
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
And if you create a new payment intent now using automatic payment methods, can you share that ID/request again?
I found also this /payment_methods request with "type" parameter equal "card"
but this request was made not from my side
Thanks for the request new request ID, checking in to that
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
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
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>
)
}
Thank you, looking over your code...
And what stripe-react-native version are you using?
0.19.0
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.
Thank you
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?
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
sure
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
export const fetchPaymentSheetParams = async orderId => {
return axios.get(`/orders/${orderId}/payment-sheet`)
}
Going to pull in some colleagues to look at this as well.
Gotcha, thanks for confirming
@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
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
I see. My current apps targeting iOS is 12. And I found this on the https://github.com/stripe/stripe-react-native
Are there another way (maybe better one) how can I create a payment form for the user?
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.
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!
Sounds good, thank you for your patience! Apologies it took a bit to diagnose this