mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 06:26:15 +02:00
creating sync with billing
This commit is contained in:
parent
162647acba
commit
0a4444b556
9 changed files with 577 additions and 60 deletions
|
@ -9,10 +9,7 @@ class PaymentStatusTest < ApplicationIntegrationTest
|
|||
Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
|
||||
end
|
||||
|
||||
def shoudl_update_buyer_balance
|
||||
assert @invoice.paid?
|
||||
assert_equal @invoice.buyer.balance.to_f, 100.0
|
||||
|
||||
test 'should mark an invoice as paid' do
|
||||
payload = {
|
||||
payment_state: 'settled',
|
||||
order_reference: @unpaid.number,
|
||||
|
@ -20,13 +17,57 @@ class PaymentStatusTest < ApplicationIntegrationTest
|
|||
transaction_time: Time.zone.now,
|
||||
}
|
||||
|
||||
put eis_billing_payment_status_path, params: payload
|
||||
item = @unpaid.items.first
|
||||
|
||||
@invoice.reload
|
||||
@invoice.buyer.reload
|
||||
@registrar.reload
|
||||
refute @unpaid.paid?
|
||||
assert_equal @unpaid.buyer.balance.to_f, 100.0
|
||||
assert_equal item.price, 5.0
|
||||
|
||||
put eis_billing_payment_status_path, params: payload
|
||||
@unpaid.reload
|
||||
assert_equal @unpaid.buyer.balance.to_f, 105.0
|
||||
end
|
||||
|
||||
test 'ignore additonal callbacks if invoice is already paid' do
|
||||
payload = {
|
||||
payment_state: 'settled',
|
||||
order_reference: @unpaid.number,
|
||||
standing_amount: @unpaid.total,
|
||||
transaction_time: Time.zone.now,
|
||||
}
|
||||
|
||||
item = @unpaid.items.first
|
||||
|
||||
refute @unpaid.paid?
|
||||
assert_equal @unpaid.buyer.balance.to_f, 100.0
|
||||
assert_equal item.price, 5.0
|
||||
|
||||
put eis_billing_payment_status_path, params: payload
|
||||
@unpaid.reload
|
||||
assert_equal @unpaid.buyer.balance.to_f, 105.0
|
||||
assert @unpaid.paid?
|
||||
|
||||
put eis_billing_payment_status_path, params: payload
|
||||
@unpaid.reload
|
||||
|
||||
assert_equal @unpaid.buyer.balance.to_f, 105.0
|
||||
assert @unpaid.paid?
|
||||
end
|
||||
|
||||
test 'send callback to already paid invoice' do
|
||||
payload = {
|
||||
payment_state: 'settled',
|
||||
order_reference: @invoice.number,
|
||||
standing_amount: @invoice.total,
|
||||
transaction_time: Time.zone.now,
|
||||
}
|
||||
|
||||
assert @invoice.paid?
|
||||
assert_equal @invoice.buyer.balance.to_f, 100.0
|
||||
|
||||
put eis_billing_payment_status_path, params: payload
|
||||
@invoice.reload
|
||||
assert_equal @invoice.buyer.balance.to_f, 100.0
|
||||
assert @invoice.paid?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue