#Aneeq Ul haq
1 messages ยท Page 1 of 1 (latest)
The python code: stripe.api_key = stripe_account_id.secret_api_key
line_items = [{
'price_data': {
'currency': str(r.bms_website_id.default_currency.name).lower(),
'unit_amount': int(r.lead_display_price * 100),
'product_data': {
'name': str(r.name) +", Email: "+ str(r.email) ,
},
},
'quantity': 1,
}]
countries = []
countries.append(r.bms_website_id.country_id.code)
checkout_session = stripe.checkout.Session.create(
metadata = {
'Lead Number': r.name,
'Customer Email': r.email,
'Customer Name': r.name
},
line_items=line_items,
mode='payment',
success_url=f'{domain}/payment_with_stripe/success?token={generate_order_token(r.id)}',
cancel_url=f'{domain}/payment_with_stripe/cancel?token={generate_order_token(r.id)}',
phone_number_collection={
'enabled': True
},
shipping_address_collection={"allowed_countries": countries} ,
shipping_options=[
{
"shipping_rate_data": {
"type": "fixed_amount",
"fixed_amount": {"amount": 0, "currency": str(r.bms_website_id.default_currency.name).lower()},
"display_name": "Shipping fee",
"delivery_estimate": {
"minimum": {"unit": "business_day", "value": 10},
"maximum": {"unit": "business_day", "value": 15},
},
},
},
],
)
decoded_url = urllib.parse.unquote(urllib.parse.unquote(checkout_session.url))
r.stripe_payment_url = decoded_url
Hi, let me help you with this.
The Checkout Session URL expire and you shouldn't send old links to the customers. The Checkout Session has to be generated and used immediately. If not, it means your integration is not correct.
Okay May I know when the session the is expire like after how much time?
If you ask this question it means the flow is not designed correctly, sorry.
Are you sending those URLs via email?
No, Just need the Information so we can tell to the customers like after this time the URL will be not worked In that case we will generate for them the new url.
We are sending in the Report I mean in the PDF file.
Hi there ๐ jumping in as my teammate needs to step away soon.
It doesn't look like your code is currently setting the expires_at parameter when creating the Checkout Sessions, so they'll be inheriting our default behavior of expiring after 24 hours:
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-expires_at
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
That's not a good user experience, @hidden charm. What I recommend doing is send them a URL to your own website, that will in turn generate a fresh Checkout Session every time, and then you won't need to worry about expiry.
No we cannot because our prices changing daily So we are generating for them only once.
Let me check in the above url if we can by pass the default session time
You can set it shorter than 24 hours, but you can't set it longer than that.
Oh it's means after 24 hr, We need to create the new checkout URL, Right?
Yes, the Checkout Session expires after 24 hours, at which point it can no longer be used.
Ok Thanks Team,