balanced 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +10 -6
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/balanced/resources.rb +2 -0
- data/lib/balanced/resources/account.rb +33 -0
- data/lib/balanced/resources/card.rb +1 -1
- data/lib/balanced/resources/customer.rb +8 -0
- data/lib/balanced/resources/resource.rb +4 -6
- data/lib/balanced/resources/settlement.rb +12 -0
- data/lib/balanced/response/balanced_exception_middleware.rb +1 -1
- data/lib/balanced/utils.rb +1 -1
- data/lib/balanced/version.rb +1 -1
- data/scenarios/account_credit/definition.rb +1 -0
- data/scenarios/account_credit/request.rb +5 -0
- data/scenarios/account_credit/ruby.mako +49 -0
- data/scenarios/account_list/definition.rb +1 -0
- data/scenarios/account_list/request.rb +2 -0
- data/scenarios/account_list/ruby.mako +64 -0
- data/scenarios/account_list_customer/definition.rb +1 -0
- data/scenarios/account_list_customer/request.rb +3 -0
- data/scenarios/account_list_customer/ruby.mako +38 -0
- data/scenarios/account_show/definition.rb +1 -0
- data/scenarios/account_show/request.rb +2 -0
- data/scenarios/account_show/ruby.mako +37 -0
- data/scenarios/api_key_create/ruby.mako +6 -6
- data/scenarios/api_key_delete/ruby.mako +2 -2
- data/scenarios/api_key_list/ruby.mako +10 -10
- data/scenarios/api_key_show/ruby.mako +6 -6
- data/scenarios/bank_account_associate_to_customer/ruby.mako +16 -14
- data/scenarios/bank_account_create/ruby.mako +13 -11
- data/scenarios/bank_account_credit/ruby.mako +16 -16
- data/scenarios/bank_account_debit/ruby.mako +21 -18
- data/scenarios/bank_account_debit_order/definition.rb +1 -0
- data/scenarios/bank_account_debit_order/request.rb +7 -0
- data/scenarios/bank_account_debit_order/ruby.mako +52 -0
- data/scenarios/bank_account_delete/ruby.mako +2 -2
- data/scenarios/bank_account_list/ruby.mako +26 -22
- data/scenarios/bank_account_show/ruby.mako +14 -12
- data/scenarios/bank_account_update/ruby.mako +14 -12
- data/scenarios/bank_account_verification_create/ruby.mako +10 -10
- data/scenarios/bank_account_verification_show/ruby.mako +10 -10
- data/scenarios/bank_account_verification_update/ruby.mako +9 -9
- data/scenarios/callback_create/ruby.mako +4 -4
- data/scenarios/callback_delete/ruby.mako +2 -2
- data/scenarios/callback_list/ruby.mako +4 -4
- data/scenarios/callback_show/ruby.mako +5 -5
- data/scenarios/card_associate_to_customer/ruby.mako +26 -26
- data/scenarios/card_create/ruby.mako +13 -15
- data/scenarios/card_create_creditable/ruby.mako +11 -11
- data/scenarios/card_create_dispute/ruby.mako +13 -13
- data/scenarios/card_credit/ruby.mako +16 -14
- data/scenarios/card_credit_order/definition.rb +1 -0
- data/scenarios/card_credit_order/request.rb +7 -0
- data/scenarios/card_credit_order/ruby.mako +45 -0
- data/scenarios/card_debit/ruby.mako +20 -17
- data/scenarios/card_debit_dispute/ruby.mako +20 -17
- data/scenarios/card_delete/ruby.mako +2 -2
- data/scenarios/card_hold_capture/ruby.mako +20 -17
- data/scenarios/card_hold_create/ruby.mako +16 -14
- data/scenarios/card_hold_list/ruby.mako +33 -27
- data/scenarios/card_hold_order/definition.rb +1 -0
- data/scenarios/card_hold_order/request.rb +6 -0
- data/scenarios/card_hold_order/ruby.mako +45 -0
- data/scenarios/card_hold_show/ruby.mako +16 -14
- data/scenarios/card_hold_update/ruby.mako +16 -14
- data/scenarios/card_hold_void/ruby.mako +17 -15
- data/scenarios/card_list/ruby.mako +25 -29
- data/scenarios/card_show/ruby.mako +14 -16
- data/scenarios/card_update/ruby.mako +14 -16
- data/scenarios/credit_list/ruby.mako +44 -14
- data/scenarios/credit_list_bank_account/ruby.mako +3 -3
- data/scenarios/credit_order/request.rb +2 -2
- data/scenarios/credit_order/ruby.mako +35 -14
- data/scenarios/credit_show/ruby.mako +16 -16
- data/scenarios/credit_update/ruby.mako +16 -16
- data/scenarios/customer_create/ruby.mako +22 -20
- data/scenarios/customer_delete/ruby.mako +1 -1
- data/scenarios/customer_list/ruby.mako +43 -39
- data/scenarios/customer_show/ruby.mako +23 -21
- data/scenarios/customer_update/ruby.mako +23 -21
- data/scenarios/debit_dispute_show/ruby.mako +12 -12
- data/scenarios/debit_list/ruby.mako +43 -37
- data/scenarios/debit_order/ruby.mako +22 -19
- data/scenarios/debit_show/ruby.mako +20 -17
- data/scenarios/debit_update/ruby.mako +20 -17
- data/scenarios/dispute_list/ruby.mako +11 -11
- data/scenarios/dispute_show/ruby.mako +12 -12
- data/scenarios/event_list/ruby.mako +55 -81
- data/scenarios/event_show/ruby.mako +35 -45
- data/scenarios/order_create/ruby.mako +16 -14
- data/scenarios/order_list/ruby.mako +33 -29
- data/scenarios/order_show/ruby.mako +16 -14
- data/scenarios/order_update/ruby.mako +16 -14
- data/scenarios/refund_create/ruby.mako +13 -13
- data/scenarios/refund_list/ruby.mako +12 -12
- data/scenarios/refund_show/ruby.mako +13 -13
- data/scenarios/refund_update/ruby.mako +13 -13
- data/scenarios/reversal_create/ruby.mako +13 -13
- data/scenarios/reversal_list/ruby.mako +12 -12
- data/scenarios/reversal_show/ruby.mako +13 -13
- data/scenarios/reversal_update/ruby.mako +13 -13
- data/scenarios/settlement_create/definition.rb +1 -0
- data/scenarios/settlement_create/request.rb +5 -0
- data/scenarios/settlement_create/ruby.mako +48 -0
- data/scenarios/settlement_list/definition.rb +1 -0
- data/scenarios/settlement_list/request.rb +2 -0
- data/scenarios/settlement_list/ruby.mako +40 -0
- data/scenarios/settlement_list_account/definition.rb +1 -0
- data/scenarios/settlement_list_account/request.rb +3 -0
- data/scenarios/settlement_list_account/ruby.mako +41 -0
- data/scenarios/settlement_show/definition.rb +1 -0
- data/scenarios/settlement_show/request.rb +2 -0
- data/scenarios/settlement_show/ruby.mako +40 -0
- data/snippets/account-balance.rb +1 -0
- data/snippets/bank-account-create.rb +6 -0
- data/snippets/bank-account-debit.rb +9 -0
- data/snippets/bank-account-verification-confirm.rb +5 -0
- data/snippets/bank-account-verification-create.rb +1 -0
- data/snippets/callback-create.rb +4 -0
- data/snippets/card-associate-to-customer.rb +2 -0
- data/snippets/card-create-dispute.rb +6 -0
- data/snippets/card-create.rb +7 -0
- data/snippets/card-credit.rb +9 -0
- data/snippets/card-debit.rb +9 -0
- data/snippets/card-hold-capture.rb +6 -0
- data/snippets/card-hold-create.rb +6 -0
- data/snippets/card-hold-void.rb +3 -0
- data/snippets/create-buyer-and-card.rb +13 -0
- data/snippets/credit-create.rb +8 -0
- data/snippets/credit-fetch.rb +1 -0
- data/snippets/credit-marketplace-escrow.rb +4 -0
- data/snippets/credit-reverse.rb +1 -0
- data/snippets/credit-soft-descriptor.rb +9 -0
- data/snippets/credit-split.rb +13 -0
- data/snippets/customer-create.rb +8 -0
- data/snippets/debit-dispute-show.rb +3 -0
- data/snippets/debit-fetch.rb +1 -0
- data/snippets/debit-marketplace-escrow.rb +4 -0
- data/snippets/debit-refund.rb +1 -0
- data/snippets/dispute-list.rb +1 -0
- data/snippets/dispute-show.rb +2 -0
- data/snippets/examine-order-after-refund.rb +3 -0
- data/snippets/examine-order-after-reversal.rb +3 -0
- data/snippets/example.rb +1 -0
- data/snippets/marketplace-in-escrow.rb +1 -0
- data/snippets/merchant-payable-account-fetch.rb +2 -0
- data/snippets/order-amount-escrowed.rb +3 -0
- data/snippets/order-bank-account-create.rb +8 -0
- data/snippets/order-create.rb +1 -0
- data/snippets/order-credit-marketplace.rb +5 -0
- data/snippets/order-credit-merchant-payable-account.rb +4 -0
- data/snippets/order-credit.rb +4 -0
- data/snippets/order-credits-fetch.rb +1 -0
- data/snippets/order-debit.rb +4 -0
- data/snippets/order-debits-fetch.rb +1 -0
- data/snippets/order-fetch.rb +1 -0
- data/snippets/order-update.rb +5 -0
- data/snippets/refund-create.rb +13 -0
- data/snippets/reversal-create.rb +13 -0
- data/snippets/settlement-create.rb +5 -0
- data/spec/balanced/resources/account_spec.rb +265 -0
- data/spec/balanced/resources/card_spec.rb +6 -6
- metadata +86 -2
@@ -0,0 +1,9 @@
|
|
1
|
+
# card_href is the stored href for the Card
|
2
|
+
# order_href is the stored href for the Order
|
3
|
+
card = Balanced::Card.fetch(card_href)
|
4
|
+
card.credit(
|
5
|
+
:amount => 5000,
|
6
|
+
:appears_on_statement_as => 'Some text',
|
7
|
+
:description => 'Some descriptive text for the debit in the dashboard',
|
8
|
+
:order => order_href
|
9
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# card_href is the stored href for the Card
|
2
|
+
# order_href is the stored href for the Order
|
3
|
+
card = Balanced::Card.fetch(card_href)
|
4
|
+
card.debit(
|
5
|
+
:amount => 5000,
|
6
|
+
:appears_on_statement_as => 'Statement text',
|
7
|
+
:description => 'Some descriptive text for the debit in the dashboard',
|
8
|
+
:order => order_href
|
9
|
+
)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
buyer = Balanced::Customer.new(
|
2
|
+
:name => 'John Buyer'
|
3
|
+
).save
|
4
|
+
|
5
|
+
card = Balanced::Card.new(
|
6
|
+
:number => '5105105105105100',
|
7
|
+
:expiration_month => '12',
|
8
|
+
:expiration_year => '2020',
|
9
|
+
:cvv => '123',
|
10
|
+
:name => 'John Buyer'
|
11
|
+
).save
|
12
|
+
|
13
|
+
card.associate_to_customer(buyer)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# bank_account_href is the stored href for the BankAccount
|
2
|
+
# order_href is the stored href for the Order
|
3
|
+
bank_account = Balanced::BankAccount.fetch(bank_account_href)
|
4
|
+
credit = bank_account.credit(
|
5
|
+
:amount => 100000,
|
6
|
+
:description => 'Payout for order #1111',
|
7
|
+
:order => order_href
|
8
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
credit = Balanced::Credit.fetch(credit_href)
|
@@ -0,0 +1 @@
|
|
1
|
+
credit.reverse
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# bank_account_href is the stored href for the BankAccount
|
2
|
+
# order_href is the stored href for the Order
|
3
|
+
bank_account = Balanced::BankAccount.fetch(bank_account_href)
|
4
|
+
credit = bank_account.credit(
|
5
|
+
:amount => 100000,
|
6
|
+
:description => 'Payout for order #1111',
|
7
|
+
:appears_on_statement_as => 'GoodCo #1111',
|
8
|
+
:order => order_href
|
9
|
+
)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# bank_account_href_a is the stored href for the BankAccount for Person A
|
2
|
+
bank_account_person_a = Balanced::BankAccount.fetch(bank_account_href_a)
|
3
|
+
credit = bank_account_person_a.credit(
|
4
|
+
:amount => 50000,
|
5
|
+
:description => 'Payout for order #1111'
|
6
|
+
)
|
7
|
+
|
8
|
+
# bank_account_href_b is the stored href for the BankAccount for Person B
|
9
|
+
bank_account_person_b = Balanced::BankAccount.fetch(bank_account_href_b)
|
10
|
+
credit = bank_account_person_b.credit(
|
11
|
+
:amount => 50000,
|
12
|
+
:description => 'Payout for order #1111'
|
13
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
debit = Balanced::Debit.fetch(debit_href)
|
@@ -0,0 +1 @@
|
|
1
|
+
debit.refund
|
@@ -0,0 +1 @@
|
|
1
|
+
disputes = Balanced::Dispute.all
|
data/snippets/example.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'balanced'
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Marketplace.mine.in_escrow
|
@@ -0,0 +1 @@
|
|
1
|
+
order = merchant.create_order
|
@@ -0,0 +1 @@
|
|
1
|
+
order.credits # instance of Balanced::Pager. Lazily iterate as an array.
|
@@ -0,0 +1 @@
|
|
1
|
+
order.debits # instance of Balanced::Pager. Lazily iterate as an array.
|
@@ -0,0 +1 @@
|
|
1
|
+
order = Balanced::Order.fetch(order_href)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# debit_href is the stored href for the Debit
|
2
|
+
# order_href is the stored href for the Order
|
3
|
+
debit = Balanced::Debit.fetch(debit_href)
|
4
|
+
debit.refund(
|
5
|
+
:amount => 3000,
|
6
|
+
:description => 'Refund for Order #1111',
|
7
|
+
:meta => {
|
8
|
+
'merchant.feedback' => 'positive',
|
9
|
+
'fulfillment.item.condition' => 'OK',
|
10
|
+
'user.refund_reason' => 'not happy with product'
|
11
|
+
},
|
12
|
+
:order => order_href
|
13
|
+
)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# credit_href is the stored href for the Credit
|
2
|
+
# order_href is the stored href for the Order
|
3
|
+
credit = Balanced::Credit.fetch(credit_href)
|
4
|
+
reversal = credit.reverse(
|
5
|
+
:amount => 100000,
|
6
|
+
:description => 'Reversal for Order #1111',
|
7
|
+
:meta => {
|
8
|
+
'merchant.feedback' => 'positive',
|
9
|
+
'fulfillment.item.condition' => 'OK',
|
10
|
+
'user.refund_reason' => 'not happy with product'
|
11
|
+
},
|
12
|
+
:order => order_href
|
13
|
+
)
|
@@ -0,0 +1,265 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Balanced::Account, :vcr, :marketplace => true do
|
4
|
+
|
5
|
+
describe 'credit funds from order to account' do
|
6
|
+
before do
|
7
|
+
# create seller
|
8
|
+
@merchant = Balanced::Customer.new(
|
9
|
+
:name => 'Henry Ford',
|
10
|
+
:dob_month => 7,
|
11
|
+
:dob_year => 1963,
|
12
|
+
:address => {
|
13
|
+
:postal_code => '48120'
|
14
|
+
}
|
15
|
+
).save
|
16
|
+
|
17
|
+
# create buyer
|
18
|
+
buyer = Balanced::Customer.new(
|
19
|
+
:name => 'John Buyer'
|
20
|
+
).save
|
21
|
+
@card = buyer.cards.create(
|
22
|
+
:number => '5105105105105100',
|
23
|
+
:expiration_month => '12',
|
24
|
+
:expiration_year => '2020',
|
25
|
+
:cvv => '123'
|
26
|
+
)
|
27
|
+
|
28
|
+
# create order
|
29
|
+
@order = @merchant.create_order
|
30
|
+
|
31
|
+
# set amount for debit
|
32
|
+
@amount = 10000
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should increase an account balance when credited' do
|
36
|
+
@order.debit_from(
|
37
|
+
:source => @card,
|
38
|
+
:amount => @amount
|
39
|
+
)
|
40
|
+
|
41
|
+
account_credit = @merchant.payable_account.credit(
|
42
|
+
:amount => @amount,
|
43
|
+
:order => @order
|
44
|
+
)
|
45
|
+
|
46
|
+
@merchant.payable_account.balance.should eq @amount
|
47
|
+
account_credit.status.should eq 'succeeded'
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "settling an account" do
|
53
|
+
before do
|
54
|
+
# create seller
|
55
|
+
@merchant = Balanced::Customer.new(
|
56
|
+
:name => 'Henry Ford',
|
57
|
+
:dob_month => 7,
|
58
|
+
:dob_year => 1963,
|
59
|
+
:address => {
|
60
|
+
:postal_code => '48120'
|
61
|
+
}
|
62
|
+
).save
|
63
|
+
@bank_account = @merchant.bank_accounts.create(
|
64
|
+
:name => 'William Henry Cavendish III',
|
65
|
+
:routing_number => '321174851',
|
66
|
+
:account_number => '0987654321',
|
67
|
+
:type => 'checking'
|
68
|
+
)
|
69
|
+
@bank_account.associate_to_customer(@merchant)
|
70
|
+
|
71
|
+
# create buyer
|
72
|
+
buyer = Balanced::Customer.new(
|
73
|
+
:name => 'John Buyer'
|
74
|
+
).save
|
75
|
+
@card = buyer.cards.create(
|
76
|
+
:number => '5105105105105100',
|
77
|
+
:expiration_month => '12',
|
78
|
+
:expiration_year => '2020',
|
79
|
+
:cvv => '123'
|
80
|
+
)
|
81
|
+
|
82
|
+
# create order
|
83
|
+
@order = @merchant.create_order
|
84
|
+
|
85
|
+
# set amount for debit
|
86
|
+
@amount = 10000
|
87
|
+
|
88
|
+
# debit into the order
|
89
|
+
debit = @order.debit_from(
|
90
|
+
:source => @card,
|
91
|
+
:amount => @amount
|
92
|
+
)
|
93
|
+
|
94
|
+
# credit the account
|
95
|
+
account_credit = @merchant.payable_account.credit(
|
96
|
+
:amount => @amount,
|
97
|
+
:order => @order
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'reduces the account balance to zero' do
|
102
|
+
# settle the account
|
103
|
+
settlement = @merchant.payable_account.settle(
|
104
|
+
:funding_instrument => @bank_account,
|
105
|
+
:appears_on_statement_as => "Settlement Oct",
|
106
|
+
:description => "Settlement for payouts from October"
|
107
|
+
)
|
108
|
+
|
109
|
+
settlement.amount.should eq @amount
|
110
|
+
settlement.appears_on_statement_as.should eq "BAL*Settlement Oct"
|
111
|
+
settlement.description.should eq "Settlement for payouts from October"
|
112
|
+
@merchant.payable_account.balance.should eq 0
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe 'reversing a settlement' do
|
117
|
+
before do
|
118
|
+
# create seller
|
119
|
+
@merchant = Balanced::Customer.new(
|
120
|
+
:name => 'Henry Ford',
|
121
|
+
:dob_month => 7,
|
122
|
+
:dob_year => 1963,
|
123
|
+
:address => {
|
124
|
+
:postal_code => '48120'
|
125
|
+
}
|
126
|
+
).save
|
127
|
+
@bank_account = @merchant.bank_accounts.create(
|
128
|
+
:name => 'William Henry Cavendish III',
|
129
|
+
:routing_number => '321174851',
|
130
|
+
:account_number => '0987654321',
|
131
|
+
:type => 'checking'
|
132
|
+
)
|
133
|
+
@bank_account.associate_to_customer(@merchant)
|
134
|
+
|
135
|
+
# create buyer
|
136
|
+
buyer = Balanced::Customer.new(
|
137
|
+
:name => 'John Buyer'
|
138
|
+
).save
|
139
|
+
@card = buyer.cards.create(
|
140
|
+
:number => '5105105105105100',
|
141
|
+
:expiration_month => '12',
|
142
|
+
:expiration_year => '2020',
|
143
|
+
:cvv => '123'
|
144
|
+
)
|
145
|
+
|
146
|
+
# create order
|
147
|
+
@order = @merchant.create_order
|
148
|
+
|
149
|
+
# set amount for debit
|
150
|
+
@amount = 10000
|
151
|
+
|
152
|
+
# debit into the order
|
153
|
+
@order.debit_from(
|
154
|
+
:source => @card,
|
155
|
+
:amount => @amount
|
156
|
+
)
|
157
|
+
|
158
|
+
# credit the account
|
159
|
+
@account_credit = @merchant.payable_account.credit(
|
160
|
+
:amount => @amount,
|
161
|
+
:order => @order
|
162
|
+
)
|
163
|
+
|
164
|
+
# settle the account
|
165
|
+
@settlement = @merchant.payable_account.settle(
|
166
|
+
:funding_instrument => @bank_account.href,
|
167
|
+
:appears_on_statement_as => "Settlement Oct",
|
168
|
+
:description => "Settlement for payouts from October"
|
169
|
+
)
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'credit should be reversible when account has pending balance' do
|
173
|
+
order_two = @merchant.create_order
|
174
|
+
order_two.debit_from(
|
175
|
+
:source => @card,
|
176
|
+
:amount => @amount
|
177
|
+
)
|
178
|
+
|
179
|
+
credit = @merchant.payable_account.credit(
|
180
|
+
:amount => @amount,
|
181
|
+
:order => order_two
|
182
|
+
)
|
183
|
+
@merchant.payable_account.balance.should eq @amount
|
184
|
+
|
185
|
+
credit.reverse(:amount => @amount)
|
186
|
+
|
187
|
+
#@payable_account.reload
|
188
|
+
@merchant.payable_account.balance.should eq 0
|
189
|
+
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe 'settling an account with an negative balance' do
|
194
|
+
before do
|
195
|
+
|
196
|
+
# create seller
|
197
|
+
@merchant = Balanced::Customer.new(
|
198
|
+
:name => 'Henry Ford',
|
199
|
+
:dob_month => 7,
|
200
|
+
:dob_year => 1963,
|
201
|
+
:address => {
|
202
|
+
:postal_code => '48120'
|
203
|
+
}
|
204
|
+
).save
|
205
|
+
@bank_account = @merchant.bank_accounts.create(
|
206
|
+
:name => 'William Henry Cavendish III',
|
207
|
+
:routing_number => '321174851',
|
208
|
+
:account_number => '0987654321',
|
209
|
+
:type => 'checking'
|
210
|
+
)
|
211
|
+
@bank_account.associate_to_customer(@merchant)
|
212
|
+
|
213
|
+
# create buyer
|
214
|
+
buyer = Balanced::Customer.new(
|
215
|
+
:name => 'John Buyer'
|
216
|
+
).save
|
217
|
+
@card = buyer.cards.create(
|
218
|
+
:number => '5105105105105100',
|
219
|
+
:expiration_month => '12',
|
220
|
+
:expiration_year => '2020',
|
221
|
+
:cvv => '123'
|
222
|
+
)
|
223
|
+
|
224
|
+
# create order
|
225
|
+
@order = @merchant.create_order
|
226
|
+
|
227
|
+
# set amount for debit
|
228
|
+
@amount = 10000
|
229
|
+
|
230
|
+
# debit into the order
|
231
|
+
@order.debit_from(
|
232
|
+
:source => @card,
|
233
|
+
:amount => @amount
|
234
|
+
)
|
235
|
+
|
236
|
+
# credit the account
|
237
|
+
@account_credit = @merchant.payable_account.credit(
|
238
|
+
:amount => @amount,
|
239
|
+
:order => @order
|
240
|
+
)
|
241
|
+
|
242
|
+
# settle the account
|
243
|
+
@settlement = @merchant.payable_account.settle(
|
244
|
+
:funding_instrument => @bank_account,
|
245
|
+
:appears_on_statement_as => "BAL*Settlement Oct",
|
246
|
+
:description => "Settlement for payouts from October"
|
247
|
+
)
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'should create reversal and refund' do
|
251
|
+
@account_credit.reverse(:amount => @amount)
|
252
|
+
|
253
|
+
@merchant.payable_account.reload
|
254
|
+
@merchant.payable_account.balance.should eq -@amount
|
255
|
+
|
256
|
+
@settlement = @merchant.payable_account.settle(
|
257
|
+
:funding_instrument => @bank_account,
|
258
|
+
:appears_on_statement_as => "Reverse Settlement Oct",
|
259
|
+
:description => "Settlement for payouts from October"
|
260
|
+
)
|
261
|
+
|
262
|
+
@merchant.payable_account.balance.should eq 0
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|