fix creditentail to be dynamic
This commit is contained in:
@@ -5,24 +5,29 @@ class KbzMerchant
|
||||
|
||||
def initialize(payment_method)
|
||||
@payment_method = payment_method
|
||||
@url = @payment_method.gateway_url
|
||||
json_params = @payment_method.additional_parameters.inspect.undump
|
||||
params = JSON.parse(json_params)
|
||||
@notify_url = params['notify_url']
|
||||
@app_id = params['app_id']
|
||||
end
|
||||
|
||||
def create_order(amount:, merch_order_id:, timeout: '120m')
|
||||
api_url = 'http://api.kbzpay.com/payment/gateway/uat/precreate'
|
||||
api_url = "#{@url}/precreate"
|
||||
payload = build_create_payload(amount, merch_order_id, timeout)
|
||||
response = send_request(payload, api_url)
|
||||
handle_response(response)
|
||||
end
|
||||
|
||||
def close_order(merch_order_id:)
|
||||
api_url ='http://api.kbzpay.com/payment/gateway/uat/closeorder'
|
||||
api_url = "#{@url}/closeorder"
|
||||
payload = build_close_payload(merch_order_id)
|
||||
response = send_request(payload, api_url)
|
||||
handle_response(response)
|
||||
end
|
||||
|
||||
def query_order(merch_order_id:)
|
||||
api_url = 'http://api.kbzpay.com/payment/gateway/uat/queryorder'
|
||||
api_url = "#{@url}/queryorder"
|
||||
payload = build_query_payload(merch_order_id)
|
||||
response = send_request(payload, api_url)
|
||||
handle_response(response)
|
||||
@@ -31,18 +36,15 @@ class KbzMerchant
|
||||
private
|
||||
|
||||
def build_create_payload(amount, merch_order_id, timeout)
|
||||
json_params = @payment_method.additional_parameters.inspect.undump
|
||||
params = JSON.parse(json_params)
|
||||
byebug
|
||||
base_params = {
|
||||
method: 'kbz.payment.precreate',
|
||||
timestamp: Time.now.utc.to_i.to_s,
|
||||
nonce_str: SecureRandom.hex(16),
|
||||
notify_url: params['notify_url'],
|
||||
notify_url: @notify_url,
|
||||
sign_type: 'SHA256',
|
||||
version: '1.0',
|
||||
biz_content: {
|
||||
appid: @payment_method.gateway_url,
|
||||
appid: @app_id,
|
||||
merch_code: @payment_method.merchant_account_id,
|
||||
merch_order_id: merch_order_id,
|
||||
trade_type: 'PAY_BY_QRCODE',
|
||||
@@ -64,7 +66,7 @@ class KbzMerchant
|
||||
sign_type: 'SHA256',
|
||||
version: '3.0',
|
||||
biz_content: {
|
||||
appid: @payment_method.gateway_url,
|
||||
appid: @app_id,
|
||||
merch_code: @payment_method.merchant_account_id,
|
||||
merch_order_id: merch_order_id
|
||||
}.compact
|
||||
|
||||
Reference in New Issue
Block a user