Class: ECpayPayment::ECpayPaymentClient

Inherits:
Object
  • Object
show all
Includes:
ECpayErrorDefinition
Defined in:
lib/ecpay_payment/payment_client.rb

Instance Method Summary collapse

Constructor Details

#initializeECpayPaymentClient

Returns a new instance of ECpayPaymentClient.



22
23
24
25
26
# File 'lib/ecpay_payment/payment_client.rb', line 22

def initialize
  @helper = APIHelper.new
  @verify_aiochkout = ECpayPayment::AioCheckOutParamVerify.new

end

Instance Method Details

#aio_check_out_all(params:, invoice: {}) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/ecpay_payment/payment_client.rb', line 28

def aio_check_out_all(params:, invoice:{})
  unsupport = []
  aiochkout_base_proc!(params: params, invoice: invoice, unsupport_param: unsupport, pay_method: 'ALL')
  # handle Ignore Payment
  params['IgnorePayment'] = @helper.get_ignore_pay.join('#')
  html = aiochkout_pos_proc!(params: params)
  return html

end

#aio_check_out_applepay(params:, invoice: {}) ⇒ Object



45
46
47
48
49
50
# File 'lib/ecpay_payment/payment_client.rb', line 45

def aio_check_out_applepay(params:, invoice:{})
  unsupport = ['HoldTradeAMT', 'IgnorePayment']
  aiochkout_base_proc!(params: params, invoice: invoice, unsupport_param: unsupport, pay_method: 'ApplePay')
  html = aiochkout_pos_proc!(params: params)
  return html
end

#aio_check_out_atm(params:, url_return_payinfo: '', exp_period: '', client_redirect: '', invoice: {}) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/ecpay_payment/payment_client.rb', line 88

def aio_check_out_atm(params:, url_return_payinfo:'', exp_period:'', client_redirect:'', invoice:{})
  unsupport = ['IgnorePayment']
  aiochkout_base_proc!(params: params, invoice: invoice, unsupport_param: unsupport, pay_method: 'ATM')
  if exp_period == ''
    params.delete('ExpireDate')
  else
    params['ExpireDate'] = exp_period
  end
			if client_redirect == ''
    params.delete('ClientRedirectURL')
			else
params['ClientRedirectURL'] = client_redirect
  end
			if url_return_payinfo == ''
    params.delete('PaymentInfoURL')
			else
params['PaymentInfoURL'] = url_return_payinfo
  end
  html = aiochkout_pos_proc!(params: params)
  return html
end

#aio_check_out_barcode(barcode_info:, params:, invoice: {}, client_redirect_url: '') ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/ecpay_payment/payment_client.rb', line 139

def aio_check_out_barcode(barcode_info:, params:, invoice:{}, client_redirect_url:'')
  unsupport = ['IgnorePayment']
  aiochkout_base_proc!(params: params, invoice: invoice, unsupport_param: unsupport, pay_method: 'BARCODE')
  if barcode_info.is_a?(Hash)
    barcode_args = ['StoreExpireDate', 'Desc_1', 'Desc_2', 'Desc_3', 'Desc_4', 'PaymentInfoURL']
    if barcode_info.keys.sort() == barcode_args.sort()
      params.merge!(barcode_info)
      if client_redirect_url == '' or client_redirect_url.nil?
        params.delete('ClientRedirectURL')
      else
        params['ClientRedirectURL'] = client_redirect_url
      end
      html = aiochkout_pos_proc!(params: params)
      return html
    else
      raise "BARCODE info keys must match #{barcode_args}."
    end
  else
    raise "Recieved barcode_info argument must be a Hash."
  end
end

#aio_check_out_credit_divide(params:, invoice: {}, installment:) ⇒ Object

2019/09/30暫時關閉GooglePay付款方式 def aio_check_out_googlepay(params:, invoice:{})

unsupport = ['HoldTradeAMT', 'IgnorePayment']
aiochkout_base_proc!(params: params, invoice: invoice, unsupport_param: unsupport, pay_method: 'GooglePay')
html = aiochkout_pos_proc!(params: params)
return html

end



59
60
61
62
63
64
65
# File 'lib/ecpay_payment/payment_client.rb', line 59

def aio_check_out_credit_divide(params:, invoice:{}, installment: )
  unsupport = ['HoldTradeAMT', 'IgnorePayment', 'Redeem', 'PeriodAmount', 'PeriodType', 'Frequency', 'ExecTimes', 'PeriodReturnURL']
  aiochkout_base_proc!(params: params, invoice: invoice, unsupport_param: unsupport, pay_method: 'Credit')
  params['CreditInstallment'] = installment
  html = aiochkout_pos_proc!(params: params)
  return html
end

#aio_check_out_credit_onetime(params:, invoice: {}) ⇒ Object



38
39
40
41
42
43
# File 'lib/ecpay_payment/payment_client.rb', line 38

def aio_check_out_credit_onetime(params:, invoice:{})
  unsupport = ['HoldTradeAMT', 'IgnorePayment']
  aiochkout_base_proc!(params: params, invoice: invoice, unsupport_param: unsupport, pay_method: 'Credit')
  html = aiochkout_pos_proc!(params: params)
  return html
end

#aio_check_out_credit_period(period_info:, params:, invoice: {}) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/ecpay_payment/payment_client.rb', line 67

def aio_check_out_credit_period(period_info:, params:, invoice:{})
  # 'PeriodAmount', 'PeriodType', 'Frequency', 'ExecTimes', 'PeriodReturnURL'
  unsupport = ['HoldTradeAMT', 'IgnorePayment', 'Redeem', 'CreditInstallment', 'InstallmentAmount']
  aiochkout_base_proc!(params: params, invoice: invoice, unsupport_param: unsupport, pay_method: 'Credit')
  if period_info.is_a?(Hash)
    period_args = ['PeriodAmount', 'PeriodType', 'Frequency', 'ExecTimes', 'PeriodReturnURL']
    if period_info.keys.sort() == period_args.sort()
      params.merge!(period_info)
      # Add total amount protection!!!

      html = aiochkout_pos_proc!(params: params)
      return html
    else
      raise "Credit card period parameters must be #{period_args}."
    end
  else
    raise "Recieved period_info argument must be a Hash."
  end

end

#aio_check_out_cvs(cvs_info:, params:, invoice: {}, client_redirect_url: '') ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/ecpay_payment/payment_client.rb', line 117

def aio_check_out_cvs(cvs_info:, params:, invoice:{}, client_redirect_url:'')
  unsupport = ['IgnorePayment']
  aiochkout_base_proc!(params: params, invoice: invoice, unsupport_param: unsupport, pay_method: 'CVS')
  if cvs_info.is_a?(Hash)
    cvs_args = ['StoreExpireDate', 'Desc_1', 'Desc_2', 'Desc_3', 'Desc_4', 'PaymentInfoURL']
    if cvs_info.keys.sort() == cvs_args.sort()
      params.merge!(cvs_info)
      if client_redirect_url == '' or client_redirect_url.nil?
        params.delete('ClientRedirectURL')
      else
        params['ClientRedirectURL'] = client_redirect_url
      end
      html = aiochkout_pos_proc!(params: params)
      return html
    else
      raise "CVS info keys must match #{cvs_args}."
    end
  else
    raise "Recieved cvs_info argument must be a Hash."
  end
end

#aio_check_out_webatm(params:, invoice: {}) ⇒ Object



110
111
112
113
114
115
# File 'lib/ecpay_payment/payment_client.rb', line 110

def aio_check_out_webatm(params:, invoice:{})
  unsupport = ['IgnorePayment']
  aiochkout_base_proc!(params: params, invoice: invoice, unsupport_param: unsupport, pay_method: 'WebATM')
  html = aiochkout_pos_proc!(params: params)
  return html
end