This commit is contained in:
Zoey
2019-07-22 15:57:33 +06:30
parent 931df461b5
commit 1a11b9e2e7
2 changed files with 11 additions and 2 deletions

View File

@@ -115,7 +115,7 @@ class Origami::PaymentsController < BaseOrigamiController
sale_payment = SalePayment.new
sale_payment.process_kbz_payment(sale_id, sale_data.grand_total, 0, 'pending')
status, qr = KbzPay.pay(sale_data.grand_total, sale_payment.sale_payment_id, kbz_pay_method.gateway_url, kbz_pay_method.auth_token, kbz_pay_method.merchant_account_id, kbz_pay_method.additional_parameters)
status, qr = KbzPay.pay(sale_data.grand_total.to_i, sale_payment.sale_payment_id, kbz_pay_method.gateway_url, kbz_pay_method.auth_token, kbz_pay_method.merchant_account_id, kbz_pay_method.additional_parameters)
end
end

View File

@@ -3,6 +3,9 @@ class KbzPay
KBZ_PAY = 'KBZPay'
def self.pay(amount, receipt_no, url, key, app_id, code)
shop = Shop.first
prefix = shop.shop_code
receipt_no = "#{prefix}#{receipt_no}"
datetime = DateTime.now.strftime("%d%m%Y%H%M")
kbz_app_id = app_id
@@ -46,18 +49,22 @@ class KbzPay
:headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
)
Rails.logger.info result
Rails.logger.info '===================================='
if result['Response']['result'] == "SUCCESS"
#TODO QR return
qr = result['Response']['qrCode']
return true, qr
else
# Rails.logger.debug result['Response']
return false, result['Response']
puts result['Response']
end
end
def self.query(receipt_no, current_user, url, key, app_id, code)
shop = Shop.first
prefix = shop.shop_code
receipt_no = "#{prefix}#{receipt_no}"
amount = 0
datetime = DateTime.now.strftime("%d%m%Y%H%M")
kbz_app_id = app_id
@@ -101,6 +108,8 @@ class KbzPay
merch_order_id = result['Response']['merch_order_id']
cash = result['Response']['total_amount']
merch_order_id.slice! "#{prefix}"
sp = SalePayment.find(merch_order_id)
if !sp.nil?
if sp.payment_status == 'pending'