#RandomAccordian
1 messages · Page 1 of 1 (latest)
What fields are you looking to add/override?
The reason for cancellation
It's not really an array, the [] just indicate that it's a parameter
It literally says --add stringArray in the help when you type stripe trigger with no params.
But what's the syntax?
...for the values used with the --add and --override parameters?
stripe trigger payment_intent.canceled --override payment_intent:cancellation_reason=reason
It's clearer in the docs: https://stripe.com/docs/cli/trigger#trigger-override
Great, thanks! It would be cool if the cli displayed a link to the relevant docs too, they were hard to find as there are so many docs
Oh oh:
Running fixture for: payment_intent
Trigger failed: Request failed, status=400, body={
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: cancellation_reason",
"param": "cancellation_reason",
"type": "invalid_request_error"
}
}```
Yeah, wasn't sure if that would work. This is the fixture for that specific event trigger: https://github.com/stripe/stripe-cli/blob/master/pkg/fixtures/triggers/payment_intent.canceled.json
What's happening I guess is the CLI is attempting to pass cancellation_reason during the creation request
And in that case its an unknown param
okay, I could tell it to not create the pi
You can stub your own fixture file, which may help: https://stripe.com/docs/cli/fixtures
Are you suggesting I use a fixture to create the pi, then trigger a cancellation for that specific pi?
as opposed to triggering a cancellation but skipping the create pi step
You can just create a fixture file which does both creation and cancellation, and in the fixture file explicitly pass cancellation_reason param during the cancelation request
Then you can skip --override flag which will prevent the issue you just had
Yeah I don't think there's a way to say 'cancel this specific PI', it just uses the PI it created in the fixture
Oh I see, I would provide a fixture for creating the PI, but no fixture is needed for cancelling it 👍
No, your fixture would need both
Basically, copy this fixture: https://github.com/stripe/stripe-cli/blob/master/pkg/fixtures/triggers/payment_intent.canceled.json
And change the cancellation_reason param as you need
Interestingly payment_intent.canceled triggers sets that field anyway 🤔
Is that not what you need?
Like. if you just do stripe trigger payment_intent.canceled the cancellation_reason should be set on the related event
Aha this works! --override payment_intent.cancelled:cancellation_reason=requested_by_customer
I had --override payment_intent:cancellation_reason=requested_by_customer
before.
Thank you!!
Oh, that's interesting. Didn't know you could pass the event type as the resource param
🤔 Although I suspect that's not actually working and its just defaulting to the fixture which has cancellation_reason: 'requested_by_customer' already: https://github.com/stripe/stripe-cli/blob/master/pkg/fixtures/triggers/payment_intent.canceled.json#L21
Try a different value: --override payment_intent.cancelled:cancellation_reason=duplicate
Yeah --override payment_intent.cancelled:cancellation_reason that doesn't work like you expect
I tried:
stripe trigger payment_intent.canceled --override payment_intent.canceled:cancellation_reason=duplicate
The event payload:
{
"object": {
"id": "pi_3LpVxOLostC5RfZm136ILLMu",
"object": "payment_intent",
"amount": 2000,
"amount_capturable": 0,
"amount_details": {
"tip": {
}
},
"amount_received": 0,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": 1664970010,
"cancellation_reason": "requested_by_customer",
}
}
It's just defaulting to what's in the payment_intent.canceled fixture
Another option would be :
stripe payment_intents cancel pi_xxx -d "cancellation_reason=duplicate"
Which works (just tested)