Class: OffsitePayments::Integrations::Pay2goCvs::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/offsite_payments/integrations/pay2go_cvs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_paramsObject

Returns the value of attribute _params.



97
98
99
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 97

def _params
  @_params
end

Instance Method Details

#acknowledgeObject

TODO 使用查詢功能實作 acknowledge 而以 checksum_ok? 代替



113
114
115
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 113

def acknowledge
  checksum_ok?
end

#amtObject



155
156
157
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 155

def amt
  _params['Amt'].to_s
end

#authObject



206
207
208
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 206

def auth
  _params['Auth']
end

#barcode_1Object

barcode



253
254
255
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 253

def barcode_1
  _params['Barcode_1']
end

#barcode_2Object



257
258
259
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 257

def barcode_2
  _params['Barcode_2']
end

#barcode_3Object



261
262
263
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 261

def barcode_3
  _params['Barcode_3']
end

#calculate_checksumObject



124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 124

def calculate_checksum
  params_copy = _params.clone

  check_fields = [:"Amt", :"MerchantID", :"MerchantOrderNo", :"TradeNo"]
  raw_data = params_copy.sort.map{|field, value|
    "#{field}=#{value}" if check_fields.include?(field.to_sym)
  }.compact.join('&')

  hash_raw_data = "HashIV=#{OffsitePayments::Integrations::Pay2goCvs.hash_iv}&#{raw_data}&HashKey=#{OffsitePayments::Integrations::Pay2goCvs.hash_key}"

  sha256 = Digest::SHA256.new
  sha256.update hash_raw_data.force_encoding("utf-8")
  sha256.hexdigest.upcase
end

#card_4noObject



214
215
216
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 214

def card_4no
  _params['Card4No']
end

#card_6noObject



210
211
212
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 210

def card_6no
  _params['Card6No']
end

#check_codeObject



185
186
187
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 185

def check_code
  _params['CheckCode']
end

#checksum_ok?Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 139

def checksum_ok?
  calculate_checksum == check_code.to_s
end

#code_noObject

cvs



248
249
250
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 248

def code_no
  _params['CodeNo']
end

#complete?Boolean

Returns:

  • (Boolean)


117
118
119
120
121
122
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 117

def complete?
  case status
  when 'SUCCESS' # 付款/取號成功
    true
  end
end

#eciObject



230
231
232
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 230

def eci
  _params['ECI']
end

#escrow_bankObject



197
198
199
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 197

def escrow_bank
  _params['EscrowBank']
end

#expire_dateObject

other about serials



266
267
268
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 266

def expire_date
  _params['ExpireDate']
end

#instObject



218
219
220
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 218

def inst
  _params['Inst']
end

#inst_eachObject



226
227
228
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 226

def inst_each
  _params['InstEach']
end

#inst_firstObject



222
223
224
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 222

def inst_first
  _params['InstFirst']
end

#ipObject



193
194
195
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 193

def ip
  _params['IP']
end

#item_idObject

訂單號碼



160
161
162
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 160

def item_id
  merchant_order_no
end

#merchant_idObject



151
152
153
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 151

def merchant_id
  _params['MerchantID']
end

#merchant_order_noObject



173
174
175
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 173

def merchant_order_no
  _params['MerchantOrderNo']
end

#messageObject



147
148
149
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 147

def message
  URI.decode(_params['Message'])
end

#pay_bank_codeObject

web atm, atm



239
240
241
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 239

def pay_bank_code
  _params['PayBankCode']
end

#pay_timeObject



189
190
191
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 189

def pay_time
  URI.decode(_params['PayTime']).gsub("+", " ")
end

#payer_account_5codeObject



243
244
245
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 243

def 
  _params['PayerAccount5Code']
end

#payment_typeObject



177
178
179
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 177

def payment_type
  _params['PaymentType']
end

#respond_codeObject

credit card



202
203
204
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 202

def respond_code
  _params['RespondCode']
end

#respond_typeObject



181
182
183
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 181

def respond_type
  _params['RespondType']
end

#statusObject



143
144
145
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 143

def status
  _params['Status']
end

#token_use_statusObject



234
235
236
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 234

def token_use_status
  _params['TokenUseStatus']
end

#trade_noObject



169
170
171
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 169

def trade_no
  _params['TradeNo']
end

#transaction_idObject

Pay2goCvs 端訂單號碼



165
166
167
# File 'lib/offsite_payments/integrations/pay2go_cvs.rb', line 165

def transaction_id
  trade_no
end