#ryonwhyte
1 messages · Page 1 of 1 (latest)
Hello! When you say nothing happens can you be more specific? What code is involved? Which specific code are you running that does nothing?
Hi. I am using this format
https://stripe.com/docs/payments/accept-a-payment-deferred
In the server side code. I can return an error that is displayed on the payment sheet. Error that come from stripe like if a card is declined.
In my case I also validate a users coupon in this step since technically a user could apply a coupon on the cart but not buy until the next day when maybe the coupon is no longer available.
If there is an error that retuirned to the payment sheet and displayed it like the same payment sheet no longer works. I have to close it an dtrigger the transaction again. Pressing the pay button does nothing in the app. I can see the backend code running but nothing updates the payment sheet
Yep, I understand the issue at a high level, but can you share your code? Or can you link me to a test case where I can reproduce the issue?
Like what does your stripe.confirmPayment code look like? How does it get called? What happens before it gets called?
Here is my server create intent code
https://pastebin.com/mdLz1wW9
And here is my payment sheet code. The initPaymentIntent function call is where I create the payment intent (Call to server ).
You can see possible server responses in the server code. If there is an error, I pass it to the callback function which display it in the payment sheet.
I'm not seeing where you call confirmPayment on the client.
Is it in your intentCreationCallback function?
I think I am doing that server side. I complete the charge on the server.
I am I followed it to the T. I dont know another way. Let me get familar with this again
Hmm. seems to be client side?
https://stripe.com/docs/payments/accept-a-payment-deferred?platform=react-native&type=payment#confirm-the-payment
Chekc this function
const handleConfirmation = async (
you will see the intentCreationCallback. that passes IntentSecret
Search the code you shared for confirmPayment.
This portion
` const handleConfirmation = async (
paymentMethod,
shouldSavePaymentMethod,
intentCreationCallback
) => {
//Now we create the pending order for customer
console.log("About to create order");
const initOrder = await insertOrder(
userSession.user.id,
topupProcess,
intentID
);
if (initOrder.status === false) {
Toast.show("Failed to create order", {
duration: Toast.durations.LONG,
position: Toast.positions.TOP,
backgroundColor: colors.appblue,
textColor: colors.appwhite,
});
return;
}
order_id = initOrder.order;
console.log("Order inserted", initOrder.order);
//Here we init the payment intent
let { intentID, intentSecret, error } = await initPaymentIntent(
initOrder.order,
finalToPayRealProcessed,
paymentMethod.id,
customer,
shouldSavePaymentMethod
);
if (intentSecret === false) {
/* Toast.show(message, {
duration: Toast.durations.LONG,
position: Toast.positions.TOP,
backgroundColor: colors.appblue,
textColor: colors.appwhite,
});*/
//if there is an error we return error
intentCreationCallback({ error: error });
} else {
//if all is good we return the callback and continue
intentCreationCallback({ clientSecret: intentSecret });
}
};`
Yes, I can see the code. But it does not contain the code I need to see.
You are not calling confirmPayment in there.
You did not share the code where you call confirmPayment.
What I need, in order to help you, is to see the code where you call confirmPayment.
Does that make sense?
Mine is handleConfirmation same thing
It is not the same thing.
Just different funtion name
It is, in fact, a very different thing.
The function name is set by Stripe.js.
It's not your function, it's our function.
And I need to see where you're calling it.
You mean this section
intentConfiguration: {
mode: {
amount: finalToPayRealProcessed * 100,
currencyCode: "USD",
//captureMethod: "Manual",
},
paymentMethodTypes: ["card"],
confirmHandler: handleConfirmation,
},
Nope.
Can you search your entire codebase for stripe.confirmPayment( and see if anything turns up?
Make sure you include that ( at the end.
Yeaaah. I didnt use that. Its on line 81, but I never used it 🤔
const {
initPaymentSheet,
confirmPaymentIntent,
presentPaymentSheet,
confirmPayment,
} = useStripe();
If you're following this guide using that is not optional.
Like... you not using that is why "nothing happens".
You're not calling the code that makes things happen.
Well. That's weird. Payment are always successful. See my test transactions pi_3OLEC2JgUVsS8tQc1zNIqTed
Looking...
You have confirm set to true server-side. That means you're not using the approach in the docs you linked to.
confirm is not set at all there.
But in your request to create the Payment Intent you shared here: https://dashboard.stripe.com/test/logs/req_8JDCgrvviTEdGr
You're setting confirm to true.
Doing that is not compatible with the docs you linked to.
I test a lot of cases as well, 3ds, stolen cards, decline cards. All works. The only place there is a weird error is when I send an error to the payment sheet. Everything else works
It seems like you might be mixing up mutliple incompatible approaches?
Can you explain why you're setting confirm to true server-side?
Were you perhaps following this other, completely different guide? https://stripe.com/docs/payments/finalize-payments-on-the-server
No... I think I know why. Maybe the approach is wrong. But its in the same doc. There is this note
Note
When confirming a PaymentIntent from the server, pass it the mandate_data parameter to acknowledge that you’ve shown the customer the proper terms for collecting their payment details. To make sure you display the proper terms, be sure that all IntentConfiguration properties match your PaymentIntent (for example, setup_future_usage, amount, and currency).
It is also at the very top of the page. Which i guess sounded to me like I could choose to do it either way.
You could give that a try, but I still don't understand why you're setting confirm to true on your server. Where in this guide does it say to do that?
Austin looked at it once and asked similar I don't remember the conversation, but I think it was fine.
The beginning of the docs
The Payment Element allows you to accept multiple payment methods using a single integration. In this integration, learn how to build a custom payment flow where you render the Payment Element, create the PaymentIntent, and confirm the payment in the buyer’s app. If you prefer to confirm the payment from the server instead, see Finalize payments on the server.
To me, it sounds like its up to the developer to confirm client side or server side.
Yeah, but Finalize payments on the server links to the completely different guide which I linked to above.
It's a totally different approach and is not compatible with this guide.
The sentence, "If you prefer to confirm the payment from the server instead, see Finalize payments on the server." should be read as "if you want to finalize on your server you need to use a completely different guide/approach, not this one, here's a link to the thing you need to do that is not this."
The other guide is similar, and many of the core concepts and even some of the code is the same, but they're not compatible approaches.
OK. Agreed Maybe remove the note as well with more instructions on confirming server side. https://stripe.com/docs/payments/accept-a-payment-deferred?platform=react-native&type=payment#ios-submit-payment
You need to choose one or the other.
I'll flag that docs change internally, yep. Not sure why that note is there.
Is the payment intent not applicable? I think I would prefer to keep the code. It works and make the most sense for my implementation. At least until it stops working.
But if the PI is a frankenstein I can rework it and try to find some other way.
Both approaches use Payment Intents. Not sure I understand your question?
The transaction you looked that. Was it normal or messed up in a way I dont know? If its normal and works I'll keep the code for now. If not then I'll recode and try to find another workaround
It's normal for an approach like this one: https://stripe.com/docs/payments/finalize-payments-on-the-server
If you want to keep that server-side code you need to adjust your client-side code to match that guide.