Class: OffsitePayments::Integrations::Pay2go::Notification

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_paramsObject

Returns the value of attribute _params.



123
124
125
# File 'lib/offsite_payments/integrations/pay2go.rb', line 123

def _params
  @_params
end

Instance Method Details

#acknowledgeObject

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



141
142
143
# File 'lib/offsite_payments/integrations/pay2go.rb', line 141

def acknowledge
  checksum_ok?
end

#amtObject



179
180
181
# File 'lib/offsite_payments/integrations/pay2go.rb', line 179

def amt
  _params['Amt'].to_s
end

#authObject



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

def auth
  _params['Auth']
end

#barcode_1Object

barcode



277
278
279
# File 'lib/offsite_payments/integrations/pay2go.rb', line 277

def barcode_1
  _params['Barcode_1']
end

#barcode_2Object



281
282
283
# File 'lib/offsite_payments/integrations/pay2go.rb', line 281

def barcode_2
  _params['Barcode_2']
end

#barcode_3Object



285
286
287
# File 'lib/offsite_payments/integrations/pay2go.rb', line 285

def barcode_3
  _params['Barcode_3']
end

#card_4noObject



238
239
240
# File 'lib/offsite_payments/integrations/pay2go.rb', line 238

def card_4no
  _params['Card4No']
end

#card_6noObject



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

def card_6no
  _params['Card6No']
end

#check_codeObject



209
210
211
# File 'lib/offsite_payments/integrations/pay2go.rb', line 209

def check_code
  _params['CheckCode']
end

#checksum_ok?Boolean

Returns:

  • (Boolean)


152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/offsite_payments/integrations/pay2go.rb', line 152

def checksum_ok?
  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::Pay2go.hash_iv}&#{raw_data}&HashKey=#{OffsitePayments::Integrations::Pay2go.hash_key}"

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

#code_noObject

cvs



272
273
274
# File 'lib/offsite_payments/integrations/pay2go.rb', line 272

def code_no
  _params['CodeNo']
end

#complete?Boolean

Returns:

  • (Boolean)


145
146
147
148
149
150
# File 'lib/offsite_payments/integrations/pay2go.rb', line 145

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

#eciObject



254
255
256
# File 'lib/offsite_payments/integrations/pay2go.rb', line 254

def eci
  _params['ECI']
end

#escrow_bankObject



221
222
223
# File 'lib/offsite_payments/integrations/pay2go.rb', line 221

def escrow_bank
  _params['EscrowBank']
end

#expire_dateObject

other about serials



290
291
292
# File 'lib/offsite_payments/integrations/pay2go.rb', line 290

def expire_date
  _params['ExpireDate']
end

#instObject



242
243
244
# File 'lib/offsite_payments/integrations/pay2go.rb', line 242

def inst
  _params['Inst']
end

#inst_eachObject



250
251
252
# File 'lib/offsite_payments/integrations/pay2go.rb', line 250

def inst_each
  _params['InstEach']
end

#inst_firstObject



246
247
248
# File 'lib/offsite_payments/integrations/pay2go.rb', line 246

def inst_first
  _params['InstFirst']
end

#ipObject



217
218
219
# File 'lib/offsite_payments/integrations/pay2go.rb', line 217

def ip
  _params['IP']
end

#item_idObject

訂單號碼



184
185
186
# File 'lib/offsite_payments/integrations/pay2go.rb', line 184

def item_id
  merchant_order_no
end

#merchant_idObject



175
176
177
# File 'lib/offsite_payments/integrations/pay2go.rb', line 175

def merchant_id
  _params['MerchantID']
end

#merchant_order_noObject



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

def merchant_order_no
  _params['MerchantOrderNo']
end

#messageObject



171
172
173
# File 'lib/offsite_payments/integrations/pay2go.rb', line 171

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

#pay_bank_codeObject

web atm, atm



263
264
265
# File 'lib/offsite_payments/integrations/pay2go.rb', line 263

def pay_bank_code
  _params['PayBankCode']
end

#pay_timeObject



213
214
215
# File 'lib/offsite_payments/integrations/pay2go.rb', line 213

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

#payer_account_5codeObject



267
268
269
# File 'lib/offsite_payments/integrations/pay2go.rb', line 267

def 
  _params['PayerAccount5Code']
end

#payment_typeObject



201
202
203
# File 'lib/offsite_payments/integrations/pay2go.rb', line 201

def payment_type
  _params['PaymentType']
end

#respond_codeObject

credit card



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

def respond_code
  _params['RespondCode']
end

#respond_typeObject



205
206
207
# File 'lib/offsite_payments/integrations/pay2go.rb', line 205

def respond_type
  _params['RespondType']
end

#statusObject



167
168
169
# File 'lib/offsite_payments/integrations/pay2go.rb', line 167

def status
  _params['Status']
end

#token_use_statusObject



258
259
260
# File 'lib/offsite_payments/integrations/pay2go.rb', line 258

def token_use_status
  _params['TokenUseStatus']
end

#trade_noObject



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

def trade_no
  _params['TradeNo']
end

#transaction_idObject

Pay2go 端訂單號碼



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

def transaction_id
  trade_no
end