Skip to content
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 credit endpoint spec #703

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions features/credits.feature
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,40 @@ Feature: Credits
"category_code": "no-funding-destination"
}
"""

Scenario: Bulk credit a bank account
Given I have a merchant with 5 orders with debits
When I POST to /bank_accounts/:bank_account_id/bulk_credits with the body:
"""
{
"credits": [
{
"amount": 1234,
"order": ":order_id_1",
"appears_on_statement_as": "Payout group A"
},
{
"amount": 1234,
"order": ":order_id_2",
"appears_on_statement_as": "Payout group A"
},
{
"amount": 1234,
"order": ":order_id_3",
"appears_on_statement_as": "Payout group B"
},
{
"amount": 1234,
"order": ":order_id_4",
"appears_on_statement_as": "Payout group B"
},
{
"amount": 1234,
"order": ":order_id_5",
"appears_on_statement_as": "Payout group C"
}
]
}
"""
Then I should get a 202 Accepted status code
And there should be no response body
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a response body

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would the response body consist of?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a collection of credits! ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we're expecting the client to wait around while the credits are created, right?

Or should this be a fire-and-forget endpoint and API consumers are responsible for watching for these credits via events?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case it should give a 202 HTTP status code

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

202 Accepted

The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. There is no facility for re-sending a status code from an asynchronous operation such as this.

The 202 response is intentionally non-committal. Its purpose is to allow a server to accept a request for some other process (perhaps a batch-oriented process that is only run once per day) without requiring that the user agent's connection to the server persist until the process is completed. The entity returned with this response SHOULD include an indication of the request's current status and either a pointer to a status monitor or some estimate of when the user can expect the request to be fulfilled.

22 changes: 21 additions & 1 deletion features/step_definitions/orders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,24 @@
order: @order_id
})
@client.add_hydrate :card_hold_id, @client['id']
end
end


Given(/^I have a merchant with (\d) orders with debits$/) do |num|
step 'I have created a customer'
@client.post('/customers', {})
@merchant_id = @client['id']
@client.add_hydrate :merchant_id, @merchant_id
step 'I have tokenized a bank account and associated with the merchant'
num.to_i.times do |i|
@client.post("/customers/#{@merchant_id}/orders", {})
order_id = @client['id']
@client.add_hydrate :order_id, order_id
@client.post("/cards/#{@card_id}/debits", {
amount: 12345,
order: order_id
})
@client.add_hydrate :debit_id, @merchant_id
instance_variable_set("@order_id_#{i + 1}", order_id)
end
end