#mactavish_unexpected
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always 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/1364194056170635335
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Here's SS from a customer
Here's a payment intent id from a customer who claims that Apple Pay didn't work for them pi_3RGJrNIDuaDiV9P10bCZBOxA
Looks like your integration is sending invalid data: https://dashboard.stripe.com/logs/req_iNbmdC2n4j1myd
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Can you share the code where you call confirmPayment?
Specifically, payment_method_data[billing_details][address] should be an object but you're sending a string
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Although if this is from Apple Pay you probably don't control that and we automatically get the values from the customer's wallet. But curious to see your code
Also, I'd guess this is just happening to that one customer? Likelihood they just need to update their address in their wallet
Not sure what this refers to here. The integration was done Mar 2022.
Here's the code which creates payment intent
$intent = \Stripe\PaymentIntent::create([
'amount' => $stripe_total,
'currency' => $currency,
'automatic_payment_methods' => [
'enabled' => 'true',
],
'metadata' => [
'integration_check' => 'accept_a_payment', // Verify your integration in this guide by including this parameter
'order_id' => $order->id,
'tax' => $order->tax,
'shipping' => $order->shipping,
'shipping_tax' => $order->shipping_tax,
'currency' => $order->currency,
'first_name' => $order->first_name,
'last_name' => $order->last_name,
'email' => $order->email,
'mobile' => $order->mobile,
'street' => $order->street,
'building' => $order->building,
'country' => $order->country,
'state' => $order->state,
'city' => $order->city,
'zip' => $order->zip,
'cid' => $order->cid,
'site' => "minaalsheikhly"
],
]);
No. It's happening to about 1 customer each day. That's what I got from customer support team
Yeah their address data in the wallet on their device is likely just not formatted correctly, so when they click 'pay' in the Apple Pay dialog it's send to us in the wrong format. We should definitely handle that better though
This isn't relevant, I mean the Stripe.js code in your front-end that you call when the customer clicks that 'pay now' button in your screenshot
stripe.confirmPayment({
elements,
confirmParams: {
// return url is not for Order Confirmation Only. it's simply a redirect by stripe. in some cases,
// it can even go there when there are errors.
return_url: "{{route('order_confirmation')}}",
payment_method_data: {
billing_details: {
name: "{{$order->first_name}} {{$order->last_name}}",
email: "{{$order->email}}",
phone: "{{$order->mobile}}",
address: "{{$order->street}} {{$order->building}}",
}
},
},
// Uncomment below if you only want redirect for redirect-based payments
// redirect: 'if_required',
})
.then(function(result) {
// This point will only be reached if there is an immediate error when
// confirming the payment. Otherwise, your customer will be redirected to
// your `return_url`. For some payment methods like iDEAL, your customer will
// be redirected to an intermediate site first to authorize the payment, then
// redirected to the `return_url`.
if (result.error.type === "card_error" || result.error.type === "validation_error") {
showMessage(result.error.message);
} else {
showMessage("An unexpected error occured.");
}
setLoading(false);
});
});
OK, yeah your code is sending the payment_method_data[billing_details][address] parameter in the wrong format
It's sending a string, should be an object
when did this change occur?
Not recently, AFAIK
well.. shouldn't it affect all payments instead of Apple Pay only?
In theory yes. Got another example that didn't fail that uses same code?
plenty of them. the following are just a glimpse
pi_3RGQzmIDuaDiV9P11SFociBo
pi_3RGJuQIDuaDiV9P11ALq3U6w
pi_3RGHqXIDuaDiV9P10LWhdeV0
Looking at pi_3RGQzmIDuaDiV9P11SFociBo, there were two confirmation requests:
- This failed as your code passed the same incorrectly formatted param
- 2nd attempt succeeded as the param was sent in the correct format: https://dashboard.stripe.com/logs/req_MPrGGAEfJopi6G
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
So this most definitely is an integration issue somewhere
Hmm, maybe the first attempt was with Apple Pay, failed and then they retried with a normal card? But you're code is still wrong so you should fix that
It's probably this way. Same code runs for each payment regardless of method. Seems like stripe does some correction on it's own?
I cant seem to find the docs reference that I used years ago to integrate.
I am wondering why is it this way even when I am still using API version 2020-08-27
API version has nothing to do with that, the shape of that API/param has never changed
You just need to update your confirmPayment code to use the correct shape. I can't speak to why that this is happening specifically on Apple Pay payments with the context you've shared
Perhaps different code is called if it's not Apple Pay? I don't know. But the shape of the param you're sending to payment_method_data[billing_details][address] is wrong
Well. Just one question before I fix it.
Will it affect anything else in frontend or backend code? The integration is using Payments Intents API as opposed to newer Checkout Session API.
Will what affect it?
Apologies for the confusion. I mean to say that will I need any other change in Backend code or Frontend code/integration of Stripe.js alongside converting the address to object?
Nope, you shouldn't need to update any other Stripe code