#hero_cli-override
1 messages ยท Page 1 of 1 (latest)
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.
- hero_cli-override, 22 hours ago, 13 messages
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1256001381446455297
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
@shut delta you can override the same way yes, see https://docs.stripe.com/stripe-cli/triggers
hero_cli-override
okay then maybe im a little bit lost which resouce and property i need to override for that. Can you help me with this one?
Sure, can you share an exact command you use so I can show you what to change?
stripe trigger checkout.session.completed \
--override checkout_session:customer=cus_xxx
That my current command
I now dont want to create a price and product each time i trigger that webhook and instead use my own price id
sounds good, give me a few minutes and I'll show you
Thanks ๐
Okay so when you use that trigger what we do is run a sequence of API requests that are defined in the following file https://github.com/stripe/stripe-cli/blob/7d26bb96aa0728777b0291f66f8d1ab4597570b6/pkg/fixtures/triggers/checkout.session.completed.json
What your command does is exactly that but you are overriding the Customer id in the checkout_session creation step. So basically you are forcing your parameter in this list of parameters https://github.com/stripe/stripe-cli/blob/7d26bb96aa0728777b0291f66f8d1ab4597570b6/pkg/fixtures/triggers/checkout.session.completed.json#L29
And so now what you want is also override the Price id that is inside line_items.
When I debug those what I do is use a fake Price id so that if the parameter I passed is used properly then I get an error because the Price id doesn't exist. That lets me try various approaches until one works.
Here's what you want stripe trigger checkout.session.completed --override checkout_session:"line_items[0][price]"=price_ABC
I just tried it out and it seems not to work. It still is creating price and product and using the new create price id
stripe trigger checkout.session.completed \
--override checkout_session:customer=cus_ABC \
--override checkout_session:"line_items[0][price]"=price_ABC
That my current command
can you try without customer just to confirm?
sure
Trigger failed: Request failed, status=400, body={
"error": {
"code": "checkout_amount_mismatch",
"message": "Your purchase session has changed. Please review the updated total and submit payment again.",
"param": "expected_amount",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_ABC",
"type": "invalid_request_error"
}
}
I overlocked an error when creating the trigger
That error also happends with just the line items override command
stripe trigger checkout.session.completed --override checkout_session:"line_items[0][price]"=price_ABC
Ah I got lucky I literally used a Price with the right amout
You need to also override this parameter to match your Price amount: https://github.com/stripe/stripe-cli/blob/7d26bb96aa0728777b0291f66f8d1ab4597570b6/pkg/fixtures/triggers/checkout.session.completed.json#L86
I got it, i will try
stripe trigger checkout.session.completed \
--override checkout_session:"line_items[0][price]"=price_ABC \
--override payment_page_confirm:expected_amount=425000
I still get that error even after overriding the expected_amount
The price amount is 4250,00 โฌ
Maybe my amount is wrong?
not sure sorry, would help to get real exact error, exact object ids, etc. at this point
my advice: stop using the CLI for this, you're going to get grey hair before you succeed with all the edge-cases. Use the API, create a Checkout Session and complete it in the browser
Okay, Thanks for your help. I will use your advice and create me a fast checkout creation process for testing
you can also make your own trigger so that you can pass the exact parameters you care about otherwise