#11uber_code
1 messages · Page 1 of 1 (latest)
👋 Welcome to your new thread!
⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1246171070512365619
📝 Have more to share? Add details, code, screenshots, videos, etc. below.
Hi 👋
Can you clarify which part of your code gives you this error?
And are you using our ReactNative SDK?
Hello, I just saw that the code was inclomplete, sorry, but yes, I'm using the ReactNative SDK
This is the complete snippet:
const onCheckout = async () => {
// 1. Create a payment intent
const response = await payment_service.createPaymentIntent(
service.serviceProvided.cost
);
if (!response) {
toastShow("Algo salió mal, inténtelo de nuevo");
return;
}
// 2. Initialize the Payment sheet
const { error: paymentSheetError } = await initPaymentSheet({
merchantDisplayName: "Jobis, Test",
customerId: response.customer,
customerEphemeralKeySecret: response.ephemeralKey,
paymentIntentClientSecret: response.paymentIntent, //Need the API call to get this
defaultBillingDetails: {
// Check this later
name: "Jobis",
address: "huber@alphadev.io",
},
});
if (paymentSheetError) {
console.log(paymentSheetError.message);
toastShow("Hubo un error iniciando la hoja de pagos");
return;
}
// 3. Present the Payment Sheet from Stripe
const { error: paymentError } = await presentPaymentSheet();
if (paymentError) {
console.log(
"Error code " +
paymentError.code +
", " +
JSON.stringify(paymentError, null, 4)
);
toastShow("Hubo un error mostrando la hoja de pagos");
return;
}
// 4. If payment ok -> create the order in out backend
onCreateOrder();
};
Okay and where are you getting this error? Which function is throwing it?
Also, could you please put your code between three ` on each side? It'll apply code formatting and make it easier to read
the error occurs in presentPaymentSheet, im catching the error there (the if(paymentError) clause
Okay
// 1. Create a payment intent
const response = await payment_service.createPaymentIntent(
service.serviceProvided.cost
);
if (!response) {
toastShow("Algo salió mal, inténtelo de nuevo");
return;
}
// 2. Initialize the Payment sheet
const { error: paymentSheetError } = await initPaymentSheet({
merchantDisplayName: "Jobis, Test",
customerId: response.customer,
customerEphemeralKeySecret: response.ephemeralKey,
paymentIntentClientSecret: response.paymentIntent, //Need the API call to get this
defaultBillingDetails: {
// Check this later
name: "Jobis",
address: "huber@alphadev.io",
},
});
if (paymentSheetError) {
console.log(paymentSheetError.message);
toastShow("Hubo un error iniciando la hoja de pagos");
return;
}
// 3. Present the Payment Sheet from Stripe
const { error: paymentError } = await presentPaymentSheet();
if (paymentError) {
console.log(
"Error code " +
paymentError.code +
", " +
JSON.stringify(paymentError, null, 4)
);
toastShow("Hubo un error mostrando la hoja de pagos");
return;
}
// 4. If payment ok -> create the order in out backend
onCreateOrder();
};```
Okay so in that case the first place I would start is to log out the response.customer, response.ephemeralKey, and response.paymentIntent to be sure the values you expect are present
I've check those and look correct, like this:
{"customer":"cus_QCb0Yh8fvS2jYS
ephemeralKey":"ek_test_YWNjdF8xUEdsUmMwMmlpR1JROTd3LFpGSHIzSXJGYU9hRG9ZRkVzMUFyQTIzQ29mTXplRE4_00vViN1551",
"paymentIntent":"pi_3PMaFq02iiGRQ97w1l1gabot_secret_0zOCvRMvUlqgXITP0dHrNesO0```
When you say you've checked. Do you mean you are logging those directly in the above code or do you mean you are reviewing the data somewhere else?
I logged those values in the code, and apparently the initPaymentSheet() method is working and doesn't show any error, but when presentPaymentSheet() is called it catches an error
Okay, when I look at your account logs I see a large number of failures with the following error message
The client_secret provided does not match any associated PaymentIntent on this account. Ensure the publishable key used belongs to the same account that created the PaymentIntent.**
Are you perhaps using a different key or key type? Live mode vs test mode?
Or is this a Stripe Connect scenario?
Im using just the test mode, and my stripe publishable key appears to be correct, let me check
pk_test_XXXX?
pk_test_51PGlRc02iiGRQ97wFLhEZkL8F6g1KMGaHZiZlJ7T5gdFgfIHOPif1A7ZOERhzhbk4dW2tdffLnp3t9HhztcU47YB00kGU4saMO this
I'm checking, I believe I was provided with the pk for a different account, so I was provided an incorrect pk to my stripeProvider, let me try the pk_tesk from the other account
That key belongs to the same account that created this payment intent: https://dashboard.stripe.com/test/logs/req_nk36hjI7HHarxf
so that looks correct
Okay I have to hand off to my colleague @livid pagoda who will be happy to continue assisting you. 👋