#lord-aurelion_prefill-checkout

1 messages Β· Page 1 of 1 (latest)

bitter terraceBOT
#

πŸ‘‹ 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/1300440714626203763

πŸ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

dire kayak
#

Where are you passing ['allow_redisplay' => 'always'] could you please share more details ?

#

Could you please share some Stripe object Id ? like payment method Id ?

neon pike
#

Of Course, here is the code where I update my payment method :

$stripe = new StripeClient(config('stripe.secret'));
            return $stripe->paymentMethods->update(
                $paymentMethodId,
                [
            'allow_redisplay' => 'always'
        ]
            );

This is a payment ID for example : pm_1QEsNZD3c9FKJvdgN6g5ijef

This is in my test environnment, when I say it doesn't work, it's when the user goes to Stripe checkout, the card is not preselected

high ferry
#

Hi there πŸ‘‹ jumping in as my teammate needs to step away.

Looking at the Payment Method, I believe it isn't being prefilled in checkout due to the Payment Method not having complete billing details:
https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=stripe-hosted#handling-existing-customers:~:text=The Checkout page requires a valid billing address%2C billing name%2C and billing email to prefill the customer’s card details

If you update the Payment Method with additional billing details including a name and email, does it begin showing?

bitter terraceBOT
#

lord-aurelion_prefill-checkout

neon pike
#

Okay thank you for your response, I'll try it, I need a few minutes

#

It does not seems to work, here is the parameters, did i missed something?

[
            'allow_redisplay' => 'always',
            'billing_details' => [
                'address' => [
                    'line1' => '158 Place Biscarre',
                    'line2' => '',
                    'city' => 'TOULON',
                    'postal_code' => '83000',
                    'country' => 'FR'
                ]
            ]
        ]

My new test payment ID : pm_1QEslhD3c9FKJvdgSvj0dMOg

high ferry
#

Hm, I think that all looks right. Do you see anything prefilled in the checkout session?

neon pike
#

Okayyy, i tried to prefill all of this :

[
            'allow_redisplay' => 'always',
            'billing_details' => [
                'email' => $user->email,
                'name' => $user->name,
                'phone' => '+33625190464',
                'address' => [
                    'line1' => '158 Place Biscarre',
                    'line2' => '',
                    'city' => 'TOULON',
                    'postal_code' => '83000',
                    'country' => 'FR'
                ]
            ]
        ]

And seems now to work, thank you πŸ™‚ I just have one last question, after the billing portal to add the card with 'type' => 'payment_method_update', it adds the card as default payment method on the customer, how do I make it not default? Is there a parameter?

high ferry
#

Where are you seeing that? Is that it's labeled as default in the Stripe dashboard (something I'm not familiar with how to control), or are you seeing it added to the invoice_settings.default_payment_method field on the Customer object?

neon pike
#

Inside the invoice_settings.default_payment_method on the Customer object

high ferry
#

Gotcha! So updating that field should do the trick. You can update it to the ID of a different Payment Method if you prefer. I'm not sure offhand if you're able to unset that field, but if so you'd pass an empty string to it to do so.

neon pike
#

Yes, but I can't since it's through the billing portal, once the user return to my site, the payment is already flagged as default payment method on the customer

high ferry
#

Oh, you're asking how to avoid it being set as the default in the first place? or how to unset it after it's set to to be the default in the billing portal?

neon pike
#

Yes how to avoid it being set as the default in the first place, I only want to let the user add a payment method, without changing their billing settings

high ferry
#

Double checking the parameters supported when creating a portal configuration, it doesn't look like that is a supported option.

neon pike
#

Yep, I also looked, so there's no solution to avoid this?
Or another type than 'payment_method_update' to add a payment method?

high ferry
#

Correct, not that I'm seeing. If I recall correctly customers are presented with a checkbox when adding a payment method via the customer portal to choose whether or not it's their default, but I think that may only be shown if they already have a payment method.

neon pike
#

Indeed, in my case, I don't have the box to check in my billing portal, thank you for your help anyways πŸ™‚