#gyungi-terminal
1 messages ยท Page 1 of 1 (latest)
Hiya! So my current flow is to create a payment intent server side, sent the client secret to the client, collect a payment method and then pass that to my server to capture the payment.
However, when I try and capture the payment, it gives an error telling me it's expecting a different status, namely it's expecting a payment intent with status requires_capture and what I'm handing it is something with the status requires_payment_method
{"code":"payment_intent_unexpected_state","doc_url":"https://stripe.com/docs/error-codes/payment-intent-unexpected-state","status":400,"message":"This PaymentIntent could not be captured because it has a status of requires_payment_method. Only a PaymentIntent with one of the following statuses may be captured: requires_capture."
For reference, this is the front-end code that's interacting with my backend:
if (stripeClientSecret) {
const result = await terminal?.collectPaymentMethod(stripeClientSecret)```
oh sorry I suppose I should have attached the whole bit of code
companyId,
amountDollars: centsToDollars(getValues("total")) ?? 0,
customerId: customer?.id ?? "",
saveCardToCustomer: false,
})
const stripeClientSecret = cardPresentPaymentData.data?.stripeClientSecret
if (stripeClientSecret) {
const result = await terminal?.collectPaymentMethod(stripeClientSecret)```
where initiateCardPresentPayment creates the paymentIntent object
Could you share the payment intent ID (pi_xxx)?
It looks like you tried to capture the payment intent before a payment method is collected
Can you share the full code until capturing the payment intent?
_, err := paymentintent.Capture(stripePaymentIntentID, params)```
so this is all I have on the server side for capturing the payment
and I guess I'm just not sure how I attach the payment method to the payment intent- I thought that was the whole point of the collectPaymentMethod call
When collectPaymentMethod is called, does your reader show up asking for payment?
That sounds about right! After collectPaymentMethod is invoked successfully, do you send to processPayment? https://stripe.com/docs/terminal/payments/collect-payment?terminal-sdk-platform=js#process-payment
ahhhh nope I'm imagining that might be the missing piece
Totally missed that
let me try that thank you!
No problem! Payment intent status will only move to requires_capture after processPayment is called, then you can capture the payment
got it! Super helpful. Thanks!
Glad to help! Let me know if you have other question ๐
That worked!! You're a life saver ๐
Awesome! Great to hear that it works ๐