#david_best-practices

1 messages ยท Page 1 of 1 (latest)

urban pineBOT
#

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

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

little tokenBOT
vocal laurel
#

More context:
It seems like SetupIntent would be appropiate for this case, however it would imply 2 back and forth redirects between my app and Stripe. So, in ideal scenario I am looking for a good solution, where:

  1. A single Checkout Session is used (1 back and forth)
  2. User's payment method is validated (by the SetupIntent, a minimal charge with refund via webhook or etc.)
  3. Same session leads to Subscription creation for the specific product, with a free trial
#

Roughly speaking, here is what we do:

        success_url=domain_url + ...,
        cancel_url=domain_url + ...,
        payment_method_types=["card"],
        mode="subscription",
        line_items=[*my_products],
        metadata={...},
        subscription_data={...},
        allow_promotion_codes=True,
    )```

Afterwards, the `checkout.session.completed` webhook is monitored as of now
sharp token
#

Hi ๐Ÿ‘‹ sounds like you may be looking for the payment_method_collection parameter which allows you to force Subscription mode Checkout Sessions to collect payment method details even if the first Invoice doesn't require payment:
https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-payment_method_collection

vocal laurel
#

Oh, thanks for the promt response!

Actually, I had seen this page, but assumed it is the default behaviour.
Currently, the Checkout Session created by the above snipped indeed forces the input of a payment method (card), but it does not seem to validate it in any way.

sharp token
#

Can you elaborate on that last part? How are you testing the card validation/what are you expecting to see during that testing?

vocal laurel
#

To be honest, I might not have full context, due to a different person reporting this.

I would assume, Stripe Test cards were used, specifically to test an invalid card case.

However, to make the question more generic - Does payment_method_collection=always imply validation of the collectied method even with a free trial?

sharp token
#

I'd have to run through a test using a test card to be certain, but I believe it does validation. The server is very busy at the moment so running that test would take me some time, and I think you may be able to check that faster than I can currently.

vocal laurel
#

Sorry for the late response.

Sure, I'd love to try that out. Thank you for the help and spending your time, I appreciate it a lot!
I might chime in here in a bit, after checking out this option