Skip to content

Commit

Permalink
Add support for country-specific fixtures in trigger cmd (#1070)
Browse files Browse the repository at this point in the history
* add support for named fixtures in `trigger` cmd

Adds support for explicitly specifying which fixture file to use when
triggering an event with `stripe trigger`. Achieves this by adding a
`--fixture` flag to the executable, the value of which will be the name
of a fixture "variant" (_variant_ because it will still only use
fixtures that are explicitly allowed for the given event name)

* add a comment

* revert

* add new triggers

* reset generated code

* reset pkg/plugins

---------

Co-authored-by: Edd Morgan <[email protected]>
  • Loading branch information
edd-stripe and EddM authored May 15, 2023
1 parent c502ca2 commit c6cdfeb
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/fixtures/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ var Events = map[string]string{
"invoice.payment_succeeded": "triggers/invoice.payment_succeeded.json",
"invoice.updated": "triggers/invoice.updated.json",
"issuing_authorization.request": "triggers/issuing_authorization.request.json",
"issuing_authorization.request.eu": "triggers/issuing_authorization.request.eu.json",
"issuing_authorization.request.gb": "triggers/issuing_authorization.request.gb.json",
"issuing_card.created": "triggers/issuing_card.created.json",
"issuing_card.created.eu": "triggers/issuing_card.created.eu.json",
"issuing_card.created.gb": "triggers/issuing_card.created.gb.json",
"issuing_cardholder.created": "triggers/issuing_cardholder.created.json",
"issuing_cardholder.created.eu": "triggers/issuing_cardholder.created.eu.json",
"issuing_cardholder.created.gb": "triggers/issuing_cardholder.created.gb.json",
"payment_intent.amount_capturable_updated": "triggers/payment_intent.amount_capturable_updated.json",
"payment_intent.created": "triggers/payment_intent.created.json",
"payment_intent.payment_failed": "triggers/payment_intent.payment_failed.json",
Expand Down
57 changes: 57 additions & 0 deletions pkg/fixtures/triggers/issuing_authorization.request.eu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"_meta": {
"template_version": 0
},
"fixtures": [
{
"name": "cardholder",
"path": "/v1/issuing/cardholders",
"method": "post",
"params": {
"name": "My Cardholder",
"type": "individual",
"phone_number": "+34666777888",
"individual": {
"first_name": "My",
"last_name": "Cardholder",
"card_issuing": {
"user_terms_acceptance": {
"date": 1470266163,
"ip": "91.121.146.224"
}
}
},
"billing": {
"address": {
"line1": "P. de la Castellana 43",
"city": "Madrid",
"state": "Madrid",
"postal_code": "28046",
"country": "ES"
}
}
}
},
{
"name": "card",
"path": "/v1/issuing/cards",
"method": "post",
"params": {
"currency": "eur",
"type": "virtual",
"cardholder": "${cardholder:id}",
"status": "active"
}
},
{
"name": "authorization_request",
"path": "/v1/issuing/cards/${card:id}/test/authorizations",
"method": "post",
"params": {
"held_amount": 100,
"held_currency": "eur",
"authorization_method": "online"
}
}
]
}
57 changes: 57 additions & 0 deletions pkg/fixtures/triggers/issuing_authorization.request.gb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"_meta": {
"template_version": 0
},
"fixtures": [
{
"name": "cardholder",
"path": "/v1/issuing/cardholders",
"method": "post",
"params": {
"name": "My Cardholder",
"type": "individual",
"phone_number": "+447700900000",
"individual": {
"first_name": "My",
"last_name": "Cardholder",
"card_issuing": {
"user_terms_acceptance": {
"date": 1470266163,
"ip": "91.121.146.224"
}
}
},
"billing": {
"address": {
"line1": "211 Old Street",
"city": "London",
"state": "London",
"postal_code": "EC1V 9NR",
"country": "GB"
}
}
}
},
{
"name": "card",
"path": "/v1/issuing/cards",
"method": "post",
"params": {
"currency": "gbp",
"type": "virtual",
"cardholder": "${cardholder:id}",
"status": "active"
}
},
{
"name": "authorization_request",
"path": "/v1/issuing/cards/${card:id}/test/authorizations",
"method": "post",
"params": {
"held_amount": 100,
"held_currency": "gbp",
"authorization_method": "online"
}
}
]
}
46 changes: 46 additions & 0 deletions pkg/fixtures/triggers/issuing_card.created.eu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"_meta": {
"template_version": 0
},
"fixtures": [
{
"name": "cardholder",
"path": "/v1/issuing/cardholders",
"method": "post",
"params": {
"name": "My Cardholder",
"type": "individual",
"phone_number": "+34666777888",
"individual": {
"first_name": "My",
"last_name": "Cardholder",
"card_issuing": {
"user_terms_acceptance": {
"date": 1470266163,
"ip": "91.121.146.224"
}
}
},
"billing": {
"address": {
"line1": "P. de la Castellana 43",
"city": "Madrid",
"state": "Madrid",
"postal_code": "28046",
"country": "ES"
}
}
}
},
{
"name": "card",
"path": "/v1/issuing/cards",
"method": "post",
"params": {
"currency": "eur",
"type": "virtual",
"cardholder": "${cardholder:id}"
}
}
]
}
46 changes: 46 additions & 0 deletions pkg/fixtures/triggers/issuing_card.created.gb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"_meta": {
"template_version": 0
},
"fixtures": [
{
"name": "cardholder",
"path": "/v1/issuing/cardholders",
"method": "post",
"params": {
"name": "My Cardholder",
"type": "individual",
"phone_number": "+447700900000",
"individual": {
"first_name": "My",
"last_name": "Cardholder",
"card_issuing": {
"user_terms_acceptance": {
"date": 1470266163,
"ip": "91.121.146.224"
}
}
},
"billing": {
"address": {
"line1": "211 Old Street",
"city": "London",
"state": "London",
"postal_code": "EC1V 9NR",
"country": "GB"
}
}
}
},
{
"name": "card",
"path": "/v1/issuing/cards",
"method": "post",
"params": {
"currency": "gbp",
"type": "virtual",
"cardholder": "${cardholder:id}"
}
}
]
}
36 changes: 36 additions & 0 deletions pkg/fixtures/triggers/issuing_cardholder.created.eu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"_meta": {
"template_version": 0
},
"fixtures": [
{
"name": "cardholder",
"path": "/v1/issuing/cardholders",
"method": "post",
"params": {
"name": "My Cardholder",
"type": "individual",
"phone_number": "+34666777888",
"individual": {
"first_name": "My",
"last_name": "Cardholder",
"card_issuing": {
"user_terms_acceptance": {
"date": 1470266163,
"ip": "91.121.146.224"
}
}
},
"billing": {
"address": {
"line1": "P. de la Castellana 43",
"city": "Madrid",
"state": "Madrid",
"postal_code": "28046",
"country": "ES"
}
}
}
}
]
}
36 changes: 36 additions & 0 deletions pkg/fixtures/triggers/issuing_cardholder.created.gb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"_meta": {
"template_version": 0
},
"fixtures": [
{
"name": "cardholder",
"path": "/v1/issuing/cardholders",
"method": "post",
"params": {
"name": "My Cardholder",
"type": "individual",
"phone_number": "+447700900000",
"individual": {
"first_name": "My",
"last_name": "Cardholder",
"card_issuing": {
"user_terms_acceptance": {
"date": 1470266163,
"ip": "91.121.146.224"
}
}
},
"billing": {
"address": {
"line1": "211 Old Street",
"city": "London",
"state": "London",
"postal_code": "EC1V 9NR",
"country": "GB"
}
}
}
}
]
}

0 comments on commit c6cdfeb

Please sign in to comment.