#bibek_api

1 messages · Page 1 of 1 (latest)

supple mossBOT
#

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

hoary notchBOT
fresh tartan
#

Hi! Are you integrating with Stripe Checkout or Payment Element?

safe niche
#

Stripe checkout

fresh tartan
#

So it is Checkout Session?

safe niche
#

yes

fresh tartan
safe niche
#

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.

fresh tartan
#

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)?

safe niche
#

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

supple mossBOT
remote bolt
#

👋 taking over and gimme some times to catchup + test this out

half relic
#

Hello

safe niche
#

Hello

#

shoud i add anything in the checkout ?

remote bolt
#

Can you provide the Checkout Id when it worked for payment mode too?

#

It is ultimately depends on how you saved the PM previously

safe niche
#

for mode='subscription' we need to add same saved_payment_method_options={"payment_method_save": "enabled"}

remote bolt
#

Yes

safe niche
#

now it shows Save payment methods for future payments in every checkouts but not showing to choose that payment method in future payments

remote bolt
#

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

safe niche
#

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

remote bolt
#

What does allow_display look like?

#

On the saved payment method

safe niche
#

just show like this in next checkout

remote bolt
#

Yes can you look at the allow_display of the payment method like the Doc recommends?

safe niche
#

you mean allow_redisplay

remote bolt
#

Ah yes, sorry

safe niche
#

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?

remote bolt
#

If you don't specify what value did it become? limited?

safe niche
#

i don't get it, how should i add allow_redisplay

remote bolt
safe niche
#

where do i have to look for this? in stripe dashboard?

remote bolt
#

In a payment_intent.succeeded event, call Retrieve PaymentMethod API

safe niche
#

allow_redisplay is in always in the payment method

remote bolt
#

Can you provide the payment method id? pm_xxx

safe niche
#

yah, it's pm_1QCwgfCACL6AzfJtD0gCe5at

remote bolt
#

Okie and can you create a brand new Checkout Session with that Customer cus_R55vVQJzMUvYAe and share the link here?

safe niche
#

here is the link https://checkout.stripe.com/c/pay/cs_test_a11Fo1scty69LbOKMwQkmaDr3NtzqhS53gPGc378ImaANxhqmq7BEmJolu#fid2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc%2FY2RpdmApJ2R1bE5gfCc%2FJ3VuWnFgdnFaMDRVfERzYkZERkkzRH9jT3F1ZERvRl9WVzRJQ3BtXE8xcndnbzdqajJENlVOcn81bnVfdERQQ2pENEJxZlZJST1dRjxJU3ZWV0ZGPXdHNDBmaHRTVHV1SUQ1NXE2dFYyUmkyJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpscWBoJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl

remote bolt
#

If you remove

saved_payment_method_options: {
    payment_method_save: "enabled",
  },

this time, how is it?

safe niche
#

okey i will try by removing it.

#

this is how it looks now.

remote bolt
#

Hmm and if you just change the price to an one time payment price and mode = payment , it works?

safe niche
#

yes, for mode=payment it works.

remote bolt
#

That's weird. Mine is working. Looking closer

safe niche
#

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)

remote bolt
#

Nah I think code is ok. Maybe account related

#

Can you try a brand new customer, and save only 1 payment method into it, then create the next CheckoutSession and provide here?

#

Please use a completely new customer

safe niche
#

okey

#

yah, it works with the new customer.