stripe-ruby-mock 1.8.4.10 → 1.8.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/README.md +2 -2
  2. data/lib/stripe_mock/api/webhooks.rb +1 -0
  3. data/lib/stripe_mock/data.rb +2 -1
  4. data/lib/stripe_mock/instance.rb +4 -0
  5. data/lib/stripe_mock/request_handlers/cards.rb +26 -0
  6. data/lib/stripe_mock/version.rb +1 -1
  7. data/lib/stripe_mock/webhook_fixtures/account.updated.json +13 -11
  8. data/lib/stripe_mock/webhook_fixtures/balance.available.json +25 -0
  9. data/lib/stripe_mock/webhook_fixtures/charge.dispute.closed.json +12 -11
  10. data/lib/stripe_mock/webhook_fixtures/charge.dispute.created.json +12 -11
  11. data/lib/stripe_mock/webhook_fixtures/charge.dispute.updated.json +12 -11
  12. data/lib/stripe_mock/webhook_fixtures/charge.failed.json +40 -43
  13. data/lib/stripe_mock/webhook_fixtures/charge.refunded.json +44 -40
  14. data/lib/stripe_mock/webhook_fixtures/charge.succeeded.json +40 -43
  15. data/lib/stripe_mock/webhook_fixtures/coupon.created.json +12 -12
  16. data/lib/stripe_mock/webhook_fixtures/coupon.deleted.json +45 -15
  17. data/lib/stripe_mock/webhook_fixtures/customer.created.json +44 -32
  18. data/lib/stripe_mock/webhook_fixtures/customer.discount.created.json +15 -15
  19. data/lib/stripe_mock/webhook_fixtures/customer.discount.deleted.json +15 -15
  20. data/lib/stripe_mock/webhook_fixtures/customer.discount.updated.json +22 -22
  21. data/lib/stripe_mock/webhook_fixtures/customer.subscription.created.json +25 -23
  22. data/lib/stripe_mock/webhook_fixtures/customer.subscription.deleted.json +25 -23
  23. data/lib/stripe_mock/webhook_fixtures/customer.subscription.trial_will_end.json +25 -23
  24. data/lib/stripe_mock/webhook_fixtures/customer.subscription.updated.json +31 -29
  25. data/lib/stripe_mock/webhook_fixtures/customer.updated.json +44 -32
  26. data/lib/stripe_mock/webhook_fixtures/invoice.created.json +41 -40
  27. data/lib/stripe_mock/webhook_fixtures/invoice.payment_failed.json +41 -40
  28. data/lib/stripe_mock/webhook_fixtures/invoice.payment_succeeded.json +41 -40
  29. data/lib/stripe_mock/webhook_fixtures/invoice.updated.json +45 -42
  30. data/lib/stripe_mock/webhook_fixtures/invoiceitem.created.json +13 -13
  31. data/lib/stripe_mock/webhook_fixtures/invoiceitem.deleted.json +13 -13
  32. data/lib/stripe_mock/webhook_fixtures/invoiceitem.updated.json +13 -13
  33. data/lib/stripe_mock/webhook_fixtures/plan.created.json +12 -12
  34. data/lib/stripe_mock/webhook_fixtures/plan.deleted.json +12 -12
  35. data/lib/stripe_mock/webhook_fixtures/plan.updated.json +12 -12
  36. data/lib/stripe_mock/webhook_fixtures/transfer.created.json +80 -15
  37. data/lib/stripe_mock/webhook_fixtures/transfer.failed.json +80 -15
  38. data/lib/stripe_mock/webhook_fixtures/transfer.paid.json +80 -15
  39. data/lib/stripe_mock/webhook_fixtures/transfer.updated.json +80 -15
  40. data/spec/readme_spec.rb +1 -1
  41. data/spec/shared_stripe_examples/card_examples.rb +20 -0
  42. data/spec/shared_stripe_examples/charge_examples.rb +1 -0
  43. metadata +3 -2
@@ -1,23 +1,88 @@
1
1
  {
2
2
  "created": 1326853478,
3
+ "livemode": false,
4
+ "id": "evt_00000000000000",
5
+ "type": "transfer.failed",
6
+ "object": "event",
3
7
  "data": {
4
8
  "object": {
5
- "account": null,
6
- "amount": 1100,
7
- "currency": "usd",
8
- "date": 1371513600,
9
- "description": "Transfer to test@example.com",
10
- "fee": 0,
11
- "fee_details": [],
12
9
  "id": "tr_00000000000000",
13
- "livemode": true,
14
10
  "object": "transfer",
15
- "recipient": "rp_00000000000000",
16
- "status": "failed"
11
+ "date": 1381104000,
12
+ "livemode": false,
13
+ "amount": 67,
14
+ "currency": "usd",
15
+ "status": "failed",
16
+ "balance_transaction": "txn_00000000000000",
17
+ "summary": {
18
+ "charge_gross": 100,
19
+ "charge_fees": 33,
20
+ "charge_fee_details": [
21
+ {
22
+ "amount": 33,
23
+ "currency": "usd",
24
+ "type": "stripe_fee",
25
+ "description": null,
26
+ "application": null
27
+ }
28
+ ],
29
+ "refund_gross": 0,
30
+ "refund_fees": 0,
31
+ "refund_fee_details": [
32
+
33
+ ],
34
+ "adjustment_gross": 0,
35
+ "adjustment_fees": 0,
36
+ "adjustment_fee_details": [
37
+
38
+ ],
39
+ "validation_fees": 0,
40
+ "validation_count": 0,
41
+ "charge_count": 1,
42
+ "refund_count": 0,
43
+ "adjustment_count": 0,
44
+ "net": 67,
45
+ "currency": "usd",
46
+ "collected_fee_gross": 0,
47
+ "collected_fee_count": 0,
48
+ "collected_fee_refund_gross": 0,
49
+ "collected_fee_refund_count": 0
50
+ },
51
+ "transactions": {
52
+ "object": "list",
53
+ "count": 1,
54
+ "url": "/v1/transfers/tr_2h8RC13PPvwDZs/transactions",
55
+ "data": [
56
+ {
57
+ "id": "ch_2fb4RERw49oI8s",
58
+ "type": "charge",
59
+ "amount": 100,
60
+ "currency": "usd",
61
+ "net": 67,
62
+ "created": 1380582860,
63
+ "description": null,
64
+ "fee": 33,
65
+ "fee_details": [
66
+ {
67
+ "amount": 33,
68
+ "currency": "usd",
69
+ "type": "stripe_fee",
70
+ "description": "Stripe processing fees",
71
+ "application": null
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ },
77
+ "other_transfers": [
78
+ "tr_2h8RC13PPvwDZs"
79
+ ],
80
+ "account": null,
81
+ "description": "STRIPE TRANSFER",
82
+ "metadata": {
83
+ },
84
+ "statement_descriptor": null,
85
+ "recipient": null
17
86
  }
18
- },
19
- "id": "evt_00000000000000",
20
- "livemode": false,
21
- "object": "event",
22
- "type": "transfer.failed"
87
+ }
23
88
  }
@@ -1,23 +1,88 @@
1
1
  {
2
2
  "created": 1326853478,
3
+ "livemode": false,
4
+ "id": "evt_00000000000000",
5
+ "type": "transfer.paid",
6
+ "object": "event",
3
7
  "data": {
4
8
  "object": {
5
- "account": null,
6
- "amount": 1100,
7
- "currency": "usd",
8
- "date": 1371513600,
9
- "description": "Transfer to test@example.com",
10
- "fee": 0,
11
- "fee_details": [],
12
9
  "id": "tr_00000000000000",
13
- "livemode": true,
14
10
  "object": "transfer",
15
- "recipient": "rp_00000000000000",
16
- "status": "paid"
11
+ "date": 1381104000,
12
+ "livemode": false,
13
+ "amount": 67,
14
+ "currency": "usd",
15
+ "status": "paid",
16
+ "balance_transaction": "txn_00000000000000",
17
+ "summary": {
18
+ "charge_gross": 100,
19
+ "charge_fees": 33,
20
+ "charge_fee_details": [
21
+ {
22
+ "amount": 33,
23
+ "currency": "usd",
24
+ "type": "stripe_fee",
25
+ "description": null,
26
+ "application": null
27
+ }
28
+ ],
29
+ "refund_gross": 0,
30
+ "refund_fees": 0,
31
+ "refund_fee_details": [
32
+
33
+ ],
34
+ "adjustment_gross": 0,
35
+ "adjustment_fees": 0,
36
+ "adjustment_fee_details": [
37
+
38
+ ],
39
+ "validation_fees": 0,
40
+ "validation_count": 0,
41
+ "charge_count": 1,
42
+ "refund_count": 0,
43
+ "adjustment_count": 0,
44
+ "net": 67,
45
+ "currency": "usd",
46
+ "collected_fee_gross": 0,
47
+ "collected_fee_count": 0,
48
+ "collected_fee_refund_gross": 0,
49
+ "collected_fee_refund_count": 0
50
+ },
51
+ "transactions": {
52
+ "object": "list",
53
+ "count": 1,
54
+ "url": "/v1/transfers/tr_2h8RC13PPvwDZs/transactions",
55
+ "data": [
56
+ {
57
+ "id": "ch_2fb4RERw49oI8s",
58
+ "type": "charge",
59
+ "amount": 100,
60
+ "currency": "usd",
61
+ "net": 67,
62
+ "created": 1380582860,
63
+ "description": null,
64
+ "fee": 33,
65
+ "fee_details": [
66
+ {
67
+ "amount": 33,
68
+ "currency": "usd",
69
+ "type": "stripe_fee",
70
+ "description": "Stripe processing fees",
71
+ "application": null
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ },
77
+ "other_transfers": [
78
+ "tr_2h8RC13PPvwDZs"
79
+ ],
80
+ "account": null,
81
+ "description": "STRIPE TRANSFER",
82
+ "metadata": {
83
+ },
84
+ "statement_descriptor": null,
85
+ "recipient": null
17
86
  }
18
- },
19
- "id": "evt_00000000000000",
20
- "livemode": false,
21
- "object": "event",
22
- "type": "transfer.paid"
87
+ }
23
88
  }
@@ -1,26 +1,91 @@
1
1
  {
2
2
  "created": 1326853478,
3
+ "livemode": false,
4
+ "id": "evt_00000000000000",
5
+ "type": "transfer.updated",
6
+ "object": "event",
3
7
  "data": {
4
8
  "object": {
5
- "account": null,
6
- "amount": 1100,
7
- "currency": "usd",
8
- "date": 1371513600,
9
- "description": "Transfer to test@example.com",
10
- "fee": 0,
11
- "fee_details": [],
12
9
  "id": "tr_00000000000000",
13
- "livemode": true,
14
10
  "object": "transfer",
15
- "recipient": "rp_00000000000000",
16
- "status": "pending"
11
+ "date": 1381104000,
12
+ "livemode": false,
13
+ "amount": 67,
14
+ "currency": "usd",
15
+ "status": "pending",
16
+ "balance_transaction": "txn_00000000000000",
17
+ "summary": {
18
+ "charge_gross": 100,
19
+ "charge_fees": 33,
20
+ "charge_fee_details": [
21
+ {
22
+ "amount": 33,
23
+ "currency": "usd",
24
+ "type": "stripe_fee",
25
+ "description": null,
26
+ "application": null
27
+ }
28
+ ],
29
+ "refund_gross": 0,
30
+ "refund_fees": 0,
31
+ "refund_fee_details": [
32
+
33
+ ],
34
+ "adjustment_gross": 0,
35
+ "adjustment_fees": 0,
36
+ "adjustment_fee_details": [
37
+
38
+ ],
39
+ "validation_fees": 0,
40
+ "validation_count": 0,
41
+ "charge_count": 1,
42
+ "refund_count": 0,
43
+ "adjustment_count": 0,
44
+ "net": 67,
45
+ "currency": "usd",
46
+ "collected_fee_gross": 0,
47
+ "collected_fee_count": 0,
48
+ "collected_fee_refund_gross": 0,
49
+ "collected_fee_refund_count": 0
50
+ },
51
+ "transactions": {
52
+ "object": "list",
53
+ "count": 1,
54
+ "url": "/v1/transfers/tr_2h8RC13PPvwDZs/transactions",
55
+ "data": [
56
+ {
57
+ "id": "ch_2fb4RERw49oI8s",
58
+ "type": "charge",
59
+ "amount": 100,
60
+ "currency": "usd",
61
+ "net": 67,
62
+ "created": 1380582860,
63
+ "description": null,
64
+ "fee": 33,
65
+ "fee_details": [
66
+ {
67
+ "amount": 33,
68
+ "currency": "usd",
69
+ "type": "stripe_fee",
70
+ "description": "Stripe processing fees",
71
+ "application": null
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ },
77
+ "other_transfers": [
78
+ "tr_2h8RC13PPvwDZs"
79
+ ],
80
+ "account": null,
81
+ "description": "STRIPE TRANSFER",
82
+ "metadata": {
83
+ },
84
+ "statement_descriptor": null,
85
+ "recipient": null
17
86
  },
18
87
  "previous_attributes": {
19
88
  "amount": 123
20
89
  }
21
- },
22
- "id": "evt_00000000000000",
23
- "livemode": false,
24
- "object": "event",
25
- "type": "transfer.updated"
90
+ }
26
91
  }
@@ -44,7 +44,7 @@ describe 'README examples' do
44
44
 
45
45
  customer_object = event.data.object
46
46
  expect(customer_object.id).to_not be_nil
47
- expect(customer_object.active_card).to_not be_nil
47
+ expect(customer_object.default_card).to_not be_nil
48
48
  # etc.
49
49
  end
50
50
 
@@ -51,4 +51,24 @@ shared_examples 'Card API' do
51
51
  customer = Stripe::Customer.retrieve('test_customer_sub')
52
52
  expect(customer.default_card).to be_nil
53
53
  end
54
+
55
+ context "retrieval and deletion" do
56
+ let!(:customer) { Stripe::Customer.create(id: 'test_customer_sub') }
57
+ let!(:card_token) { StripeMock.generate_card_token(last4: "1123", exp_month: 11, exp_year: 2099) }
58
+ let!(:card) { customer.cards.create(card: card_token) }
59
+
60
+ it "retrieves a customers card" do
61
+ retrieved = customer.cards.retrieve(card.id)
62
+ expect(retrieved.to_s).to eq(card.to_s)
63
+ end
64
+
65
+ it "deletes a customers card" do
66
+ card.delete
67
+ retrieved_cus = Stripe::Customer.retrieve(customer.id)
68
+ expect(retrieved_cus.cards.data).to be_empty
69
+ end
70
+
71
+ it "updates the default card if deleted"
72
+
73
+ end
54
74
  end
@@ -133,5 +133,6 @@ shared_examples 'Charge API' do
133
133
 
134
134
  expect(charge.refunded).to eq(true)
135
135
  expect(charge.refunds.first.amount).to eq(999)
136
+ expect(charge.amount_refunded).to eq(999)
136
137
  end
137
138
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-ruby-mock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.4.10
4
+ version: 1.8.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-27 00:00:00.000000000 Z
12
+ date: 2013-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: stripe
@@ -154,6 +154,7 @@ files:
154
154
  - lib/stripe_mock/version.rb
155
155
  - lib/stripe_mock/webhook_fixtures/account.application.deauthorized.json
156
156
  - lib/stripe_mock/webhook_fixtures/account.updated.json
157
+ - lib/stripe_mock/webhook_fixtures/balance.available.json
157
158
  - lib/stripe_mock/webhook_fixtures/charge.dispute.closed.json
158
159
  - lib/stripe_mock/webhook_fixtures/charge.dispute.created.json
159
160
  - lib/stripe_mock/webhook_fixtures/charge.dispute.updated.json