#ryonwhyte

1 messages · Page 1 of 1 (latest)

tight muralBOT
sonic needle
#

Hello! When you say nothing happens can you be more specific? What code is involved? Which specific code are you running that does nothing?

vital hatch
#

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

sonic needle
#

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?

vital hatch
#

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 ).

https://pastebin.com/q5cP29VC

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.

sonic needle
#

I'm not seeing where you call confirmPayment on the client.

#

Is it in your intentCreationCallback function?

vital hatch
#

I think I am doing that server side. I complete the charge on the server.

sonic needle
#

So you're not using the docs you linked to?

vital hatch
#

I am I followed it to the T. I dont know another way. Let me get familar with this again

sonic needle
#

Yes.

#

But it's not in the client side code you shared.

vital hatch
#

Chekc this function
const handleConfirmation = async (

you will see the intentCreationCallback. that passes IntentSecret

sonic needle
#

Search the code you shared for confirmPayment.

vital hatch
#

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 });
}

};`

sonic needle
#

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?

vital hatch
#

Mine is handleConfirmation same thing

sonic needle
#

It is not the same thing.

vital hatch
#

Just different funtion name

sonic needle
#

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.

vital hatch
#

You mean this section

intentConfiguration: {
mode: {
amount: finalToPayRealProcessed * 100,
currencyCode: "USD",
//captureMethod: "Manual",
},
paymentMethodTypes: ["card"],
confirmHandler: handleConfirmation,
},

sonic needle
#

Nope.

#

Can you search your entire codebase for stripe.confirmPayment( and see if anything turns up?

#

Make sure you include that ( at the end.

vital hatch
#

Yeaaah. I didnt use that. Its on line 81, but I never used it 🤔

#

const {
initPaymentSheet,
confirmPaymentIntent,
presentPaymentSheet,
confirmPayment,
} = useStripe();

sonic needle
#

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.

vital hatch
#

Well. That's weird. Payment are always successful. See my test transactions pi_3OLEC2JgUVsS8tQc1zNIqTed

sonic needle
#

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.

#

You're setting confirm to true.

#

Doing that is not compatible with the docs you linked to.

vital hatch
#

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

sonic needle
#

It seems like you might be mixing up mutliple incompatible approaches?

#

Can you explain why you're setting confirm to true server-side?

vital hatch
#

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.

sonic needle
#

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?

vital hatch
#

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.

sonic needle
#

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.

vital hatch
sonic needle
#

You need to choose one or the other.

#

I'll flag that docs change internally, yep. Not sure why that note is there.

vital hatch
#

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.

sonic needle
#

Both approaches use Payment Intents. Not sure I understand your question?

vital hatch
#

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

sonic needle
#

If you want to keep that server-side code you need to adjust your client-side code to match that guide.