-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bulk credits sweep account #707
Changes from all commits
c8530e8
29279bd
8471295
f42089a
172a527
306bee1
6fe13fd
a9dd0a9
18d6292
8045aba
0aeab75
1e49b4d
642370e
d3e31f8
e4d8cbf
745d043
2e3b457
f2c7675
8ef8470
d1e4036
36352e7
1365a5b
9a36b43
676ffec
8e6280e
b617c04
2b66e22
9b0f434
e988cc9
ff15533
f59e0dc
aa0cc6f
2ff55e8
8b81e3e
959a691
f75e3a0
b5538ed
ec3af70
08ad48e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" | ||
} | ||
} | ||
""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,3 +124,50 @@ Feature: Credits | |
"category_code": "no-funding-destination" | ||
} | ||
""" | ||
|
||
|
||
Scenario: Bulk credit to a customer payable account | ||
Given I have a merchant with 2 orders with debits | ||
When I POST to /accounts/:customer_payable_account_id/credits with the body: | ||
""" | ||
{ | ||
"credits": [{ | ||
"amount": 1000, | ||
"order": "/orders/:order_id_1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would the credit say its destination is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I reverse a credit before it's at the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
that's implied by the endpoint that you're POSTing to in this scenario.
it immediately goes to the sweep, i think you mean bank account. if you reverse a credit it should leave the sweep with a negative balance (if the credit has cleared to the bank account). in that case it would eventually debit the bank account to zero out the balance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mjallday What do you mean by "eventually"? When would it actually debit the bank account? What would happen if the bank account doesn't have any balance? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the sum of the transactions to the sweep account since it was last settled are less than zero then it would result in a debit to the bank account. we haven't defined how that would react in the case of the underlying bank account failing but i suspect it would cause the other transactions to go into a failed state. |
||
"appears_on_statement_as": "Payout group A" | ||
}] | ||
} | ||
""" | ||
Then I should get a 201 Created status code | ||
And the response is valid according to the "credits" schema | ||
|
||
When I make a GET request to /accounts/:customer_payable_account_id | ||
Then I should get a 200 OK status code | ||
And the fields on this account match: | ||
""" | ||
{ | ||
"balance": 1000 | ||
} | ||
""" | ||
|
||
When I POST to /accounts/:customer_payable_account_id/credits with the body: | ||
""" | ||
{ | ||
"credits": [{ | ||
"amount": 1000, | ||
"order": "/orders/:order_id_2", | ||
"appears_on_statement_as": "Payout group B" | ||
}] | ||
} | ||
""" | ||
Then I should get a 201 Created status code | ||
And the response is valid according to the "credits" schema | ||
|
||
When I make a GET request to /accounts/:customer_payable_account_id | ||
Then I should get a 200 OK status code | ||
And the fields on this account match: | ||
""" | ||
{ | ||
"balance": 2000 | ||
} | ||
""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,3 +159,69 @@ Feature: Reversal | |
""" | ||
{ "status": "failed" } | ||
""" | ||
|
||
Scenario: Reverse an Account credit before settlement | ||
Given I have an Account with sufficient funds | ||
When I POST to /credits/:credit_id_2/reversals with the body: | ||
""" | ||
{ | ||
"reversals": [{ | ||
"amount": 1000 | ||
}] | ||
} | ||
""" | ||
Then I should get a 201 Created status code | ||
And the response is valid according to the "reversals" schema | ||
And the fields on this reversal match: | ||
""" | ||
{ "status": "succeeded" } | ||
""" | ||
|
||
Scenario: Reverse an Account credit after settlement | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a reversals happening in this scenario despite it saying "reverse an account credit". |
||
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" | ||
}] | ||
} | ||
""" | ||
Then I should get a 201 Created status code | ||
And the response is valid according to the "settlements" schema | ||
And the fields on this settlement match: | ||
""" | ||
{ | ||
"amount": 30000, | ||
"status": "succeeded" | ||
} | ||
""" | ||
|
||
When I POST to /credits/:credit_id_2/reversals | ||
Then I should get a 201 Created status code | ||
And the response is valid according to the "reversals" schema | ||
And the fields on this reversal match: | ||
""" | ||
{ | ||
"amount": 10000, | ||
"status": "succeeded" | ||
} | ||
""" | ||
|
||
When I POST to /accounts/:customer_payable_account_id/settlements with the body: | ||
""" | ||
{ | ||
"settlements": [{ | ||
"funding_instrument": "/bank_accounts/:bank_account_id" | ||
}] | ||
} | ||
""" | ||
Then I should get a 201 Created status code | ||
And the response is valid according to the "settlements" schema | ||
|
||
When I make a GET request to the link "reversals.order" | ||
Then I should get a 200 OK status code | ||
And the fields on this order match: | ||
""" | ||
{ "amount_escrowed": 10000 } | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it return the order href? i think we return the order ID and a link href.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The response should. Most of the steps in these API specs are just written to get the ID so I followed that convention for now, but I'd like to revisit it later.