#some1-coupon-error
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- some1ataplace, 3 hours ago, 7 messages
- some1ataplace, 12 hours ago, 17 messages
- some1ataplace, 5 days ago, 26 messages
Sorry discord got busy suddenly but looking
no worries
Okay do you have a request id req_123 or the Coupon id co_123 for me to look at it?
req_KfI2HH60AfEaCl
some1-coupon-error
Hum that is not a PromotionCode creation request at all right? That is a request id for an API Request made by Checkout
yes which i thought that was strange too. But it originates from my webhook. Here is the coupons I am using: D1JjuzlM and hS1WFhyv
I'm sorry what does "it originates from my webhook" mean?
Can you please try and provide a lot more details?
if event.type == 'payment_intent.succeeded':
customer_id = event.data.object.customer
customer_email = event.data.object.receipt_email
payment_intent_id = event.data.object.id
checkout_session = stripe.checkout.Session.list(payment_intent=payment_intent_id,expand=["data.line_items",]).auto_paging_iter()
if product_description == 'Monthly Gift Card':
promotion_codes = []
for y in range(quantity):
promotion_code = stripe.PromotionCode.create(
coupon=settings.STRIPE_MONTHLY_COUPON_ID,
customer=None, #customer=customer_id,
active=True,
max_redemptions=1,
metadata={
'monthly_price_id': settings.STRIPE_MONTHLY_PRICE_ID,
'product_type': 'Monthly',
},
)
print(promotion_code.code)
checkout_session = stripe.checkout.Session.create(
success_url=request.build_absolute_uri(reverse('giftcards:stripe_success')) + '?session_id={CHECKOUT_SESSION_ID}',
cancel_url=request.build_absolute_uri(reverse('giftcards:stripe_cancelled')),
payment_method_options={
"us_bank_account": {
"financial_connections": {"permissions": ["payment_method", "balances", "ownership", "transactions"]},
},
},
customer=customer_id,
mode='payment',
line_items=[{
'price_data': {
'currency': 'usd',
'unit_amount': yearly_price_amount,
'product_data': {
'name': 'Yearly Gift Card',
},
},
'quantity':quantity,
}],
phone_number_collection={
'enabled': True,
},
)
And which request in that code is getting an error?
a successful checkout session. I want to create a promo code to give the user since they are buying it
my terminal says it fails here:
stripe_payment_intent_success_webhook
promotion_code = stripe.PromotionCode.create(
What error do you get from that call?
Can you send the request ID of one of those calls where you are getting this error?
see my first message in the thread, it is an unclear message
all it says is contact stripe in the terminal. I had to do digging in the dashboard to find any request id
That isn't the stripe error code though, looking for the message that our API sends back.
Do i look in developer logs or under webhooks?
i don't see one at all...
https://dashboard.stripe.com/test/logs/req_6sBgLXH8WssDn6 and https://dashboard.stripe.com/test/logs/req_w2jftnbYXwYIci is the only things i see
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
i just re-ran it again so those are the most recent
Can you give me the exact parameters that you are setting when making that call? The code looks like it is properly formatted at first glance. If you aren't seeing any calls to that endpoint, the call may be failing on your server before it even reaches out to Stripe
stripe.PromotionCode.create(
coupon=settings.STRIPE_MONTHLY_COUPON_ID,
#customer=None, #customer=customer_id,
active=True,
max_redemptions=1,
metadata={
'monthly_price_id': settings.STRIPE_MONTHLY_PRICE_ID,
'product_type': 'Monthly',
},
)
If you copy that API call out in to a different file, hardcode the coupon ID, and run it, do you still get the same error?
ok hold on
yes, it worked just fine:
import stripe
stripe.api_key = <KEY>
stripe.PromotionCode.create(
coupon="D1JjuzlM",
#customer=None, #customer=customer_id,
active=True,
max_redemptions=1,
metadata={
'yearly_price_id': "price_1HNYoqIeTJrsS1repAcV42H2",
'product_type': 'Yearly',
},
)
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Strange. Can you try hard-coding this in your original code?
If it starts working there, either your coupon ID or price ID variables may not be populated
Sure.
oh man my fault completely
i am setting it as base64 since i was lazy when copying and pasting from my other environment variable
thanks for the help.. that was the problem
Good find! Glad this helped you fix it