#bibek_api
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/1298490721442992128
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- bibek_code, 15 hours ago, 12 messages
- bibek_code, 17 hours ago, 47 messages
- bibek_code, 1 day ago, 41 messages
- bibek_api, 1 day ago, 23 messages
Hi! Are you integrating with Stripe Checkout or Payment Element?
Stripe checkout
So it is Checkout Session?
yes
Are you following this Checkout Session (Hosted Payment page) for Subscription guide: https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=web&ui=stripe-hosted
If so, the payment method is automatically saved for future payments.
yes, its from hosted payment page.
but not showing default payment options in future paments.
This is the code:
checkout_session = stripe.checkout.Session.create( line_items=[ { 'price_data': { 'currency': price.currency.code_for_stripe, 'product_data': { 'name': price.price_name }, 'unit_amount': price.price }, 'quantity': 1 } ], # payment_method_types=[ # 'card', # ], mode='payment', success_url=external_url('payment.clinician_checkout_status', status='success'), cancel_url=external_url('payment.clinician_checkout_status', status='cancelled'), client_reference_id=json.dumps( {'user_id': current_user.id, 'user_type': 2, 'purchase_type': 'token', 'price_id': price.id, 'timestamp': int(time.time() * 1000), 'currency_type': price.currency.code, 'is_new_plan': True}), customer=clinician.stripe_customer_id ) i am using.
In subscription mode, the customer’s default payment method will be used if it’s a card, otherwise the most recently saved card will be used. In this case you need to ensure the customer has a saved payment method.
Can you provide the checkout session ID (cs_abc)?
I see your code has mode='payment'. In this case, I would recommend following this guide: https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=stripe-hosted#save-payment-methods-to-prefill-them-in-checkout
wow, works for one time purchases but for subsription it's not showing saved payment methods:
Here is the code for subscription:
checkout_session = stripe.checkout.Session.create( payment_method_types=[], line_items=[ { 'price_data': { 'currency': price.currency.code_for_stripe, 'product': current_app.config['STRIPE_PRODUCTS']['tier-product'], 'recurring': { 'interval': interval }, 'unit_amount': price.price }, 'quantity': 1, }, ], discounts=[ {'coupon': stripe_coupon_id} ], mode='subscription', subscription_data={ 'trial_period_days': 30, # Start with a 30-day trial 'metadata': { 'tier': price.tier, 'eyeonic_tier_price_id': price.id, 'currency_type': price.currency.code, 'is_new_plan': 'True', 'plan': plans[price.tier - 1] } }, success_url=external_url('payment.clinician_checkout_status', status='success'), cancel_url=external_url('payment.clinician_checkout_status', status='cancelled'), customer=clinician.stripe_customer_id, )
this is the checkout id cs_test_a1qOcNwXDvV60aHxmxu2smJ2sDXpXaieqomtTpn573VrtuKKGLAw4RsxZ5
👋 taking over and gimme some times to catchup + test this out
Hello
Can you provide the Checkout Id when it worked for payment mode too?
It is ultimately depends on how you saved the PM previously
Or this for more completed guide: https://support.stripe.com/questions/prefilling-saved-cards-in-checkout
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
for mode='subscription' we need to add same saved_payment_method_options={"payment_method_save": "enabled"}
Yes
now it shows Save payment methods for future payments in every checkouts but not showing to choose that payment method in future payments
That's the first time. After customer tick on there and you can confirm the saved PM allow_display, then next time it will be displayed
yah, i already have tick on there and purchase many times still not showing previous payment methods in next payment. This is one checkout id cs_test_a15NZf3j5ZYD6OJYsZREu8YJRM8PGz0ohqLhPN09wi6VCx8Te5PN6EK74X
just show like this in next checkout
Yes can you look at the allow_display of the payment method like the Doc recommends?
you mean allow_redisplay
Ah yes, sorry
should i add like this saved_payment_method_options={"payment_method_save": "enabled", "allow_redisplay": "always"},
but showing this error stripe._error.InvalidRequestError: Request req_DJpwFVTXwQjF1g: Received unknown parameter: saved_payment_method_options[allow_redisplay]. Did you mean allow_redisplay_filters?
If you don't specify what value did it become? limited?
i don't get it, how should i add allow_redisplay
Let's put the question simpler: after collecting the PaymentMethod first time, can you look at the Payment Method object's allow_redisplay properties and see what value it has? https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
where do i have to look for this? in stripe dashboard?
In a payment_intent.succeeded event, call Retrieve PaymentMethod API
allow_redisplay is in always in the payment method
Can you provide the payment method id? pm_xxx
yah, it's pm_1QCwgfCACL6AzfJtD0gCe5at
Okie and can you create a brand new Checkout Session with that Customer cus_R55vVQJzMUvYAe and share the link here?
here is the link https://checkout.stripe.com/c/pay/cs_test_a11Fo1scty69LbOKMwQkmaDr3NtzqhS53gPGc378ImaANxhqmq7BEmJolu#fid2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc%2FY2RpdmApJ2R1bE5gfCc%2FJ3VuWnFgdnFaMDRVfERzYkZERkkzRH9jT3F1ZERvRl9WVzRJQ3BtXE8xcndnbzdqajJENlVOcn81bnVfdERQQ2pENEJxZlZJST1dRjxJU3ZWV0ZGPXdHNDBmaHRTVHV1SUQ1NXE2dFYyUmkyJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpscWBoJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl
If you remove
saved_payment_method_options: {
payment_method_save: "enabled",
},
this time, how is it?
Hmm and if you just change the price to an one time payment price and mode = payment , it works?
yes, for mode=payment it works.
That's weird. Mine is working. Looking closer
yah, sure
is there any thing missing in my code ?
code:
checkout_session = stripe.checkout.Session.create( line_items=[ { 'price_data': { 'currency': price.currency.code_for_stripe, 'product': current_app.config['STRIPE_PRODUCTS']['tier-product'], 'recurring': { 'interval': interval }, 'unit_amount': price.price }, 'quantity': 1, }, ], discounts=[ {'coupon': stripe_coupon_id} ], mode='subscription', subscription_data={ 'metadata': { 'tier': price.tier, 'eyeonic_tier_price_id': price.id, 'currency_type': price.currency.code, 'is_new_plan': True, 'plan': plan } }, success_url=external_url('payment.clinician_checkout_status', status='success'), cancel_url=external_url('payment.clinician_checkout_status', status='cancelled'), # saved_payment_method_options={"payment_method_save": "enabled"}, client_reference_id=json.dumps( {'user_id': current_user.id, 'user_type': 2, 'purchase_type': 'tier', 'price_id': price.id, 'tier': price.tier, 'timestamp': int(time.time() * 1000), 'currency_type': price.currency.code, 'is_new_plan': True}), customer=clinician.stripe_customer_id, ) return redirect(checkout_session.url, code=303)