Rename Payments to PaymentOrders

This commit is contained in:
Maciej Szlosarczyk 2018-04-30 09:30:34 +03:00
parent a1bbdc0d8e
commit d92004cbe0
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
9 changed files with 20 additions and 20 deletions

View file

@ -17,14 +17,14 @@ class Registrar
bank, invoice_id: invoice
)
}
@payment = ::Payments.create_with_type(bank, invoice, opts)
@payment = ::PaymentOrders.create_with_type(bank, invoice, opts)
@payment.create_transaction
end
def back
invoice = Invoice.find(params[:invoice_id])
opts = { response: params }
@payment = ::Payments.create_with_type(params[:bank], invoice, opts)
@payment = ::PaymentOrders.create_with_type(params[:bank], invoice, opts)
if @payment.valid_response_from_intermediary? && @payment.settled_payment?
@payment.complete_transaction
@ -42,7 +42,7 @@ class Registrar
def callback
invoice = Invoice.find(params[:invoice_id])
opts = { response: params }
@payment = ::Payments.create_with_type(params[:bank], invoice, opts)
@payment = ::PaymentOrders.create_with_type(params[:bank], invoice, opts)
if @payment.valid_response_from_intermediary? && @payment.settled_payment?
@payment.complete_transaction
@ -60,7 +60,7 @@ class Registrar
def supported_payment_method?
Payments::PAYMENT_METHODS.include?(params[:bank])
PaymentOrders::PAYMENT_METHODS.include?(params[:bank])
end
end
end

View file

@ -1,4 +1,4 @@
module Payments
module PaymentOrders
PAYMENT_INTERMEDIARIES = ENV['payments_intermediaries'].to_s.strip.split(', ').freeze
PAYMENT_BANKLINK_BANKS = ENV['payments_banks'].to_s.strip.split(', ').freeze
PAYMENT_METHODS = [PAYMENT_INTERMEDIARIES, PAYMENT_BANKLINK_BANKS].flatten.freeze

View file

@ -1,4 +1,4 @@
module Payments
module PaymentOrders
class BankLink < Base
BANK_LINK_VERSION = '008'

View file

@ -1,4 +1,4 @@
module Payments
module PaymentOrders
class Base
include ActionView::Helpers::NumberHelper

View file

@ -1,4 +1,4 @@
module Payments
module PaymentOrders
class EveryPay < Base
USER = ENV['payments_every_pay_api_user'].freeze
KEY = ENV['payments_every_pay_api_key'].freeze

View file

@ -17,4 +17,4 @@
- if !@invoice.cancelled? && !@invoice.binded?
.row.semifooter
.col-md-6-offset-6.text-right= render 'registrar/invoices/partials/banklinks', locals: { payment_channels: Payments::PAYMENT_METHODS }
.col-md-6-offset-6.text-right= render 'registrar/invoices/partials/banklinks', locals: { payment_channels: PaymentOrders::PAYMENT_METHODS }

View file

@ -47,7 +47,7 @@ class BankLinkTest < ActiveSupport::TestCase
'VK_LANG': 'ENG'
}.with_indifferent_access
@completed_bank_link = Payments::BankLink.new(
@completed_bank_link = PaymentOrders::BankLink.new(
'seb', @invoice, { response: params }
)
end
@ -66,14 +66,14 @@ class BankLinkTest < ActiveSupport::TestCase
'VK_LANG': 'ENG'
}.with_indifferent_access
@cancelled_bank_link = Payments::BankLink.new(
@cancelled_bank_link = PaymentOrders::BankLink.new(
'seb', @invoice, { response: params }
)
end
def create_new_bank_link
params = { return_url: 'return.url', response_url: 'response.url' }
@new_bank_link = Payments::BankLink.new('seb', @invoice, params)
@new_bank_link = PaymentOrders::BankLink.new('seb', @invoice, params)
end
def test_response_is_not_valid_when_it_is_missing

View file

@ -35,8 +35,8 @@ class EveryPayTest < ActiveSupport::TestCase
invoice_id: '1',
},
}
@every_pay = Payments::EveryPay.new('every_pay', @invoice, params)
@other_pay = Payments::EveryPay.new('every_pay', @invoice, {})
@every_pay = PaymentOrders::EveryPay.new('every_pay', @invoice, params)
@other_pay = PaymentOrders::EveryPay.new('every_pay', @invoice, {})
travel_to Time.zone.parse('2018-04-01 00:30:00 +0000')
end
@ -69,7 +69,7 @@ class EveryPayTest < ActiveSupport::TestCase
def test_settled_payment?
assert(@every_pay.settled_payment?)
other_pay = Payments::EveryPay.new(
other_pay = PaymentOrders::EveryPay.new(
'every_pay', @invoice, {response: {payment_state: 'CANCELLED'}}
)
refute(other_pay.settled_payment?)

View file

@ -1,6 +1,6 @@
require 'test_helper'
class PaymentTest < ActiveSupport::TestCase
class PaymentOrdersTest < ActiveSupport::TestCase
def setup
super
@ -8,7 +8,7 @@ class PaymentTest < ActiveSupport::TestCase
@original_seb_URL = ENV['seb_payment_url']
ENV['payment_methods'] = 'seb, swed, credit_card'
ENV['seb_payment_url'] = nil
@not_implemented_payment = Payments::Base.new(
@not_implemented_payment = PaymentOrders::Base.new(
'not_implemented', Invoice.new
)
end
@ -47,12 +47,12 @@ class PaymentTest < ActiveSupport::TestCase
def test_that_create_with_type_raises_argument_error
assert_raise ArgumentError do
Payments.create_with_type("not_implemented", Invoice.new)
PaymentOrders.create_with_type("not_implemented", Invoice.new)
end
end
def test_create_with_correct_subclass
payment = Payments.create_with_type('seb', Invoice.new)
assert_equal Payments::BankLink, payment.class
payment = PaymentOrders.create_with_type('seb', Invoice.new)
assert_equal PaymentOrders::BankLink, payment.class
end
end