#IvonneVargas
1 messages · Page 1 of 1 (latest)
Hello! Can you clarify where you're seeing this error?
sorry I wrote wrong
I did the paymentIntent
i have 3 data
customer_id , ephemeral id, and client_secret
I try to use initPaymentSheet
like this
async initialisePaymentSheet() {
let paymentIntent = "pi_3N9EnsD8NTMkQGrD1fMpgtF2_secret_IZ9bRJzyzugAmzX0Itovvc5Ih";
let ephemeralKey = "ephkey_1N9EnMD8NTMkQGrDf8EsiFrk";
let customer = "cus_Nv4wi41lGdUAR6";
const { error } = await initPaymentSheet({
customerId: customer,
customerEphemeralKeySecret: ephemeralKey,
paymentIntentClientSecret: paymentIntent,
merchantDisplayName: 'Example Inc.',
returnURL: 'stripe-example://stripe-redirect',
allowsDelayedPaymentMethods: true,
});
if (!error) {
console.log("success");
this.setState({initializedSheets: true})
} else if (error.code === PaymentSheetError.Failed) {
console.log("PaymentSheet init failed with error code: " + error.message);
} else if (error.code === PaymentSheetError.Canceled) {
console.log("PaymentSheet init was canceled with code: " + error.message);
}
};
but, print this error "init failed with error code: customerEphemeralKeySecret format does not match expected client secret formatting."
what am I doing wrong?
Instead of passing in ephkey_123 we're expecting somethign like ek_test_123
Are you making sure to pass in the secret you get back when you create the Ephemeral Key and not the id?
{
"id": "ephkey_1N9EnMD8NTMkQGrDf8EsiFrk",
"object": "ephemeral_key",
"associated_objects": [
{
"id": "cus_Nv4wi41lGdUAR6",
"type": "customer"
}
],
"created": 1684446936,
"expires": 1684450536,
"livemode": false,
"secret": "ek_test_YWNjdF8xTE5OMmREOE5UTWtRR3JELE5ReVp3eUQzSGlNS1hlbEFEYlJETWF2Tk1LbjZNdHk_00UwbYWxoA"
}
pass id...
that's the issue then - you need to be using secret not id