#ryan_checkout-product
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/1278421827663696023
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Here is the relevent code:
def run_checkout(items_list, cart_id, YOUR_DOMAIN, quality, color, comments):
lineItems = []
for item in items_list:
item_id, item_price, item_quantity = item
lineItems.append({
'price_data': {
'currency': 'usd',
'product_data': {
'name': item_id,
},
'unit_amount': int(item_price * 100),
},
'quantity': item_quantity,
})
productionType = connector.get_cart_type(cart_id)
if productionType == "live":
stripe.api_key = os.getenv("STRIPE_LIVE_API_KEY")
shippingRateMode = connector.get_shipping_rate()
else:
stripe.api_key = os.getenv("STRIPE_SANDBOX_API_KEY")
shippingRateMode = "shr_1NwPs5DBmtvCmuyX0cKDOxMu"
checkout_session = stripe.checkout.Session.create(
allow_promotion_codes=True,
billing_address_collection="required",
automatic_tax={
"enabled": True,
},
shipping_address_collection={
"allowed_countries": ["US"],
},
line_items=lineItems,
shipping_options=[
{
"shipping_rate": shippingRateMode,
}
],
metadata={
"card_id": cart_id,
"quality": quality,
"color": color,
"prod_mode": productionType,
"comments": comments
},
mode="payment",
success_url=YOUR_DOMAIN + "api/checkout_success/{CHECKOUT_SESSION_ID}/",
cancel_url=YOUR_DOMAIN + "order",
)
return checkout_session
example archived products:
@rigid bison you should in that case be creating the Product and associated Price(s) upfront
ryan_checkout-product
ahhh okay cool