-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Subscription: Test that creation with card 4000000000000341 works
This adds a small suite of tests related to the discussion at #232 (comment) It seems that Stripe works this way (I've tested it today), so let's make sure Localstripe does it too, by adding a non-regression test.
- Loading branch information
1 parent
c0f2e16
commit 8bd29d4
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1129,3 +1129,33 @@ refunded=$( | |
curl -sSfg -u $SK: $HOST/v1/payment_intents/$payment_intent \ | ||
| grep -oE '"amount_refunded": 1000,') | ||
[ -n "$refunded" ] | ||
|
||
# Create a customer with card 4000000000000341 (that fails upon payment) and | ||
# make sure creating the subscription doesn't fail (although it creates it with | ||
# status 'incomplete'). This how Stripe behaves, see | ||
# https://github.com/adrienverge/localstripe/pull/232#issuecomment-2400000513 | ||
cus=$(curl -sSfg -u $SK: $HOST/v1/customers \ | ||
-d [email protected] \ | ||
| grep -oE 'cus_\w+' | head -n 1) | ||
res=$(curl -sSfg -u $SK: -X POST $HOST/v1/setup_intents) | ||
seti=$(echo "$res" | grep '"id"' | grep -oE 'seti_\w+' | head -n 1) | ||
seti_secret=$(echo $res | grep -oE 'seti_\w+_secret_\w+' | head -n 1) | ||
res=$(curl -sSfg $HOST/v1/setup_intents/$seti/confirm \ | ||
-d key=pk_test_sldkjflaksdfj \ | ||
-d client_secret=$seti_secret \ | ||
-d payment_method_data[type]=card \ | ||
-d payment_method_data[card][number]=4000000000000341 \ | ||
-d payment_method_data[card][cvc]=242 \ | ||
-d payment_method_data[card][exp_month]=4 \ | ||
-d payment_method_data[card][exp_year]=2030 \ | ||
-d payment_method_data[billing_details][address][postal_code]=42424) | ||
pm=$(echo "$res" | grep '"payment_method"' | grep -oE 'pm_\w+' | head -n 1) | ||
curl -u $SK: $HOST/v1/payment_methods/$pm/attach -d customer=$cus | ||
curl -sSfg -u $SK: $HOST/v1/customers/$cus \ | ||
-d invoice_settings[default_payment_method]=$pm | ||
status=$( | ||
curl -sSfg -u $SK: $HOST/v1/subscriptions \ | ||
-d customer=$cus \ | ||
-d items[0][plan]=basique-annuel \ | ||
| grep -oE '"status": "incomplete"') | ||
[ -n "$status" ] |