mustwin-stripe-ruby-mock 1.8.4.10

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 (89) hide show
  1. data/.gitignore +5 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +5 -0
  4. data/ChangeLog.rdoc +4 -0
  5. data/Gemfile +7 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +264 -0
  8. data/Rakefile +28 -0
  9. data/bin/stripe-mock-server +19 -0
  10. data/lib/stripe_mock.rb +46 -0
  11. data/lib/stripe_mock/api/card_tokens.rb +22 -0
  12. data/lib/stripe_mock/api/client.rb +37 -0
  13. data/lib/stripe_mock/api/debug.rb +11 -0
  14. data/lib/stripe_mock/api/errors.rb +41 -0
  15. data/lib/stripe_mock/api/instance.rb +27 -0
  16. data/lib/stripe_mock/api/server.rb +24 -0
  17. data/lib/stripe_mock/api/strict.rb +11 -0
  18. data/lib/stripe_mock/api/webhooks.rb +64 -0
  19. data/lib/stripe_mock/client.rb +84 -0
  20. data/lib/stripe_mock/data.rb +317 -0
  21. data/lib/stripe_mock/error_queue.rb +23 -0
  22. data/lib/stripe_mock/errors/closed_client_connection_error.rb +9 -0
  23. data/lib/stripe_mock/errors/server_timeout_error.rb +12 -0
  24. data/lib/stripe_mock/errors/stripe_mock_error.rb +15 -0
  25. data/lib/stripe_mock/errors/uninitialized_instance_error.rb +9 -0
  26. data/lib/stripe_mock/errors/unstarted_state_error.rb +9 -0
  27. data/lib/stripe_mock/errors/unsupported_request_error.rb +4 -0
  28. data/lib/stripe_mock/instance.rb +108 -0
  29. data/lib/stripe_mock/request_handlers/charges.rb +33 -0
  30. data/lib/stripe_mock/request_handlers/customers.rb +107 -0
  31. data/lib/stripe_mock/request_handlers/invoice_items.rb +15 -0
  32. data/lib/stripe_mock/request_handlers/plans.rb +43 -0
  33. data/lib/stripe_mock/server.rb +58 -0
  34. data/lib/stripe_mock/util.rb +22 -0
  35. data/lib/stripe_mock/version.rb +4 -0
  36. data/lib/stripe_mock/webhook_fixtures/account.application.deauthorized.json +12 -0
  37. data/lib/stripe_mock/webhook_fixtures/account.updated.json +24 -0
  38. data/lib/stripe_mock/webhook_fixtures/charge.dispute.closed.json +21 -0
  39. data/lib/stripe_mock/webhook_fixtures/charge.dispute.created.json +21 -0
  40. data/lib/stripe_mock/webhook_fixtures/charge.dispute.updated.json +24 -0
  41. data/lib/stripe_mock/webhook_fixtures/charge.failed.json +57 -0
  42. data/lib/stripe_mock/webhook_fixtures/charge.refunded.json +57 -0
  43. data/lib/stripe_mock/webhook_fixtures/charge.succeeded.json +57 -0
  44. data/lib/stripe_mock/webhook_fixtures/coupon.created.json +22 -0
  45. data/lib/stripe_mock/webhook_fixtures/coupon.deleted.json +22 -0
  46. data/lib/stripe_mock/webhook_fixtures/customer.created.json +40 -0
  47. data/lib/stripe_mock/webhook_fixtures/customer.deleted.json +40 -0
  48. data/lib/stripe_mock/webhook_fixtures/customer.discount.created.json +28 -0
  49. data/lib/stripe_mock/webhook_fixtures/customer.discount.deleted.json +28 -0
  50. data/lib/stripe_mock/webhook_fixtures/customer.discount.updated.json +43 -0
  51. data/lib/stripe_mock/webhook_fixtures/customer.subscription.created.json +34 -0
  52. data/lib/stripe_mock/webhook_fixtures/customer.subscription.deleted.json +34 -0
  53. data/lib/stripe_mock/webhook_fixtures/customer.subscription.trial_will_end.json +34 -0
  54. data/lib/stripe_mock/webhook_fixtures/customer.subscription.updated.json +47 -0
  55. data/lib/stripe_mock/webhook_fixtures/customer.updated.json +43 -0
  56. data/lib/stripe_mock/webhook_fixtures/invoice.created.json +64 -0
  57. data/lib/stripe_mock/webhook_fixtures/invoice.payment_failed.json +64 -0
  58. data/lib/stripe_mock/webhook_fixtures/invoice.payment_succeeded.json +64 -0
  59. data/lib/stripe_mock/webhook_fixtures/invoice.updated.json +67 -0
  60. data/lib/stripe_mock/webhook_fixtures/invoiceitem.created.json +21 -0
  61. data/lib/stripe_mock/webhook_fixtures/invoiceitem.deleted.json +21 -0
  62. data/lib/stripe_mock/webhook_fixtures/invoiceitem.updated.json +24 -0
  63. data/lib/stripe_mock/webhook_fixtures/plan.created.json +20 -0
  64. data/lib/stripe_mock/webhook_fixtures/plan.deleted.json +20 -0
  65. data/lib/stripe_mock/webhook_fixtures/plan.updated.json +23 -0
  66. data/lib/stripe_mock/webhook_fixtures/transfer.created.json +23 -0
  67. data/lib/stripe_mock/webhook_fixtures/transfer.failed.json +23 -0
  68. data/lib/stripe_mock/webhook_fixtures/transfer.paid.json +23 -0
  69. data/lib/stripe_mock/webhook_fixtures/transfer.updated.json +26 -0
  70. data/lib/trollop.rb +782 -0
  71. data/spec/_dummy/webhooks/dummy.event.json +6 -0
  72. data/spec/fixtures/stripe_webhooks/account.updated.json +7 -0
  73. data/spec/fixtures/stripe_webhooks/custom.account.updated.json +5 -0
  74. data/spec/instance_spec.rb +49 -0
  75. data/spec/readme_spec.rb +72 -0
  76. data/spec/server_spec.rb +131 -0
  77. data/spec/shared_stripe_examples/card_token_examples.rb +28 -0
  78. data/spec/shared_stripe_examples/charge_examples.rb +123 -0
  79. data/spec/shared_stripe_examples/customer_examples.rb +218 -0
  80. data/spec/shared_stripe_examples/error_mock_examples.rb +152 -0
  81. data/spec/shared_stripe_examples/invoice_item_examples.rb +17 -0
  82. data/spec/shared_stripe_examples/plan_examples.rb +123 -0
  83. data/spec/spec_helper.rb +11 -0
  84. data/spec/stripe_mock_spec.rb +40 -0
  85. data/spec/support/stripe_examples.rb +18 -0
  86. data/spec/util_spec.rb +45 -0
  87. data/spec/webhook_spec.rb +77 -0
  88. data/stripe-ruby-mock.gemspec +27 -0
  89. metadata +253 -0
@@ -0,0 +1,28 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "coupon": {
6
+ "amount_off": null,
7
+ "currency": "usd",
8
+ "duration": "repeating",
9
+ "duration_in_months": 3,
10
+ "id": "25OFF_00000000000000",
11
+ "livemode": false,
12
+ "max_redemptions": null,
13
+ "object": "coupon",
14
+ "percent_off": 25,
15
+ "redeem_by": null,
16
+ "times_redeemed": 0
17
+ },
18
+ "customer": "cus_00000000000000",
19
+ "end": 1379450108,
20
+ "object": "discount",
21
+ "start": 1371501308
22
+ }
23
+ },
24
+ "id": "evt_00000000000000",
25
+ "livemode": false,
26
+ "object": "event",
27
+ "type": "customer.discount.created"
28
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "coupon": {
6
+ "amount_off": null,
7
+ "currency": "usd",
8
+ "duration": "repeating",
9
+ "duration_in_months": 3,
10
+ "id": "25OFF_00000000000000",
11
+ "livemode": false,
12
+ "max_redemptions": null,
13
+ "object": "coupon",
14
+ "percent_off": 25,
15
+ "redeem_by": null,
16
+ "times_redeemed": 0
17
+ },
18
+ "customer": "cus_00000000000000",
19
+ "end": 1379450113,
20
+ "object": "discount",
21
+ "start": 1371501313
22
+ }
23
+ },
24
+ "id": "evt_00000000000000",
25
+ "livemode": false,
26
+ "object": "event",
27
+ "type": "customer.discount.deleted"
28
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "coupon": {
6
+ "amount_off": null,
7
+ "currency": "usd",
8
+ "duration": "repeating",
9
+ "duration_in_months": 3,
10
+ "id": "25OFF_00000000000000",
11
+ "livemode": false,
12
+ "max_redemptions": null,
13
+ "object": "coupon",
14
+ "percent_off": 25,
15
+ "redeem_by": null,
16
+ "times_redeemed": 0
17
+ },
18
+ "customer": "cus_00000000000000",
19
+ "end": 1379450110,
20
+ "object": "discount",
21
+ "start": 1371501310
22
+ },
23
+ "previous_attributes": {
24
+ "coupon": {
25
+ "amount_off": null,
26
+ "currency": "usd",
27
+ "duration": "repeating",
28
+ "duration_in_months": 3,
29
+ "id": "OLD_COUPON_ID",
30
+ "livemode": false,
31
+ "max_redemptions": null,
32
+ "object": "coupon",
33
+ "percent_off": 25,
34
+ "redeem_by": null,
35
+ "times_redeemed": 0
36
+ }
37
+ }
38
+ },
39
+ "id": "evt_00000000000000",
40
+ "livemode": false,
41
+ "object": "event",
42
+ "type": "customer.discount.updated"
43
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "cancel_at_period_end": false,
6
+ "canceled_at": null,
7
+ "current_period_end": 1371760577,
8
+ "current_period_start": 1371501377,
9
+ "customer": "cus_00000000000000",
10
+ "ended_at": null,
11
+ "object": "subscription",
12
+ "plan": {
13
+ "amount": 1000,
14
+ "currency": "usd",
15
+ "id": "1_00000000000000",
16
+ "interval": "month",
17
+ "interval_count": 1,
18
+ "livemode": false,
19
+ "name": "Cool Plan",
20
+ "object": "plan",
21
+ "trial_period_days": 3
22
+ },
23
+ "quantity": 1,
24
+ "start": 1371501377,
25
+ "status": "trialing",
26
+ "trial_end": 1371760577,
27
+ "trial_start": 1371501377
28
+ }
29
+ },
30
+ "id": "evt_00000000000000",
31
+ "livemode": false,
32
+ "object": "event",
33
+ "type": "customer.subscription.created"
34
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "cancel_at_period_end": false,
6
+ "canceled_at": null,
7
+ "current_period_end": 1371760585,
8
+ "current_period_start": 1371501385,
9
+ "customer": "cus_00000000000000",
10
+ "ended_at": 1371420375,
11
+ "object": "subscription",
12
+ "plan": {
13
+ "amount": 1000,
14
+ "currency": "usd",
15
+ "id": "1_00000000000000",
16
+ "interval": "month",
17
+ "interval_count": 1,
18
+ "livemode": false,
19
+ "name": "Cool Plan",
20
+ "object": "plan",
21
+ "trial_period_days": 3
22
+ },
23
+ "quantity": 1,
24
+ "start": 1371501385,
25
+ "status": "canceled",
26
+ "trial_end": 1371760585,
27
+ "trial_start": 1371501385
28
+ }
29
+ },
30
+ "id": "evt_00000000000000",
31
+ "livemode": false,
32
+ "object": "event",
33
+ "type": "customer.subscription.deleted"
34
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "cancel_at_period_end": false,
6
+ "canceled_at": null,
7
+ "current_period_end": 1371760588,
8
+ "current_period_start": 1371501388,
9
+ "customer": "cus_00000000000000",
10
+ "ended_at": null,
11
+ "object": "subscription",
12
+ "plan": {
13
+ "amount": 1000,
14
+ "currency": "usd",
15
+ "id": "1_00000000000000",
16
+ "interval": "month",
17
+ "interval_count": 1,
18
+ "livemode": false,
19
+ "name": "Cool Plan",
20
+ "object": "plan",
21
+ "trial_period_days": 3
22
+ },
23
+ "quantity": 1,
24
+ "start": 1371501388,
25
+ "status": "trialing",
26
+ "trial_end": 1371679569,
27
+ "trial_start": 1371420369
28
+ }
29
+ },
30
+ "id": "evt_00000000000000",
31
+ "livemode": false,
32
+ "object": "event",
33
+ "type": "customer.subscription.trial_will_end"
34
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "cancel_at_period_end": false,
6
+ "canceled_at": null,
7
+ "current_period_end": 1371760581,
8
+ "current_period_start": 1371501381,
9
+ "customer": "cus_00000000000000",
10
+ "ended_at": null,
11
+ "object": "subscription",
12
+ "plan": {
13
+ "amount": 1000,
14
+ "currency": "usd",
15
+ "id": "1_00000000000000",
16
+ "interval": "month",
17
+ "interval_count": 1,
18
+ "livemode": false,
19
+ "name": "Cool Plan",
20
+ "object": "plan",
21
+ "trial_period_days": 3
22
+ },
23
+ "quantity": 1,
24
+ "start": 1371501381,
25
+ "status": "trialing",
26
+ "trial_end": 1371760581,
27
+ "trial_start": 1371501381
28
+ },
29
+ "previous_attributes": {
30
+ "plan": {
31
+ "amount": 1000,
32
+ "currency": "usd",
33
+ "id": "OLD_PLAN_ID",
34
+ "interval": "month",
35
+ "interval_count": 1,
36
+ "livemode": false,
37
+ "name": "Old plan",
38
+ "object": "plan",
39
+ "trial_period_days": 3
40
+ }
41
+ }
42
+ },
43
+ "id": "evt_00000000000000",
44
+ "livemode": false,
45
+ "object": "event",
46
+ "type": "customer.subscription.updated"
47
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "account_balance": 0,
6
+ "active_card": {
7
+ "address_city": null,
8
+ "address_country": null,
9
+ "address_line1": null,
10
+ "address_line1_check": null,
11
+ "address_line2": null,
12
+ "address_state": null,
13
+ "address_zip": null,
14
+ "address_zip_check": null,
15
+ "country": "US",
16
+ "cvc_check": "pass",
17
+ "exp_month": 12,
18
+ "exp_year": 2013,
19
+ "fingerprint": "wXWJT135mEK107G8",
20
+ "last4": "4242",
21
+ "name": "1231",
22
+ "object": "card",
23
+ "type": "Visa"
24
+ },
25
+ "created": 1359947599,
26
+ "delinquent": false,
27
+ "description": null,
28
+ "discount": null,
29
+ "email": "ajoe@mailinator.com",
30
+ "id": "cus_00000000000000",
31
+ "livemode": false,
32
+ "object": "customer",
33
+ "subscription": null
34
+ },
35
+ "previous_attributes": {
36
+ "description": "Old description"
37
+ }
38
+ },
39
+ "id": "evt_00000000000000",
40
+ "livemode": false,
41
+ "object": "event",
42
+ "type": "customer.updated"
43
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount_due": 0,
6
+ "attempt_count": 0,
7
+ "attempted": false,
8
+ "charge": null,
9
+ "closed": false,
10
+ "currency": "usd",
11
+ "customer": "cus_00000000000000",
12
+ "date": 1371501468,
13
+ "discount": null,
14
+ "ending_balance": null,
15
+ "id": "in_00000000000000",
16
+ "lines": {
17
+ "count": 1,
18
+ "data": [
19
+ {
20
+ "amount": 0,
21
+ "currency": "usd",
22
+ "description": null,
23
+ "id": "su_22Dpg5ktMdA0i6",
24
+ "livemode": true,
25
+ "object": "line_item",
26
+ "period": {
27
+ "end": 1371760668,
28
+ "start": 1371501468
29
+ },
30
+ "plan": {
31
+ "amount": 1000,
32
+ "currency": "usd",
33
+ "id": "1",
34
+ "interval": "month",
35
+ "interval_count": 1,
36
+ "livemode": false,
37
+ "name": "Cool Plan",
38
+ "object": "plan",
39
+ "trial_period_days": 3
40
+ },
41
+ "proration": false,
42
+ "quantity": 1,
43
+ "type": "subscription"
44
+ }
45
+ ],
46
+ "object": "list",
47
+ "url": "/v1/invoices/in_22DpL6reHupqSS/lines"
48
+ },
49
+ "livemode": false,
50
+ "next_payment_attempt": 1371505068,
51
+ "object": "invoice",
52
+ "paid": true,
53
+ "period_end": 1371501468,
54
+ "period_start": 1371501468,
55
+ "starting_balance": 0,
56
+ "subtotal": 0,
57
+ "total": 0
58
+ }
59
+ },
60
+ "id": "evt_00000000000000",
61
+ "livemode": false,
62
+ "object": "event",
63
+ "type": "invoice.created"
64
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount_due": 0,
6
+ "attempt_count": 0,
7
+ "attempted": true,
8
+ "charge": null,
9
+ "closed": false,
10
+ "currency": "usd",
11
+ "customer": "cus_00000000000000",
12
+ "date": 1371501515,
13
+ "discount": null,
14
+ "ending_balance": null,
15
+ "id": "in_00000000000000",
16
+ "lines": {
17
+ "count": 1,
18
+ "data": [
19
+ {
20
+ "amount": 0,
21
+ "currency": "usd",
22
+ "description": null,
23
+ "id": "su_22DqVThf1vOC0I",
24
+ "livemode": true,
25
+ "object": "line_item",
26
+ "period": {
27
+ "end": 1371760715,
28
+ "start": 1371501515
29
+ },
30
+ "plan": {
31
+ "amount": 1000,
32
+ "currency": "usd",
33
+ "id": "1",
34
+ "interval": "month",
35
+ "interval_count": 1,
36
+ "livemode": false,
37
+ "name": "Cool Plan",
38
+ "object": "plan",
39
+ "trial_period_days": 3
40
+ },
41
+ "proration": false,
42
+ "quantity": 1,
43
+ "type": "subscription"
44
+ }
45
+ ],
46
+ "object": "list",
47
+ "url": "/v1/invoices/in_22DqULONy3rpya/lines"
48
+ },
49
+ "livemode": false,
50
+ "next_payment_attempt": 1371505115,
51
+ "object": "invoice",
52
+ "paid": false,
53
+ "period_end": 1371501515,
54
+ "period_start": 1371501515,
55
+ "starting_balance": 0,
56
+ "subtotal": 0,
57
+ "total": 0
58
+ }
59
+ },
60
+ "id": "evt_00000000000000",
61
+ "livemode": false,
62
+ "object": "event",
63
+ "type": "invoice.payment_failed"
64
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount_due": 0,
6
+ "attempt_count": 0,
7
+ "attempted": true,
8
+ "charge": "_00000000000000",
9
+ "closed": true,
10
+ "currency": "usd",
11
+ "customer": "cus_00000000000000",
12
+ "date": 1371501511,
13
+ "discount": null,
14
+ "ending_balance": null,
15
+ "id": "in_00000000000000",
16
+ "lines": {
17
+ "count": 1,
18
+ "data": [
19
+ {
20
+ "amount": 0,
21
+ "currency": "usd",
22
+ "description": null,
23
+ "id": "su_22DqbnCBi7246V",
24
+ "livemode": true,
25
+ "object": "line_item",
26
+ "period": {
27
+ "end": 1371760711,
28
+ "start": 1371501511
29
+ },
30
+ "plan": {
31
+ "amount": 1000,
32
+ "currency": "usd",
33
+ "id": "1",
34
+ "interval": "month",
35
+ "interval_count": 1,
36
+ "livemode": false,
37
+ "name": "Cool Plan",
38
+ "object": "plan",
39
+ "trial_period_days": 3
40
+ },
41
+ "proration": false,
42
+ "quantity": 1,
43
+ "type": "subscription"
44
+ }
45
+ ],
46
+ "object": "list",
47
+ "url": "/v1/invoices/in_22DqkNc6rNrhQo/lines"
48
+ },
49
+ "livemode": false,
50
+ "next_payment_attempt": 1371505111,
51
+ "object": "invoice",
52
+ "paid": true,
53
+ "period_end": 1371501511,
54
+ "period_start": 1371501511,
55
+ "starting_balance": 0,
56
+ "subtotal": 0,
57
+ "total": 0
58
+ }
59
+ },
60
+ "id": "evt_00000000000000",
61
+ "livemode": false,
62
+ "object": "event",
63
+ "type": "invoice.payment_succeeded"
64
+ }