diff --git a/features/credits.feature b/features/credits.feature index 7ffe1bd..831c205 100644 --- a/features/credits.feature +++ b/features/credits.feature @@ -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 \ No newline at end of file diff --git a/features/step_definitions/orders.rb b/features/step_definitions/orders.rb index 96d342a..c89801c 100644 --- a/features/step_definitions/orders.rb +++ b/features/step_definitions/orders.rb @@ -55,4 +55,24 @@ order: @order_id }) @client.add_hydrate :card_hold_id, @client['id'] -end \ No newline at end of file +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