stripe-ruby-mock 2.5.6 → 3.1.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -1
  3. data/.travis.yml +6 -9
  4. data/CHANGELOG.md +35 -0
  5. data/Gemfile +1 -0
  6. data/README.md +17 -11
  7. data/lib/stripe_mock.rb +11 -0
  8. data/lib/stripe_mock/api/client.rb +1 -1
  9. data/lib/stripe_mock/api/errors.rb +34 -28
  10. data/lib/stripe_mock/api/instance.rb +1 -1
  11. data/lib/stripe_mock/api/webhooks.rb +7 -0
  12. data/lib/stripe_mock/client.rb +2 -1
  13. data/lib/stripe_mock/data.rb +323 -13
  14. data/lib/stripe_mock/data/list.rb +42 -9
  15. data/lib/stripe_mock/instance.rb +52 -5
  16. data/lib/stripe_mock/request_handlers/account_links.rb +15 -0
  17. data/lib/stripe_mock/request_handlers/balance_transactions.rb +2 -2
  18. data/lib/stripe_mock/request_handlers/charges.rb +13 -12
  19. data/lib/stripe_mock/request_handlers/checkout.rb +15 -0
  20. data/lib/stripe_mock/request_handlers/checkout_session.rb +16 -0
  21. data/lib/stripe_mock/request_handlers/customers.rb +35 -18
  22. data/lib/stripe_mock/request_handlers/ephemeral_key.rb +1 -1
  23. data/lib/stripe_mock/request_handlers/express_login_links.rb +15 -0
  24. data/lib/stripe_mock/request_handlers/helpers/coupon_helpers.rb +14 -10
  25. data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +22 -7
  26. data/lib/stripe_mock/request_handlers/helpers/token_helpers.rb +1 -1
  27. data/lib/stripe_mock/request_handlers/invoices.rb +11 -5
  28. data/lib/stripe_mock/request_handlers/payment_intents.rb +182 -0
  29. data/lib/stripe_mock/request_handlers/payment_methods.rb +120 -0
  30. data/lib/stripe_mock/request_handlers/plans.rb +1 -1
  31. data/lib/stripe_mock/request_handlers/prices.rb +44 -0
  32. data/lib/stripe_mock/request_handlers/products.rb +44 -0
  33. data/lib/stripe_mock/request_handlers/refunds.rb +6 -3
  34. data/lib/stripe_mock/request_handlers/setup_intents.rb +93 -0
  35. data/lib/stripe_mock/request_handlers/sources.rb +12 -6
  36. data/lib/stripe_mock/request_handlers/subscription_items.rb +36 -0
  37. data/lib/stripe_mock/request_handlers/subscriptions.rb +82 -41
  38. data/lib/stripe_mock/request_handlers/tax_rates.rb +36 -0
  39. data/lib/stripe_mock/request_handlers/tokens.rb +8 -6
  40. data/lib/stripe_mock/request_handlers/validators/param_validators.rb +130 -9
  41. data/lib/stripe_mock/test_strategies/base.rb +68 -8
  42. data/lib/stripe_mock/test_strategies/live.rb +23 -12
  43. data/lib/stripe_mock/test_strategies/mock.rb +6 -2
  44. data/lib/stripe_mock/version.rb +1 -1
  45. data/lib/stripe_mock/webhook_fixtures/balance.available.json +6 -0
  46. data/lib/stripe_mock/webhook_fixtures/charge.dispute.funds_reinstated.json +88 -0
  47. data/lib/stripe_mock/webhook_fixtures/charge.dispute.funds_withdrawn.json +88 -0
  48. data/lib/stripe_mock/webhook_fixtures/charge.failed.json +166 -38
  49. data/lib/stripe_mock/webhook_fixtures/customer.created.json +1 -0
  50. data/lib/stripe_mock/webhook_fixtures/customer.updated.json +1 -0
  51. data/lib/stripe_mock/webhook_fixtures/invoice.created.json +2 -1
  52. data/lib/stripe_mock/webhook_fixtures/invoice.payment_succeeded.json +1 -1
  53. data/lib/stripe_mock/webhook_fixtures/invoice.updated.json +2 -1
  54. data/lib/stripe_mock/webhook_fixtures/payment_intent.payment_failed.json +186 -0
  55. data/lib/stripe_mock/webhook_fixtures/payment_intent.succeeded.json +164 -0
  56. data/lib/stripe_mock/webhook_fixtures/product.created.json +34 -0
  57. data/lib/stripe_mock/webhook_fixtures/product.deleted.json +34 -0
  58. data/lib/stripe_mock/webhook_fixtures/product.updated.json +38 -0
  59. data/spec/instance_spec.rb +10 -12
  60. data/spec/list_spec.rb +38 -0
  61. data/spec/server_spec.rb +6 -3
  62. data/spec/shared_stripe_examples/account_examples.rb +1 -1
  63. data/spec/shared_stripe_examples/account_link_examples.rb +16 -0
  64. data/spec/shared_stripe_examples/balance_examples.rb +6 -0
  65. data/spec/shared_stripe_examples/balance_transaction_examples.rb +3 -3
  66. data/spec/shared_stripe_examples/bank_examples.rb +3 -3
  67. data/spec/shared_stripe_examples/card_examples.rb +4 -4
  68. data/spec/shared_stripe_examples/card_token_examples.rb +17 -21
  69. data/spec/shared_stripe_examples/charge_examples.rb +32 -36
  70. data/spec/shared_stripe_examples/checkout_examples.rb +38 -0
  71. data/spec/shared_stripe_examples/coupon_examples.rb +1 -1
  72. data/spec/shared_stripe_examples/customer_examples.rb +103 -53
  73. data/spec/shared_stripe_examples/dispute_examples.rb +2 -2
  74. data/spec/shared_stripe_examples/error_mock_examples.rb +8 -7
  75. data/spec/shared_stripe_examples/express_login_link_examples.rb +12 -0
  76. data/spec/shared_stripe_examples/external_account_examples.rb +3 -3
  77. data/spec/shared_stripe_examples/invoice_examples.rb +43 -41
  78. data/spec/shared_stripe_examples/invoice_item_examples.rb +1 -1
  79. data/spec/shared_stripe_examples/payment_intent_examples.rb +147 -0
  80. data/spec/shared_stripe_examples/payment_method_examples.rb +449 -0
  81. data/spec/shared_stripe_examples/payout_examples.rb +2 -2
  82. data/spec/shared_stripe_examples/plan_examples.rb +135 -77
  83. data/spec/shared_stripe_examples/price_examples.rb +183 -0
  84. data/spec/shared_stripe_examples/product_examples.rb +155 -0
  85. data/spec/shared_stripe_examples/refund_examples.rb +41 -31
  86. data/spec/shared_stripe_examples/setup_intent_examples.rb +68 -0
  87. data/spec/shared_stripe_examples/subscription_examples.rb +546 -295
  88. data/spec/shared_stripe_examples/subscription_items_examples.rb +76 -0
  89. data/spec/shared_stripe_examples/tax_rate_examples.rb +42 -0
  90. data/spec/shared_stripe_examples/transfer_examples.rb +9 -9
  91. data/spec/shared_stripe_examples/webhook_event_examples.rb +11 -11
  92. data/spec/spec_helper.rb +7 -4
  93. data/spec/stripe_mock_spec.rb +4 -4
  94. data/spec/support/shared_contexts/stripe_validator_spec.rb +8 -0
  95. data/spec/support/stripe_examples.rb +12 -2
  96. data/stripe-ruby-mock.gemspec +8 -3
  97. metadata +81 -32
@@ -0,0 +1,88 @@
1
+ {
2
+ "created": 1326853478,
3
+ "livemode": false,
4
+ "id": "evt_00000000000000",
5
+ "type": "charge.dispute.funds_reinstated",
6
+ "object": "event",
7
+ "request": null,
8
+ "pending_webhooks": 1,
9
+ "api_version": "2017-12-14",
10
+ "data": {
11
+ "object": {
12
+ "id": "dp_00000000000000",
13
+ "object": "dispute",
14
+ "amount": 25000,
15
+ "balance_transaction": "txn_00000000000000",
16
+ "balance_transactions": [
17
+ {
18
+ "id": "txn_1Bl3mMGWCopOTFn18p8iALq8",
19
+ "object": "balance_transaction",
20
+ "amount": -25000,
21
+ "available_on": 1516233600,
22
+ "created": 1516145022,
23
+ "currency": "usd",
24
+ "description": "Chargeback withdrawal for ch_1Bl3mKGWCopOTFn1LKoN557r",
25
+ "exchange_rate": null,
26
+ "fee": 1500,
27
+ "fee_details": [
28
+ {
29
+ "amount": 1500,
30
+ "application": null,
31
+ "currency": "usd",
32
+ "description": "Dispute fee",
33
+ "type": "stripe_fee"
34
+ }
35
+ ],
36
+ "net": -26500,
37
+ "source": "dp_1Bl3mMGWCopOTFn1jpVaJDrU",
38
+ "status": "pending",
39
+ "type": "adjustment"
40
+ }
41
+ ],
42
+ "charge": "ch_00000000000000",
43
+ "created": 1516145022,
44
+ "currency": "usd",
45
+ "evidence": {
46
+ "access_activity_log": null,
47
+ "billing_address": null,
48
+ "cancellation_policy": null,
49
+ "cancellation_policy_disclosure": null,
50
+ "cancellation_rebuttal": null,
51
+ "customer_communication": null,
52
+ "customer_email_address": "amitree.apu@gmail.com",
53
+ "customer_name": "amitree.apu@gmail.com",
54
+ "customer_purchase_ip": "157.131.133.10",
55
+ "customer_signature": null,
56
+ "duplicate_charge_documentation": null,
57
+ "duplicate_charge_explanation": null,
58
+ "duplicate_charge_id": null,
59
+ "product_description": null,
60
+ "receipt": null,
61
+ "refund_policy": null,
62
+ "refund_policy_disclosure": null,
63
+ "refund_refusal_explanation": null,
64
+ "service_date": null,
65
+ "service_documentation": null,
66
+ "shipping_address": null,
67
+ "shipping_carrier": null,
68
+ "shipping_date": null,
69
+ "shipping_documentation": null,
70
+ "shipping_tracking_number": null,
71
+ "uncategorized_file": null,
72
+ "uncategorized_text": null
73
+ },
74
+ "evidence_details": {
75
+ "due_by": 1517529599,
76
+ "has_evidence": false,
77
+ "past_due": false,
78
+ "submission_count": 0
79
+ },
80
+ "is_charge_refundable": false,
81
+ "livemode": false,
82
+ "metadata": {
83
+ },
84
+ "reason": "fraudulent",
85
+ "status": "needs_response"
86
+ }
87
+ }
88
+ }
@@ -0,0 +1,88 @@
1
+ {
2
+ "created": 1326853478,
3
+ "livemode": false,
4
+ "id": "evt_00000000000000",
5
+ "type": "charge.dispute.funds_withdrawn",
6
+ "object": "event",
7
+ "request": null,
8
+ "pending_webhooks": 1,
9
+ "api_version": "2017-12-14",
10
+ "data": {
11
+ "object": {
12
+ "id": "dp_00000000000000",
13
+ "object": "dispute",
14
+ "amount": 25000,
15
+ "balance_transaction": "txn_00000000000000",
16
+ "balance_transactions": [
17
+ {
18
+ "id": "txn_1Bl3mMGWCopOTFn18p8iALq8",
19
+ "object": "balance_transaction",
20
+ "amount": -25000,
21
+ "available_on": 1516233600,
22
+ "created": 1516145022,
23
+ "currency": "usd",
24
+ "description": "Chargeback withdrawal for ch_1Bl3mKGWCopOTFn1LKoN557r",
25
+ "exchange_rate": null,
26
+ "fee": 1500,
27
+ "fee_details": [
28
+ {
29
+ "amount": 1500,
30
+ "application": null,
31
+ "currency": "usd",
32
+ "description": "Dispute fee",
33
+ "type": "stripe_fee"
34
+ }
35
+ ],
36
+ "net": -26500,
37
+ "source": "dp_1Bl3mMGWCopOTFn1jpVaJDrU",
38
+ "status": "pending",
39
+ "type": "adjustment"
40
+ }
41
+ ],
42
+ "charge": "ch_00000000000000",
43
+ "created": 1516145022,
44
+ "currency": "usd",
45
+ "evidence": {
46
+ "access_activity_log": null,
47
+ "billing_address": null,
48
+ "cancellation_policy": null,
49
+ "cancellation_policy_disclosure": null,
50
+ "cancellation_rebuttal": null,
51
+ "customer_communication": null,
52
+ "customer_email_address": "amitree.apu@gmail.com",
53
+ "customer_name": "amitree.apu@gmail.com",
54
+ "customer_purchase_ip": "157.131.133.10",
55
+ "customer_signature": null,
56
+ "duplicate_charge_documentation": null,
57
+ "duplicate_charge_explanation": null,
58
+ "duplicate_charge_id": null,
59
+ "product_description": null,
60
+ "receipt": null,
61
+ "refund_policy": null,
62
+ "refund_policy_disclosure": null,
63
+ "refund_refusal_explanation": null,
64
+ "service_date": null,
65
+ "service_documentation": null,
66
+ "shipping_address": null,
67
+ "shipping_carrier": null,
68
+ "shipping_date": null,
69
+ "shipping_documentation": null,
70
+ "shipping_tracking_number": null,
71
+ "uncategorized_file": null,
72
+ "uncategorized_text": null
73
+ },
74
+ "evidence_details": {
75
+ "due_by": 1517529599,
76
+ "has_evidence": false,
77
+ "past_due": false,
78
+ "submission_count": 0
79
+ },
80
+ "is_charge_refundable": false,
81
+ "livemode": false,
82
+ "metadata": {
83
+ },
84
+ "reason": "fraudulent",
85
+ "status": "needs_response"
86
+ }
87
+ }
88
+ }
@@ -4,53 +4,181 @@
4
4
  "id": "evt_00000000000000",
5
5
  "type": "charge.failed",
6
6
  "object": "event",
7
+ "request": null,
8
+ "pending_webhooks": 1,
9
+ "api_version": "2018-02-28",
7
10
  "data": {
8
11
  "object": {
9
12
  "id": "ch_00000000000000",
10
13
  "object": "charge",
11
- "created": 1380933505,
14
+ "amount": 100,
15
+ "amount_refunded": 0,
16
+ "application": null,
17
+ "application_fee": null,
18
+ "application_fee_amount": null,
19
+ "balance_transaction": "txn_00000000000000",
20
+ "billing_details": {
21
+ "address": {
22
+ "city": null,
23
+ "country": null,
24
+ "line1": null,
25
+ "line2": null,
26
+ "postal_code": null,
27
+ "state": null
28
+ },
29
+ "email": null,
30
+ "name": "Jenny Rosen",
31
+ "phone": null
32
+ },
33
+ "captured": false,
34
+ "created": 1572389205,
35
+ "currency": "cad",
36
+ "customer": null,
37
+ "description": "My First Test Charge (created for API docs)",
38
+ "dispute": null,
39
+ "failure_code": null,
40
+ "failure_message": null,
41
+ "fraud_details": {},
42
+ "invoice": null,
12
43
  "livemode": false,
44
+ "metadata": {},
45
+ "on_behalf_of": null,
46
+ "order": null,
47
+ "outcome": null,
13
48
  "paid": false,
14
- "amount": 1000,
15
- "currency": "usd",
16
- "refunded": false,
17
- "source": {
18
- "id": "cc_00000000000000",
19
- "object": "card",
20
- "last4": "4242",
21
- "type": "Visa",
22
- "brand": "Visa",
23
- "funding": "credit",
24
- "exp_month": 12,
25
- "exp_year": 2013,
26
- "fingerprint": "wXWJT135mEK107G8",
27
- "customer": "cus_00000000000000",
28
- "country": "US",
29
- "name": "Actual Nothing",
30
- "address_line1": null,
31
- "address_line2": null,
32
- "address_city": null,
33
- "address_state": null,
34
- "address_zip": null,
35
- "address_country": null,
36
- "cvc_check": null,
37
- "address_line1_check": null,
38
- "address_zip_check": null
49
+ "payment_intent": null,
50
+ "payment_method": "card_00000000000000",
51
+ "payment_method_details": {
52
+ "card": {
53
+ "brand": "visa",
54
+ "checks": {
55
+ "address_line1_check": null,
56
+ "address_postal_code_check": null,
57
+ "cvc_check": null
58
+ },
59
+ "country": "US",
60
+ "exp_month": 8,
61
+ "exp_year": 2019,
62
+ "fingerprint": "C8aRpBae2T8GeJcn",
63
+ "funding": "credit",
64
+ "installments": null,
65
+ "last4": "4242",
66
+ "network": "visa",
67
+ "three_d_secure": null,
68
+ "wallet": null
69
+ },
70
+ "type": "card"
39
71
  },
40
- "captured": true,
72
+ "receipt_email": null,
73
+ "receipt_number": null,
74
+ "receipt_url": "https://pay.stripe.com/receipts/acct_1C0lZEHvOcc4e36o/ch_1FZ3SbHsssvOcc4e36o87NHFK7i/rcpt_G5DuglJFhskXjsEDnLzxF6ESuGQe0Qj",
75
+ "refunded": false,
41
76
  "refunds": {
42
-
77
+ "object": "list",
78
+ "data": [],
79
+ "has_more": false,
80
+ "url": "/v1/charges/ch_1FZ3SbHvOcc4e36o87NHFK7i/refunds"
43
81
  },
44
- "balance_transaction": "txn_00000000000000",
45
- "failure_message": null,
46
- "failure_code": null,
47
- "amount_refunded": 0,
48
- "customer": "cus_00000000000000",
49
- "invoice": "in_00000000000000",
50
- "description": null,
51
- "dispute": null,
52
- "metadata": {
82
+ "review": null,
83
+ "shipping": null,
84
+ "source_transfer": null,
85
+ "statement_descriptor": null,
86
+ "statement_descriptor_suffix": null,
87
+ "status": "failed",
88
+ "transfer_data": null,
89
+ "transfer_group": null
90
+ }
91
+ },
92
+ "webhook": {
93
+ "created": 1326853478,
94
+ "livemode": false,
95
+ "id": "evt_00000000000000",
96
+ "type": "charge.failed",
97
+ "object": "event",
98
+ "request": null,
99
+ "pending_webhooks": 1,
100
+ "api_version": "2018-02-28",
101
+ "data": {
102
+ "object": {
103
+ "id": "ch_00000000000000",
104
+ "object": "charge",
105
+ "amount": 100,
106
+ "amount_refunded": 0,
107
+ "application": null,
108
+ "application_fee": null,
109
+ "application_fee_amount": null,
110
+ "balance_transaction": "txn_00000000000000",
111
+ "billing_details": {
112
+ "address": {
113
+ "city": null,
114
+ "country": null,
115
+ "line1": null,
116
+ "line2": null,
117
+ "postal_code": null,
118
+ "state": null
119
+ },
120
+ "email": null,
121
+ "name": "Jenny Rosen",
122
+ "phone": null
123
+ },
124
+ "captured": false,
125
+ "created": 1572389205,
126
+ "currency": "cad",
127
+ "customer": null,
128
+ "description": "My First Test Charge (created for API docs)",
129
+ "dispute": null,
130
+ "failure_code": null,
131
+ "failure_message": null,
132
+ "fraud_details": {},
133
+ "invoice": null,
134
+ "livemode": false,
135
+ "metadata": {},
136
+ "on_behalf_of": null,
137
+ "order": null,
138
+ "outcome": null,
139
+ "paid": false,
140
+ "payment_intent": null,
141
+ "payment_method": "card_00000000000000",
142
+ "payment_method_details": {
143
+ "card": {
144
+ "brand": "visa",
145
+ "checks": {
146
+ "address_line1_check": null,
147
+ "address_postal_code_check": null,
148
+ "cvc_check": null
149
+ },
150
+ "country": "US",
151
+ "exp_month": 8,
152
+ "exp_year": 2019,
153
+ "fingerprint": "C8aRpBae2T8GeJcn",
154
+ "funding": "credit",
155
+ "installments": null,
156
+ "last4": "4242",
157
+ "network": "visa",
158
+ "three_d_secure": null,
159
+ "wallet": null
160
+ },
161
+ "type": "card"
162
+ },
163
+ "receipt_email": null,
164
+ "receipt_number": null,
165
+ "receipt_url": "https://pay.stripe.com/receipts/acct_1C0lZEHvOcc4e36o/ch_1FZ3SbHvOcc4sssse36o87NHFK7i/rcpt_G5DuglJFhskXjsEDnLzxF6ESuGQe0Qj",
166
+ "refunded": false,
167
+ "refunds": {
168
+ "object": "list",
169
+ "data": [],
170
+ "has_more": false,
171
+ "url": "/v1/charges/ch_1FZ3SbHvOccssssss4e36o87NHFK7i/refunds"
172
+ },
173
+ "review": null,
174
+ "shipping": null,
175
+ "source_transfer": null,
176
+ "statement_descriptor": null,
177
+ "statement_descriptor_suffix": null,
178
+ "status": "failed",
179
+ "transfer_data": null,
180
+ "transfer_group": null
53
181
  }
54
182
  }
55
183
  }
56
- }
184
+ }
@@ -15,6 +15,7 @@
15
15
  "delinquent": true,
16
16
  "metadata": {
17
17
  },
18
+ "preferred_locales": [],
18
19
  "subscription": null,
19
20
  "discount": null,
20
21
  "account_balance": 0,
@@ -15,6 +15,7 @@
15
15
  "delinquent": true,
16
16
  "metadata": {
17
17
  },
18
+ "preferred_locales": [],
18
19
  "subscription": null,
19
20
  "discount": null,
20
21
  "account_balance": 0,
@@ -3,10 +3,11 @@
3
3
  "livemode": false,
4
4
  "id": "evt_00000000000000",
5
5
  "type": "invoice.created",
6
+ "status": "paid",
6
7
  "object": "event",
7
8
  "data": {
8
9
  "object": {
9
- "date": 1380674206,
10
+ "created": 1380674206,
10
11
  "id": "in_00000000000000",
11
12
  "period_start": 1378082075,
12
13
  "period_end": 1380674075,
@@ -16,7 +16,7 @@
16
16
  "closed": true,
17
17
  "currency": "eur",
18
18
  "customer": "cus_00000000000000",
19
- "date": 1464084258,
19
+ "created": 1464084258,
20
20
  "description": null,
21
21
  "discount": null,
22
22
  "ending_balance": 0,
@@ -3,10 +3,11 @@
3
3
  "livemode": false,
4
4
  "id": "evt_00000000000000",
5
5
  "type": "invoice.updated",
6
+ "status": "paid",
6
7
  "object": "event",
7
8
  "data": {
8
9
  "object": {
9
- "date": 1380674206,
10
+ "created": 1380674206,
10
11
  "id": "in_00000000000000",
11
12
  "period_start": 1378082075,
12
13
  "period_end": 1380674075,