From ec8edd98c2e73a65c3589fd947a18dcf0be5c1de Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Tue, 13 Sep 2022 14:16:12 +0300 Subject: [PATCH 1/2] remove payment_link condition from the show page --- app/controllers/eis_billing/payment_status_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/eis_billing/payment_status_controller.rb b/app/controllers/eis_billing/payment_status_controller.rb index cb8e70803..4fa626e5d 100644 --- a/app/controllers/eis_billing/payment_status_controller.rb +++ b/app/controllers/eis_billing/payment_status_controller.rb @@ -5,6 +5,9 @@ module EisBilling def update payment_status = define_payment_status(params[:payment_state]) invoice = Invoice.find_by(number: params[:order_reference]) + + return if invoice.paid? + bank = create_bank_transfer(invoice: invoice, sum: params[:standing_amount], paid_at: params[:transaction_time]) create_payment_order(invoice: invoice, everypay_response: params, payment_status: payment_status) From 43c7101c04d7241de355279c224e9b9c86a5db85 Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Tue, 13 Sep 2022 14:43:16 +0300 Subject: [PATCH 2/2] added test --- .../eis_billing/payment_status_test.rb | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/integration/eis_billing/payment_status_test.rb diff --git a/test/integration/eis_billing/payment_status_test.rb b/test/integration/eis_billing/payment_status_test.rb new file mode 100644 index 000000000..69c50e120 --- /dev/null +++ b/test/integration/eis_billing/payment_status_test.rb @@ -0,0 +1,32 @@ +require 'test_helper' + +class PaymentStatusTest < ApplicationIntegrationTest + setup do + sign_in users(:api_bestnames) + @invoice = invoices(:one) + @unpaid = invoices(:unpaid) + @registrar = registrars(:bestnames) + 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 + + payload = { + payment_state: 'settled', + order_reference: @unpaid.number, + standing_amount: @unpaid.total, + transaction_time: Time.zone.now, + } + + put eis_billing_payment_status_path, params: payload + + @invoice.reload + @invoice.buyer.reload + @registrar.reload + + assert @invoice.paid? + assert_equal @invoice.buyer.balance.to_f, 100.0 + end +end