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,22 @@
1
+ module StripeMock
2
+ module Util
3
+
4
+ def self.rmerge(desh_hash, source_hash)
5
+ return source_hash if desh_hash.nil?
6
+ return nil if source_hash.nil?
7
+
8
+ desh_hash.merge(source_hash) do |key, oldval, newval|
9
+ if oldval.is_a?(Array) && newval.is_a?(Array)
10
+ oldval.zip(newval).map {|elems|
11
+ elems[1].nil? ? elems[0] : rmerge(elems[0], elems[1])
12
+ }
13
+ elsif oldval.is_a?(Hash) && newval.is_a?(Hash)
14
+ rmerge(oldval, newval)
15
+ else
16
+ newval
17
+ end
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ module StripeMock
2
+ # stripe-ruby-mock version
3
+ VERSION = "1.8.4.10"
4
+ end
@@ -0,0 +1,12 @@
1
+ {
2
+ "type": "account.application.deauthorized",
3
+ "object": "event",
4
+ "created": 1326853478,
5
+ "livemode": false,
6
+ "id": "evt_00000000000000",
7
+ "data": {
8
+ "object": {
9
+ "id": "cus_00000000000000"
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "charge_enabled": false,
6
+ "currencies_supported": [
7
+ "USD"
8
+ ],
9
+ "details_submitted": true,
10
+ "email": "test@stripe.com",
11
+ "id": "acct_00000000000000",
12
+ "object": "account",
13
+ "statement_descriptor": "TEST",
14
+ "transfer_enabled": false
15
+ },
16
+ "previous_attributes": {
17
+ "details_submitted": false
18
+ }
19
+ },
20
+ "id": "evt_00000000000000",
21
+ "livemode": false,
22
+ "object": "event",
23
+ "type": "account.updated"
24
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount": 1000,
6
+ "charge": "ch_00000000000000",
7
+ "created": 1371500754,
8
+ "currency": "usd",
9
+ "evidence": "Here is some evidence",
10
+ "evidence_due_by": 1373155199,
11
+ "livemode": false,
12
+ "object": "dispute",
13
+ "reason": "general",
14
+ "status": "won"
15
+ }
16
+ },
17
+ "id": "evt_00000000000000",
18
+ "livemode": false,
19
+ "object": "event",
20
+ "type": "charge.dispute.closed"
21
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount": 1000,
6
+ "charge": "ch_00000000000000",
7
+ "created": 1371500744,
8
+ "currency": "usd",
9
+ "evidence": null,
10
+ "evidence_due_by": 1373155199,
11
+ "livemode": false,
12
+ "object": "dispute",
13
+ "reason": "general",
14
+ "status": "needs_response"
15
+ }
16
+ },
17
+ "id": "evt_00000000000000",
18
+ "livemode": false,
19
+ "object": "event",
20
+ "type": "charge.dispute.created"
21
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount": 1000,
6
+ "charge": "ch_00000000000000",
7
+ "created": 1371500750,
8
+ "currency": "usd",
9
+ "evidence": "Here is some evidence",
10
+ "evidence_due_by": 1373155199,
11
+ "livemode": false,
12
+ "object": "dispute",
13
+ "reason": "general",
14
+ "status": "under_review"
15
+ },
16
+ "previous_attributes": {
17
+ "evidence": null
18
+ }
19
+ },
20
+ "id": "evt_00000000000000",
21
+ "livemode": false,
22
+ "object": "event",
23
+ "type": "charge.dispute.updated"
24
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount": 14500,
6
+ "amount_refunded": 0,
7
+ "captured": true,
8
+ "card": {
9
+ "address_city": null,
10
+ "address_country": null,
11
+ "address_line1": null,
12
+ "address_line1_check": null,
13
+ "address_line2": null,
14
+ "address_state": null,
15
+ "address_zip": null,
16
+ "address_zip_check": null,
17
+ "country": "US",
18
+ "cvc_check": null,
19
+ "exp_month": 2,
20
+ "exp_year": 2016,
21
+ "fingerprint": "wXWJT135mEK107G8",
22
+ "last4": "4242",
23
+ "name": "Johnny Appleseed",
24
+ "object": "card",
25
+ "type": "Visa"
26
+ },
27
+ "created": 1360179715,
28
+ "currency": "usd",
29
+ "customer": null,
30
+ "description": "Customer: Johnny Appleseed Email: japp@mailinator.com Product: A Box of Happiness ID: 36 Quantity: 3 ",
31
+ "dispute": null,
32
+ "failure_code": null,
33
+ "failure_message": null,
34
+ "fee": 451,
35
+ "fee_details": [
36
+ {
37
+ "amount": 451,
38
+ "amount_refunded": 0,
39
+ "application": null,
40
+ "currency": "usd",
41
+ "description": "Stripe processing fees",
42
+ "type": "stripe_fee"
43
+ }
44
+ ],
45
+ "id": "ch_00000000000000",
46
+ "invoice": null,
47
+ "livemode": false,
48
+ "object": "charge",
49
+ "paid": false,
50
+ "refunded": false
51
+ }
52
+ },
53
+ "id": "evt_00000000000000",
54
+ "livemode": false,
55
+ "object": "event",
56
+ "type": "charge.failed"
57
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount": 14500,
6
+ "amount_refunded": 0,
7
+ "captured": true,
8
+ "card": {
9
+ "address_city": null,
10
+ "address_country": null,
11
+ "address_line1": null,
12
+ "address_line1_check": null,
13
+ "address_line2": null,
14
+ "address_state": null,
15
+ "address_zip": null,
16
+ "address_zip_check": null,
17
+ "country": "US",
18
+ "cvc_check": null,
19
+ "exp_month": 2,
20
+ "exp_year": 2016,
21
+ "fingerprint": "wXWJT135mEK107G8",
22
+ "last4": "4242",
23
+ "name": "Johnny Appleseed",
24
+ "object": "card",
25
+ "type": "Visa"
26
+ },
27
+ "created": 1360179715,
28
+ "currency": "usd",
29
+ "customer": null,
30
+ "description": "Customer: Johnny Appleseed Email: japp@mailinator.com Product: A Box of Happiness ID: 36 Quantity: 3 ",
31
+ "dispute": null,
32
+ "failure_code": null,
33
+ "failure_message": null,
34
+ "fee": 0,
35
+ "fee_details": [
36
+ {
37
+ "amount": 451,
38
+ "amount_refunded": 0,
39
+ "application": null,
40
+ "currency": "usd",
41
+ "description": "Stripe processing fees",
42
+ "type": "stripe_fee"
43
+ }
44
+ ],
45
+ "id": "ch_00000000000000",
46
+ "invoice": null,
47
+ "livemode": false,
48
+ "object": "charge",
49
+ "paid": true,
50
+ "refunded": true
51
+ }
52
+ },
53
+ "id": "evt_00000000000000",
54
+ "livemode": false,
55
+ "object": "event",
56
+ "type": "charge.refunded"
57
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount": 14500,
6
+ "amount_refunded": 0,
7
+ "captured": true,
8
+ "card": {
9
+ "address_city": null,
10
+ "address_country": null,
11
+ "address_line1": null,
12
+ "address_line1_check": null,
13
+ "address_line2": null,
14
+ "address_state": null,
15
+ "address_zip": null,
16
+ "address_zip_check": null,
17
+ "country": "US",
18
+ "cvc_check": null,
19
+ "exp_month": 2,
20
+ "exp_year": 2016,
21
+ "fingerprint": "wXWJT135mEK107G8",
22
+ "last4": "4242",
23
+ "name": "Johnny Appleseed",
24
+ "object": "card",
25
+ "type": "Visa"
26
+ },
27
+ "created": 1360179715,
28
+ "currency": "usd",
29
+ "customer": null,
30
+ "description": "Customer: Johnny Appleseed Email: japp@mailinator.com Product: A Box of Happiness ID: 36 Quantity: 3 ",
31
+ "dispute": null,
32
+ "failure_code": null,
33
+ "failure_message": null,
34
+ "fee": 451,
35
+ "fee_details": [
36
+ {
37
+ "amount": 451,
38
+ "amount_refunded": 0,
39
+ "application": null,
40
+ "currency": "usd",
41
+ "description": "Stripe processing fees",
42
+ "type": "stripe_fee"
43
+ }
44
+ ],
45
+ "id": "ch_00000000000000",
46
+ "invoice": null,
47
+ "livemode": false,
48
+ "object": "charge",
49
+ "paid": true,
50
+ "refunded": false
51
+ }
52
+ },
53
+ "id": "evt_00000000000000",
54
+ "livemode": false,
55
+ "object": "event",
56
+ "type": "charge.succeeded"
57
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount_off": null,
6
+ "currency": "usd",
7
+ "duration": "repeating",
8
+ "duration_in_months": 3,
9
+ "id": "25OFF_00000000000000",
10
+ "livemode": false,
11
+ "max_redemptions": null,
12
+ "object": "coupon",
13
+ "percent_off": 25,
14
+ "redeem_by": null,
15
+ "times_redeemed": 0
16
+ }
17
+ },
18
+ "id": "evt_00000000000000",
19
+ "livemode": false,
20
+ "object": "event",
21
+ "type": "coupon.created"
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "created": 1326853478,
3
+ "data": {
4
+ "object": {
5
+ "amount_off": null,
6
+ "currency": "usd",
7
+ "duration": "repeating",
8
+ "duration_in_months": 3,
9
+ "id": "25OFF_00000000000000",
10
+ "livemode": false,
11
+ "max_redemptions": null,
12
+ "object": "coupon",
13
+ "percent_off": 25,
14
+ "redeem_by": null,
15
+ "times_redeemed": 0
16
+ }
17
+ },
18
+ "id": "evt_00000000000000",
19
+ "livemode": false,
20
+ "object": "event",
21
+ "type": "coupon.deleted"
22
+ }
@@ -0,0 +1,40 @@
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
+ },
36
+ "id": "evt_00000000000000",
37
+ "livemode": false,
38
+ "object": "event",
39
+ "type": "customer.created"
40
+ }
@@ -0,0 +1,40 @@
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
+ },
36
+ "id": "evt_00000000000000",
37
+ "livemode": false,
38
+ "object": "event",
39
+ "type": "customer.deleted"
40
+ }