stripe-ruby-mock 2.5.6 → 3.1.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,186 @@
1
+ {
2
+ "id": "evt_00000000000000",
3
+ "object": "event",
4
+ "api_version": "2018-02-28",
5
+ "created": 1578401135,
6
+ "data": {
7
+ "object": {
8
+ "id": "pi_00000000000000",
9
+ "object": "payment_intent",
10
+ "allowed_source_types": ["card", "sepa_debit"],
11
+ "amount": 200,
12
+ "amount_capturable": 0,
13
+ "amount_received": 0,
14
+ "application": null,
15
+ "application_fee_amount": null,
16
+ "canceled_at": null,
17
+ "cancellation_reason": null,
18
+ "capture_method": "automatic",
19
+ "charges": {
20
+ "object": "list",
21
+ "data": [
22
+ {
23
+ "id": "py_00000000000000",
24
+ "object": "charge",
25
+ "amount": 200,
26
+ "amount_refunded": 0,
27
+ "application": null,
28
+ "application_fee": null,
29
+ "application_fee_amount": null,
30
+ "balance_transaction": null,
31
+ "billing_details": {
32
+ "address": {
33
+ "city": null,
34
+ "country": null,
35
+ "line1": null,
36
+ "line2": null,
37
+ "postal_code": null,
38
+ "state": null
39
+ },
40
+ "email": "john.doe@example.com",
41
+ "name": "John Doe",
42
+ "phone": null
43
+ },
44
+ "captured": true,
45
+ "created": 1578401129,
46
+ "currency": "eur",
47
+ "customer": "cus_00000000000000",
48
+ "description": null,
49
+ "destination": "acct_00000000000000",
50
+ "dispute": null,
51
+ "disputed": false,
52
+ "failure_code": null,
53
+ "failure_message": null,
54
+ "fraud_details": {},
55
+ "invoice": null,
56
+ "livemode": false,
57
+ "metadata": {},
58
+ "on_behalf_of": null,
59
+ "order": null,
60
+ "outcome": {
61
+ "network_status": "approved_by_network",
62
+ "reason": null,
63
+ "risk_level": "not_assessed",
64
+ "seller_message": "Payment complete.",
65
+ "type": "authorized"
66
+ },
67
+ "paid": false,
68
+ "payment_intent": "pi_00000000000000",
69
+ "payment_method": "pm_00000000000000",
70
+ "payment_method_details": {
71
+ "sepa_debit": {
72
+ "bank_code": "37040044",
73
+ "branch_code": null,
74
+ "country": "DE",
75
+ "fingerprint": "00000000000000",
76
+ "last4": "3001",
77
+ "mandate": "mandate_00000000000000"
78
+ },
79
+ "type": "sepa_debit"
80
+ },
81
+ "receipt_email": null,
82
+ "receipt_number": null,
83
+ "receipt_url": "https://pay.stripe.com/receipts/acct_00000000000000/py_00000000000000/rcpt_00000000000000",
84
+ "refunded": false,
85
+ "refunds": {
86
+ "object": "list",
87
+ "data": [],
88
+ "has_more": false,
89
+ "total_count": 0,
90
+ "url": "/v1/charges/py_00000000000000/refunds"
91
+ },
92
+ "review": null,
93
+ "shipping": null,
94
+ "source": null,
95
+ "source_transfer": null,
96
+ "statement_descriptor": "ACME Corp",
97
+ "statement_descriptor_suffix": null,
98
+ "status": "failed",
99
+ "transfer_data": {
100
+ "amount": null,
101
+ "destination": "acct_00000000000000"
102
+ },
103
+ "transfer_group": "group_pi_00000000000000"
104
+ }
105
+ ],
106
+ "has_more": false,
107
+ "total_count": 1,
108
+ "url": "/v1/charges?payment_intent=pi_00000000000000"
109
+ },
110
+ "client_secret": "pi_00000000000000",
111
+ "confirmation_method": "automatic",
112
+ "created": 1578401129,
113
+ "currency": "eur",
114
+ "customer": "cus_00000000000000",
115
+ "description": null,
116
+ "invoice": null,
117
+ "last_payment_error": {
118
+ "code": "payment_intent_payment_attempt_failed",
119
+ "doc_url": "https://stripe.com/docs/error-codes/payment-intent-payment-attempt-failed",
120
+ "message": "The payment failed.",
121
+ "payment_method": {
122
+ "id": "pm_00000000000000",
123
+ "object": "payment_method",
124
+ "billing_details": {
125
+ "address": {
126
+ "city": null,
127
+ "country": null,
128
+ "line1": null,
129
+ "line2": null,
130
+ "postal_code": null,
131
+ "state": null
132
+ },
133
+ "email": "john.doe@example.com",
134
+ "name": "John Doe",
135
+ "phone": null
136
+ },
137
+ "created": 1578400666,
138
+ "customer": "cus_00000000000000",
139
+ "livemode": false,
140
+ "metadata": {},
141
+ "sepa_debit": {
142
+ "bank_code": "37040044",
143
+ "branch_code": "",
144
+ "country": "DE",
145
+ "fingerprint": "00000000000000",
146
+ "last4": "3001"
147
+ },
148
+ "type": "sepa_debit"
149
+ },
150
+ "type": "invalid_request_error"
151
+ },
152
+ "livemode": false,
153
+ "metadata": {},
154
+ "next_action": null,
155
+ "next_source_action": null,
156
+ "on_behalf_of": null,
157
+ "payment_method": null,
158
+ "payment_method_options": {
159
+ "card": {
160
+ "installments": null,
161
+ "request_three_d_secure": "automatic"
162
+ }
163
+ },
164
+ "payment_method_types": ["card", "sepa_debit"],
165
+ "receipt_email": null,
166
+ "review": null,
167
+ "setup_future_usage": null,
168
+ "shipping": null,
169
+ "source": null,
170
+ "statement_descriptor": "ACME Corp",
171
+ "statement_descriptor_suffix": null,
172
+ "status": "requires_source",
173
+ "transfer_data": {
174
+ "destination": "acct_00000000000000"
175
+ },
176
+ "transfer_group": null
177
+ }
178
+ },
179
+ "livemode": false,
180
+ "pending_webhooks": 3,
181
+ "request": {
182
+ "id": null,
183
+ "idempotency_key": null
184
+ },
185
+ "type": "payment_intent.payment_failed"
186
+ }
@@ -0,0 +1,164 @@
1
+ {
2
+ "id": "evt_00000000000000",
3
+ "object": "event",
4
+ "api_version": "2018-02-28",
5
+ "created": 1578499109,
6
+ "data": {
7
+ "object": {
8
+ "id": "pi_00000000000000",
9
+ "object": "payment_intent",
10
+ "allowed_source_types": ["card", "sepa_debit"],
11
+ "amount": 900,
12
+ "amount_capturable": 0,
13
+ "amount_received": 900,
14
+ "application": null,
15
+ "application_fee_amount": null,
16
+ "canceled_at": null,
17
+ "cancellation_reason": null,
18
+ "capture_method": "automatic",
19
+ "charges": {
20
+ "object": "list",
21
+ "data": [
22
+ {
23
+ "id": "ch_00000000000000",
24
+ "object": "charge",
25
+ "amount": 900,
26
+ "amount_refunded": 0,
27
+ "application": null,
28
+ "application_fee": null,
29
+ "application_fee_amount": null,
30
+ "balance_transaction": "txn_00000000000000",
31
+ "billing_details": {
32
+ "address": {
33
+ "city": null,
34
+ "country": "DE",
35
+ "line1": null,
36
+ "line2": null,
37
+ "postal_code": null,
38
+ "state": null
39
+ },
40
+ "email": null,
41
+ "name": null,
42
+ "phone": null
43
+ },
44
+ "captured": true,
45
+ "created": 1578499109,
46
+ "currency": "eur",
47
+ "customer": "cus_00000000000000",
48
+ "description": null,
49
+ "destination": "acct_00000000000000",
50
+ "dispute": null,
51
+ "disputed": false,
52
+ "failure_code": null,
53
+ "failure_message": null,
54
+ "fraud_details": {},
55
+ "invoice": null,
56
+ "livemode": false,
57
+ "metadata": {},
58
+ "on_behalf_of": null,
59
+ "order": null,
60
+ "outcome": {
61
+ "network_status": "approved_by_network",
62
+ "reason": null,
63
+ "risk_level": "normal",
64
+ "risk_score": 40,
65
+ "seller_message": "Payment complete.",
66
+ "type": "authorized"
67
+ },
68
+ "paid": true,
69
+ "payment_intent": "pi_00000000000000",
70
+ "payment_method": "pm_00000000000000",
71
+ "payment_method_details": {
72
+ "card": {
73
+ "brand": "visa",
74
+ "checks": {
75
+ "address_line1_check": null,
76
+ "address_postal_code_check": null,
77
+ "cvc_check": null
78
+ },
79
+ "country": "US",
80
+ "exp_month": 4,
81
+ "exp_year": 2024,
82
+ "fingerprint": "00000000000000",
83
+ "funding": "credit",
84
+ "installments": null,
85
+ "last4": "4242",
86
+ "network": "visa",
87
+ "three_d_secure": null,
88
+ "wallet": null
89
+ },
90
+ "type": "card"
91
+ },
92
+ "receipt_email": null,
93
+ "receipt_number": null,
94
+ "receipt_url": "https://pay.stripe.com/receipts/acct_00000000000000/ch_00000000000000/rcpt_00000000000000",
95
+ "refunded": false,
96
+ "refunds": {
97
+ "object": "list",
98
+ "data": [],
99
+ "has_more": false,
100
+ "total_count": 0,
101
+ "url": "/v1/charges/ch_00000000000000/refunds"
102
+ },
103
+ "review": null,
104
+ "shipping": null,
105
+ "source": null,
106
+ "source_transfer": null,
107
+ "statement_descriptor": "ACME Corp",
108
+ "statement_descriptor_suffix": null,
109
+ "status": "succeeded",
110
+ "transfer": "tr_00000000000000",
111
+ "transfer_data": {
112
+ "amount": null,
113
+ "destination": "acct_00000000000000"
114
+ },
115
+ "transfer_group": "group_pi_00000000000000"
116
+ }
117
+ ],
118
+ "has_more": false,
119
+ "total_count": 1,
120
+ "url": "/v1/charges?payment_intent=pi_00000000000000"
121
+ },
122
+ "client_secret": "pi_00000000000000",
123
+ "confirmation_method": "automatic",
124
+ "created": 1578499108,
125
+ "currency": "eur",
126
+ "customer": "cus_00000000000000",
127
+ "description": null,
128
+ "invoice": null,
129
+ "last_payment_error": null,
130
+ "livemode": false,
131
+ "metadata": {},
132
+ "next_action": null,
133
+ "next_source_action": null,
134
+ "on_behalf_of": null,
135
+ "payment_method": "pm_00000000000000",
136
+ "payment_method_options": {
137
+ "card": {
138
+ "installments": null,
139
+ "request_three_d_secure": "automatic"
140
+ }
141
+ },
142
+ "payment_method_types": ["card", "sepa_debit"],
143
+ "receipt_email": null,
144
+ "review": null,
145
+ "setup_future_usage": null,
146
+ "shipping": null,
147
+ "source": null,
148
+ "statement_descriptor": "ACME Corp",
149
+ "statement_descriptor_suffix": null,
150
+ "status": "succeeded",
151
+ "transfer_data": {
152
+ "destination": "acct_00000000000000"
153
+ },
154
+ "transfer_group": "group_pi_00000000000000"
155
+ }
156
+ },
157
+ "livemode": false,
158
+ "pending_webhooks": 2,
159
+ "request": {
160
+ "id": "req_00000000000000",
161
+ "idempotency_key": null
162
+ },
163
+ "type": "payment_intent.succeeded"
164
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "created": 1326853478,
3
+ "livemode": false,
4
+ "id": "evt_00000000000000",
5
+ "type": "product.created",
6
+ "object": "event",
7
+ "data": {
8
+ "object": {
9
+ "id": "prod_00000000000000",
10
+ "object": "product",
11
+ "active": true,
12
+ "attributes": [
13
+ ],
14
+ "caption": null,
15
+ "created": 1558795883,
16
+ "deactivate_on": [
17
+ ],
18
+ "description": null,
19
+ "images": [
20
+ ],
21
+ "livemode": false,
22
+ "metadata": {
23
+ },
24
+ "name": "Test Product",
25
+ "package_dimensions": null,
26
+ "shippable": null,
27
+ "statement_descriptor": null,
28
+ "type": "service",
29
+ "unit_label": null,
30
+ "updated": 1558795883,
31
+ "url": null
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "created": 1326853478,
3
+ "livemode": false,
4
+ "id": "evt_00000000000000",
5
+ "type": "product.deleted",
6
+ "object": "event",
7
+ "data": {
8
+ "object": {
9
+ "id": "prod_00000000000000",
10
+ "object": "product",
11
+ "active": true,
12
+ "attributes": [
13
+ ],
14
+ "caption": null,
15
+ "created": 1558795883,
16
+ "deactivate_on": [
17
+ ],
18
+ "description": null,
19
+ "images": [
20
+ ],
21
+ "livemode": false,
22
+ "metadata": {
23
+ },
24
+ "name": "Test Product",
25
+ "package_dimensions": null,
26
+ "shippable": null,
27
+ "statement_descriptor": null,
28
+ "type": "service",
29
+ "unit_label": null,
30
+ "updated": 1558795883,
31
+ "url": null
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "created": 1326853478,
3
+ "livemode": false,
4
+ "id": "evt_00000000000000",
5
+ "type": "product.updated",
6
+ "object": "event",
7
+ "data": {
8
+ "object": {
9
+ "id": "prod_00000000000000",
10
+ "object": "product",
11
+ "active": true,
12
+ "attributes": [
13
+ ],
14
+ "caption": null,
15
+ "created": 1558795883,
16
+ "deactivate_on": [
17
+ ],
18
+ "description": null,
19
+ "images": [
20
+ ],
21
+ "livemode": false,
22
+ "metadata": {
23
+ },
24
+ "name": "Test Product",
25
+ "package_dimensions": null,
26
+ "shippable": null,
27
+ "statement_descriptor": null,
28
+ "type": "service",
29
+ "unit_label": null,
30
+ "updated": 1558795883,
31
+ "url": null
32
+ },
33
+ "previous_attributes": {
34
+ "name": "Product Test",
35
+ "updated": 1558873981
36
+ }
37
+ }
38
+ }