/
debits.feature
227 lines (210 loc) · 6.25 KB
/
debits.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
Feature: Debit a card or bank account
Debits is the action of charging a customers card or bank account.
Upon a debit succeeding, the value will be reflected in the marketplace's escrow balance
or in the escrow for an order.
Scenario: Debiting a card
Given I have tokenized a card
When I POST to /cards/:card_id/debits with the body:
"""
{
"debits": [{
"amount": 20000
}]
}
"""
Then I should get a 201 Created status code
And the response is valid according to the "debits" schema
And the fields on this debit match:
"""
{
"amount": 20000
}
"""
Scenario: Retrieving debits for a card
Given I have debited a card
When I GET to /cards/:card_id/debits
Then I should get a 200 OK status code
And the response is valid according to the "debits" schema
And the fields on these debits match:
"""
{
"links": {
"source": ":card_id"
}
}
"""
Scenario: Debiting a customer
If the debit is done directly on the customer resource
then that customers default "funding source" will be used
when preforming the debit.
Given I have a customer with a card
When I POST to /customers/:customer_id/debits with the body:
"""
{
"debits": [{
"amount": 2000,
"meta": {
"product_id": "123123123"
},
"description": "Bob is giving me some $$$"
}]
}
"""
Then I should get a 201 Created status code
And the response is valid according to the "debits" schema
And the fields on this debit match:
"""
{
"amount": 2000,
"links": {
"customer": ":customer_id"
},
"meta": {
"product_id": "123123123"
},
"description": "Bob is giving me some $$$"
}
"""
Scenario: List debits
Given I have more than one debit
When I GET to /debits
Then I should get a 200 OK status code
And the response is valid according to the "debits" schema
Scenario: Update a debit description
Given I have debited a card
When I PUT to /debits/:debit_id with the body:
"""
{
"description": "something useful"
}
"""
Then I should get a 200 OK status code
And the response is valid according to the "debits" schema
And the fields on this debit match:
"""
{
"description": "something useful"
}
"""
Scenario: Update a debit meta
Given I have debited a card
When I PUT to /debits/:debit_id with the body:
"""
{
"debits": [{
"meta": {
"order.status": "shipped"
}
}]
}
"""
Then I should get a 200 OK status code
And the response is valid according to the "debits" schema
And the fields on this debit match:
"""
{
"meta": {
"order.status": "shipped"
}
}
"""
Scenario: Refund a debit
Given I have debited a card
When I POST to /debits/:debit_id/refunds
Then I should get a 201 Created status code
And the response is valid according to the "refunds" schema
Scenario: Debit a card
Given I have tokenized a card
When I make a POST request to the link "cards.debits" with the body:
"""
{ "debits": [ {"amount": 2000 } ] }
"""
Then I should get a 201 Created status code
And the response is valid according to the "debits" schema
Scenario: Debit a card
Given I have tokenized a card
When I make a POST request to /debits with the body:
"""
{
"amount": 2000,
"source": ":card_href"
}
"""
Then I should get a 201 Created status code
And the response is valid according to the "debits" schema
Scenario: Debit a customer card
Given I have tokenized a customer card
When I make a POST request to the link "cards.debits" with the body:
"""
{ "debits": [ {"amount": 2000 } ] }
"""
Then I should get a 201 Created status code
And the response is valid according to the "debits" schema
Scenario: Debit a verified bank account
Given I have a verified bank account
When I make a POST request to the link "bank_accounts.debits" with the body:
"""
{ "debits": [ {"amount": 2000 } ] }
"""
Then I should get a 201 Created status code
And the response is valid according to the "debits" schema
And the fields on these debits match:
"""
{ "status": "succeeded" }
"""
Scenario: Debits to unverified bank accounts fail
Given I have attempted to verify a bank account and failed
When I make a POST request to the link "bank_accounts.debits" with the body:
"""
{ "debits": [ {"amount": 2000 } ] }
"""
Then I should get a 409 Conflict status code
And the response is valid according to the "debits" schema
And the fields on these debits match:
"""
{ "status": "failed" }
"""
Scenario: Debit a customer
Given I have created a customer
When I make a POST request to the link "customers.debits" with the body:
"""
{ "debits": [ {"amount": 1234 } ] }
"""
Then I should get a 201 Created status code
And the response is valid according to the "debits" schema
Scenario: Failing to debit a customer
Given I have created a customer without a card and bank account
When I make a POST request to the link "customers.debits" with the body:
"""
{ "debits": [ {"amount": 8979 } ] }
"""
Then I should get a 409 Conflict status code
And the response is valid according to the "debits" schema
Scenario: Debiting a card directly
When I POST to /debits with the body:
"""
{
"debits": [{
"amount": 1234,
"source": {
"number": "4111111111111111",
"expiration_year": "2018",
"expiration_month": 12
}
}]
}
"""
Then I should get a 201 Created status code
And the response is valid according to the "debits" schema
Scenario: Debit unassociated card
Given I have tokenized a card
When I POST to /cards/:card_id/debits with the body:
"""
{
"debits": [{
"amount": 5000
}]
}
"""
Then I should get a 201 Created status code
And the response is valid according to the "debits" schema