-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathaccounts.feature
126 lines (117 loc) · 3.87 KB
/
accounts.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
Feature: Accounts
Accounts are funding instruments which are able to store a balance internally with the Balanced system.
Scenario: List accounts
Given I have created a customer
When I GET to /accounts
Then I should get a 200 OK status code
And the response is valid according to the "accounts" schema
Scenario: Retrieving accounts for a customer
Given I have created a customer
When I GET to /customers/:customer_id/accounts
Then I should get a 200 OK status code
And the response is valid according to the "accounts" schema
And the fields on these accounts match:
"""
{
"links": {
"customer": ":customer_id"
}
}
"""
Scenario: Credit a customer payable account
Given I have an order with a debit
When I POST to /accounts/:customer_payable_account_id/credits with the body:
"""
{
"credits": [{
"amount": 234,
"order": "/orders/:order_id"
}]
}
"""
Then I should get a 201 Created status code
And the response is valid according to the "credits" schema
Scenario: Retrieving credits for an account
Given I have an Account with sufficient funds
When I GET to /accounts/:customer_payable_account_id/credits
Then I should get a 200 OK status code
And the response is valid according to the "credits" schema
And the fields on these credits match:
"""
{
"links": {
"destination": ":customer_payable_account_id"
}
}
"""
# Currently there are no debitable accounts
Scenario: Retrieving debits for an account
Given I have an Account with sufficient funds
When I GET to /accounts/:customer_payable_account_id/debits
Then I should get a 200 OK status code
And the fields on these debits match:
"""
{
"meta": {
"total": 0
}
}
"""
# Currently there are no debitable accounts, thus no refunds
Scenario: Retrieving refunds for an account
Given I have an Account with a credit
Then I POST to /credits/:credit_id/reversals
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
When I GET to /accounts/:customer_payable_account_id/refunds
Then I should get a 200 OK status code
And the fields on these refunds match:
"""
{
"meta": {
"total": 0
}
}
"""
Scenario: Retrieving reversals for an account
Given I have an Account with a credit
Then I POST to /credits/:credit_id/reversals
Then I should get a 201 Created status code
And the response is valid according to the "reversals" schema
When I GET to /accounts/:customer_payable_account_id/reversals
Then I should get a 200 OK status code
And the response is valid according to the "reversals" schema
And the fields on these reversals match:
"""
{
"links": {
"credit": ":credit_id"
}
}
"""
Scenario: Retrieving settlements for an account
Given I have an Account with sufficient funds
When I POST to /accounts/:customer_payable_account_id/settlements with the body:
"""
{
"settlements": [{
"funding_instrument": "/bank_accounts/:bank_account_id",
"appears_on_statement_as": "Settlement Oct",
"description": "Settlement for payouts from October"
}]
}
"""
Then I should get a 201 Created status code
And the response is valid according to the "settlements" schema
When I GET to /accounts/:customer_payable_account_id/settlements
Then I should get a 200 OK status code
And the response is valid according to the "settlements" schema
And the fields on these settlements match:
"""
{
"links": {
"source": ":customer_payable_account_id"
}
}
"""