kbzpay
This commit is contained in:
@@ -6,18 +6,16 @@ class KbzPay
|
||||
|
||||
datetime = DateTime.now.strftime("%d%m%Y%H%M")
|
||||
kbz_app_id = app_id
|
||||
kbz_merch_code = code
|
||||
# kbz_app_id = "kp1e78f7efddca190042638341afb88d"
|
||||
# kbz_merch_code = "200004"
|
||||
kbz_merch_code = code
|
||||
kbz_api_key = key
|
||||
kbz_provider_url = "#{url}/precreate"
|
||||
|
||||
kbz_method = 'kbz.payment.precreate'
|
||||
kbz_trade_type = "PAY_BY_QRCODE"
|
||||
kbz_api_key = key
|
||||
# kbz_api_key = "code2lab123456"
|
||||
kbz_version = "1.0"
|
||||
kbz_provider_url = url
|
||||
# kbz_provider_url = "http://api.kbzpay.com/payment/gateway/uat/precreate"
|
||||
kbz_currency = "MMK"
|
||||
kbz_callback_url = "https://staging-v2.doemal.com/api/v3/ordering/kbz_callback"
|
||||
|
||||
nounce_str = SecureRandom.base64(32).first(32).upcase
|
||||
|
||||
params = "appid="+kbz_app_id+"&merch_code="+kbz_merch_code+"&merch_order_id="+receipt_no.to_s+"&method="+kbz_method+"&nonce_str="+nounce_str.to_s+"¬ify_url="+ kbz_callback_url + "&timeout_express=20m×tamp="+datetime+"&total_amount="+amount.to_s+"&trade_type="+kbz_trade_type+"&trans_currency="+ kbz_currency+"&version="+kbz_version+"&key="+kbz_api_key
|
||||
@@ -59,18 +57,20 @@ class KbzPay
|
||||
|
||||
end
|
||||
|
||||
def self.query(receipt_no, current_user)
|
||||
def self.query(receipt_no, current_user, url, key, app_id, code)
|
||||
amount = 0
|
||||
datetime = DateTime.now.strftime("%d%m%Y%H%M")
|
||||
kbz_app_id = "kp1e78f7efddca190042638341afb88d"
|
||||
kbz_merch_code = "200004"
|
||||
kbz_app_id = app_id
|
||||
kbz_merch_code = code
|
||||
kbz_api_key = key
|
||||
kbz_provider_url = "#{url}/queryorder"
|
||||
|
||||
kbz_method = 'kbz.payment.queryorder'
|
||||
kbz_trade_type = "APP"
|
||||
kbz_api_key = "code2lab123456"
|
||||
kbz_trade_type = "PAY_BY_QRCODE"
|
||||
kbz_version = "1.0"
|
||||
kbz_provider_url = "http://api.kbzpay.com/payment/gateway/uat/queryorder"
|
||||
kbz_currency = "MMK"
|
||||
kbz_callback_url = "https://staging-v2.doemal.com/api/v3/ordering/kbz_callback"
|
||||
|
||||
nounce_str = SecureRandom.base64(32).first(32).upcase
|
||||
|
||||
params = "appid="+kbz_app_id+"&merch_code="+kbz_merch_code+"&merch_order_id="+receipt_no.to_s+"&method="+kbz_method+"&nonce_str="+nounce_str.to_s+"×tamp="+datetime+"&version="+kbz_version+"&key="+kbz_api_key
|
||||
|
||||
@@ -31,10 +31,11 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
def self.get_kbz_pay_amount(sale_id, current_user)
|
||||
amount = 0
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last
|
||||
if !sale_payment.nil?
|
||||
if !sale_payment.nil? and !kbz_pay_method.nil?
|
||||
if sale_payment.payment_status == 'pending'
|
||||
amount = KbzPay.query(sale_payment.id, current_user)
|
||||
amount = KbzPay.query(sale_payment.id, current_user, kbz_pay_method.gateway_url, kbz_pay_method.auth_token, kbz_pay_method.merchant_account_id, kbz_pay_method.additional_parameters)
|
||||
elsif sale_payment.payment_status == 'paid'
|
||||
amount = sale_payment.payment_amount
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user