#mactavish_unexpected

1 messages ¡ Page 1 of 1 (latest)

waxen flowerBOT
#

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

flint hazel
#

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

clear shard
#

Can you share the code where you call confirmPayment?

clear shard
#

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

flint hazel
# clear shard Can you share the code where you call `confirmPayment`?

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"
                ],
            ]);
flint hazel
clear shard
#

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

clear shard
flint hazel
# clear shard This isn't relevant, I mean the Stripe.js code in your front-end that you call w...
        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);
            });
    });
clear shard
clear shard
clear shard
#

Not recently, AFAIK

flint hazel
#

well.. shouldn't it affect all payments instead of Apple Pay only?

clear shard
#

In theory yes. Got another example that didn't fail that uses same code?

flint hazel
#

plenty of them. the following are just a glimpse
pi_3RGQzmIDuaDiV9P11SFociBo
pi_3RGJuQIDuaDiV9P11ALq3U6w
pi_3RGHqXIDuaDiV9P10LWhdeV0

clear shard
#

Looking at pi_3RGQzmIDuaDiV9P11SFociBo, there were two confirmation requests:

#

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

flint hazel
clear shard
#

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

clear shard
flint hazel
#

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.

clear shard
#

Will what affect it?

flint hazel
# clear shard 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?

clear shard
#

Nope, you shouldn't need to update any other Stripe code