class ECpayInvoice::NotifyClientECPay
Public Class Methods
new()
click to toggle source
# File lib/ecpay_invoice/notify_client.rb, line 23 def initialize @helper = APIHelper.new end
Public Instance Methods
ecpay_invoice_notify(param)
click to toggle source
# File lib/ecpay_invoice/notify_client.rb, line 27 def ecpay_invoice_notify(param) notify_base_proc!(params: param) unix_time = get_curr_unix_time() - 120 param['TimeStamp'] = unix_time.to_s p param['TimeStamp'] res = notify_pos_proc!(params: param, apiname: 'InvoiceNotify') return res end
Private Instance Methods
get_curr_unix_time()
click to toggle source
Private method definition start ###
# File lib/ecpay_invoice/notify_client.rb, line 39 def get_curr_unix_time() return Time.now.to_i end
notify_base_proc!(params:)
click to toggle source
# File lib/ecpay_invoice/notify_client.rb, line 43 def notify_base_proc!(params:) if params.is_a?(Hash) # Transform param key to string params.stringify_keys() params['MerchantID'] = @helper.get_mercid else raise ECpayInvalidParam, "Recieved parameter object must be a Hash" end end
notify_pos_proc!(params:, apiname:)
click to toggle source
# File lib/ecpay_invoice/notify_client.rb, line 55 def notify_pos_proc!(params:, apiname:) verify_query_api = ECpayInvoice::NotifyParamVerify.new(apiname) verify_query_api.verify_notify_param(params) #encode special param sp_param = verify_query_api.get_special_encode_param(apiname) @helper.encode_special_param!(params, sp_param) # Insert chkmacval chkmac = @helper.gen_chk_mac_value(params, mode: 0) params['CheckMacValue'] = chkmac params['NotifyMail'] = CGI::unescape(params['NotifyMail']) p params # gen post html api_url = verify_query_api.get_svc_url(apiname, @helper.get_op_mode) #post from server resp = @helper.http_request(method: 'POST', url: api_url, payload: params) # return post response return resp end