#mattvb91_code

1 messages ยท Page 1 of 1 (latest)

knotty kestrelBOT
#

๐Ÿ‘‹ 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/1275071990658629632

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

quaint marten
#

I need to check wether or not the user has checked the checkbox for future purchases so I can reuse the payment method for a yearly subscription (billed every 12 months) so i need to disable the confirmPayment button until it is checked

pulsar umbra
#

hi there!

#

so you want to make sure the users is saving their card?

quaint marten
#

I want to do both, allow the user to save their card but also I need a checkbox to allow to charge the card at a later time and im struggling with where that part should be implemented

        $intent = $stripeClient->paymentIntents->create(
            [
                'customer'                  => $customerId,
                'amount'                    => $totalAmount,
                'currency'                  => 'eur',
                'metadata'                  => $meta,
                'automatic_payment_methods' => [
                    'enabled' => true,
                ],
            ]
        );

        $customer_session = $stripeClient->customerSessions->create([
            'customer'   => $customerId,
            'components' => [
                'payment_element' => [
                    'enabled'  => true,
                    'features' => [
                        'payment_method_redisplay'  => 'enabled',
                        'payment_method_save'       => 'enabled',
                        'payment_method_save_usage' => 'off_session',
                        'payment_method_remove'     => 'enabled',
                    ],
                ],
            ],
        ]);
#

so i guess is it possible to set off_session when the client confirmsPayment on the client side if another checkbox has been checked?

pulsar umbra
#

I want to do both, allow the user to save their card but also I need a checkbox to allow to charge the card at a later time
can you clarify exactly what you want to do? I'm not sure I follow.

quaint marten
#

No problem. I want to give the user to option to save the card so they can see it again in the checkout at a later stage. As far as im aware thats the payment_method_redisplay and payment_method_save. I am also offering a yearly subscription model and need the user to confirm that the card can be charged at a later time off_session.

According to the docs you need to get confirmation of the user to opt in to having it used in future. But the paymentIntent needs to be created first to show the payment options to the user so at that point I dont know wether they have opted in or not.

shrewd loom
#

Hi there ๐Ÿ‘‹ looking at your initial post, it sounds like you want to disable the submit button when your customers don't choose to save their payment method, so it seems like you don't want to give them a choice and instead always save the card. Is that correct?

quaint marten
#

if that is the same as getting consent for off session charges then yes!

shrewd loom
#

You'll want to double check with your legal advisor about what exactly constitutes getting consent for where you're doing business, that's not advice I'm permitted or able to give.

But if that's the case, then you can set setup_future_usage to off_session on your Payment Intent. By default, when you set setup_future_usage, the Payment Element will display verbiage indicating the card information can be reused later.
https://docs.stripe.com/api/payment_intents/create#create_payment_intent-setup_future_usage