kbzpay
This commit is contained in:
@@ -115,7 +115,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
sale_payment.process_kbz_payment(sale_id, sale_data.grand_total, 0, 'pending')
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ class KbzPay
|
|||||||
KBZ_PAY = 'KBZPay'
|
KBZ_PAY = 'KBZPay'
|
||||||
|
|
||||||
def self.pay(amount, receipt_no, url, key, app_id, code)
|
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")
|
datetime = DateTime.now.strftime("%d%m%Y%H%M")
|
||||||
kbz_app_id = app_id
|
kbz_app_id = app_id
|
||||||
@@ -46,18 +49,22 @@ class KbzPay
|
|||||||
:headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
|
:headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
|
||||||
)
|
)
|
||||||
Rails.logger.info result
|
Rails.logger.info result
|
||||||
|
Rails.logger.info '===================================='
|
||||||
if result['Response']['result'] == "SUCCESS"
|
if result['Response']['result'] == "SUCCESS"
|
||||||
#TODO QR return
|
#TODO QR return
|
||||||
qr = result['Response']['qrCode']
|
qr = result['Response']['qrCode']
|
||||||
return true, qr
|
return true, qr
|
||||||
else
|
else
|
||||||
|
# Rails.logger.debug result['Response']
|
||||||
return false, result['Response']
|
return false, result['Response']
|
||||||
puts result['Response']
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.query(receipt_no, current_user, url, key, app_id, code)
|
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
|
amount = 0
|
||||||
datetime = DateTime.now.strftime("%d%m%Y%H%M")
|
datetime = DateTime.now.strftime("%d%m%Y%H%M")
|
||||||
kbz_app_id = app_id
|
kbz_app_id = app_id
|
||||||
@@ -101,6 +108,8 @@ class KbzPay
|
|||||||
merch_order_id = result['Response']['merch_order_id']
|
merch_order_id = result['Response']['merch_order_id']
|
||||||
cash = result['Response']['total_amount']
|
cash = result['Response']['total_amount']
|
||||||
|
|
||||||
|
merch_order_id.slice! "#{prefix}"
|
||||||
|
|
||||||
sp = SalePayment.find(merch_order_id)
|
sp = SalePayment.find(merch_order_id)
|
||||||
if !sp.nil?
|
if !sp.nil?
|
||||||
if sp.payment_status == 'pending'
|
if sp.payment_status == 'pending'
|
||||||
|
|||||||
Reference in New Issue
Block a user