#Gerald - Redfluencer
1 messages · Page 1 of 1 (latest)
Hi! Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
I don't think this is the correct request ID, the response is 200 and there's no error
let me try it again
Hi jack, still the same. The intent pops up for a quick second before it closes and throws the same error
would it be alright if I could do a video call to show you?
I can only support you through chat.
Or can you share with me the relevant code? both backend and frontend.
sure
backend
apiVersion: "2022-08-01",
});
const token = await stripe.tokens.create(
{ customer: "cus_Mg2WOw41gS1ggp" },
{ stripeAccount: "acct_1LwfZwCGwb4Rcxpz" }
);
const customer = await stripe.customers.create(
{ source: token.id },
{ stripeAccount: "acct_1LwfZwCGwb4Rcxpz" }
);
console.log(customer);
const ephemeralKey = await stripe.ephemeralKeys.create(
{ customer: "cus_Mg2WOw41gS1ggp" },
{ apiVersion: "2022-08-01" }
);
const paymentIntent = await stripe.paymentIntents.create(
{
amount: 999,
currency: "sgd",
payment_method_types: ["card"],
customer: customer.id,
payment_method: customer.default_source,
},
{
stripeAccount: "acct_1LwfZwCGwb4Rcxpz",
}
);
console.log(paymentIntent);
res.json({
paymentIntent: paymentIntent.client_secret,
ephemeralKey: ephemeralKey.secret,
customer: "cus_Mg2WOw41gS1ggp",
});```
frontend
// temp body
const params = {
userId: userInfo.uid,
stripeId: userData.stripeId,
amount: parseFloat(payToMerchantAmount),
shopId: merchantData.shopUUID,
merchantId: merchantData.merchantUUID,
promoCode,
};
const { token } = await auth().currentUser.getIdTokenResult();
const response = await fetch(`${API_URL}/stripe/checkout`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ params }),
});
const { paymentIntent, ephemeralKey, customer, dateCreated } =
await response.json();
return {
paymentIntent,
ephemeralKey,
customer,
dateCreated,
};
};
const proceed = paymentControls();
if (!proceed) {
return;
}
setLoading(true);
const { paymentIntent, ephemeralKey, customer, dateCreated } =
await fetchPaymentSheetParams();
const { error } = await initPaymentSheet({
customerId: customer,
customerEphemeralKeySecret: ephemeralKey,
paymentIntentClientSecret: paymentIntent,
merchantDisplayName: "testing",
postalCodeField: false,
defaultBillingDetails: {
address: {
country: "SG",
},
},
appearance: {
shapes: {
borderRadius: 12,
borderWidth: 0.5,
},
colors: {
primary: "#FF2741",
background: "#ffffff",
componentBackground: "#f3f8fa",
componentBorder: "#f3f8fa",
componentDivider: "#000000",
primaryText: "#000000",
secondaryText: "#000000",
componentText: "#000000",
placeholderText: "#73757b",
},
},
});
if (!error) {
await openPaymentSheet(paymentIntent, dateCreated);
}
};```
I will call initializePaymentSheet when a button is being pressed
OK. I think I know the problem.
You need to specify the stripeAccountId when initializing the react-native SDK.
publishableKey="{{PLATFORM_PUBLISHABLE_KEY}}"
stripeAccountId="{{CONNECTED_STRIPE_ACCOUNT_ID}}"
>
// Your app code here
</StripeProvider>```
oh I see now it works. So does that I have to dynamically change the stripe account ID everytime I pay to a different merchant?
And you also need to specify the stripeAccount when creating the ephemeral key
like this?
const ephemeralKey = await stripe.ephemeralKeys.create(
{ stripeAccount: "{{PLATFORM_STRIPE_ACCOUNT_I}}"}
{ customer: "cus_Mg2WOw41gS1ggp" },
{ apiVersion: "2022-08-01" }
);
You should specify the stripe account ID for the merchant that you wish to operate on behalf of.
so this should be connected account ID?
stripe.ephemeralKeys.create({
customer: 'cux_XXX',
apiVersion: '2022-08-01'
},{
stripeAccount: 'CONNECTED_ACCOUNT_ID'
})
It should be something like this
got it thanks