Search code examples
stripe-payments

How to trigger a test checkout.session.completed eventin stripe cli with amount_total specified?


Example with additional params works below

stripe trigger checkout.session.completed --add checkout_session:client_reference_id=0b044395-9265-4dff-8f7e-3a53839e76d8 --add checkout_session:metadata.orgId=ee1ab35e-2ec5-46ff-9d95-e8fc71ae44ff

But it errors with invalid request error code: parameter_unknown for amount_total :(

stripe trigger checkout.session.completed --add checkout_session:client_reference_id=0b044395-9265-4dff-8f7e-3a53839e76d8 --add checkout_session:metadata.orgId=ee1ab35e-2ec5-46ff-9d95-e8fc71ae44ff --add checkout_session:amount_total=450

Solution

  • The issue is that you're trying to pass an attribute that can't be included in a Checkout Session creation request. The attribute amount_total is added to the Checkout Session automatically by Stripe after creation, so only Stripe can update its value.

    If you want to pass a specific amount when you trigger a checkout.session.completed Event, then you'll want to pass one or more line_items to represent a mock of what a customer would actually be paying for.

    To do this, use the --add flag to include a Price object ID to line_items.price (see API ref here)