Class: OffsitePayments::Integrations::Allpay::Notification
- Inherits:
-
Notification
- Object
- Notification
- OffsitePayments::Integrations::Allpay::Notification
- Defined in:
- lib/offsite_payments/integrations/allpay.rb
Instance Method Summary collapse
-
#acknowledge ⇒ Object
TODO 使用查詢功能實作 acknowledge Allpay 沒有遠端驗證功能, 而以 checksum_ok? 代替.
-
#bank_code ⇒ Object
for ATM.
-
#barcode1 ⇒ Object
for BARCODE.
- #barcode2 ⇒ Object
- #barcode3 ⇒ Object
- #check_mac_value ⇒ Object
- #checksum_ok? ⇒ Boolean
- #complete? ⇒ Boolean
- #currency ⇒ Object
- #expire_date ⇒ Object
- #gross ⇒ Object
- #merchant_id ⇒ Object
-
#merchant_trade_no ⇒ Object
(also: #item_id)
廠商交易編號.
- #payment_date ⇒ Object
-
#payment_no ⇒ Object
for CVS.
- #payment_type ⇒ Object
- #payment_type_charge_fee ⇒ Object
- #rtn_code ⇒ Object
- #rtn_msg ⇒ Object
- #simulate_paid ⇒ Object
- #status ⇒ Object
- #trade_amt ⇒ Object
- #trade_date ⇒ Object
-
#trade_no ⇒ Object
(also: #transaction_id)
AllPay 的交易編號.
- #v_account ⇒ Object
Instance Method Details
#acknowledge ⇒ Object
TODO 使用查詢功能實作 acknowledge Allpay 沒有遠端驗證功能, 而以 checksum_ok? 代替
187 188 189 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 187 def acknowledge checksum_ok? end |
#bank_code ⇒ Object
for ATM
281 282 283 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 281 def bank_code @params['BankCode'] end |
#barcode1 ⇒ Object
for BARCODE
303 304 305 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 303 def @params['Barcode1'] end |
#barcode2 ⇒ Object
307 308 309 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 307 def @params['Barcode2'] end |
#barcode3 ⇒ Object
311 312 313 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 311 def @params['Barcode3'] end |
#check_mac_value ⇒ Object
276 277 278 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 276 def check_mac_value @params['CheckMacValue'] end |
#checksum_ok? ⇒ Boolean
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 206 def checksum_ok? params_copy = @params.clone checksum = params_copy.delete('CheckMacValue') # 把 params 轉成 query string 前必須先依照 hash key 做 sort # 依照英文字母排序,由 A 到 Z 且大小寫不敏感 raw_data = params_copy.sort_by{ |k,v| k.downcase }.map do |x, y| "#{x}=#{y}" end.join('&') hash_raw_data = "HashKey=#{OffsitePayments::Integrations::Allpay.hash_key}&#{raw_data}&HashIV=#{OffsitePayments::Integrations::Allpay.hash_iv}" url_endcode_data = OffsitePayments::Integrations::Allpay::Helper.url_encode(hash_raw_data) url_endcode_data.downcase! (Digest::MD5.hexdigest(url_endcode_data) == checksum.to_s.downcase) end |
#complete? ⇒ Boolean
191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 191 def complete? case @params['RtnCode'] when '1' #付款成功 true when '2' # ATM 取號成功 true when '10100073' # CVS 或 BARCODE 取號成功 true when '800' #貨到付款訂單建立成功 true else false end end |
#currency ⇒ Object
298 299 300 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 298 def currency 'TWD' end |
#expire_date ⇒ Object
289 290 291 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 289 def expire_date @params['ExpireDate'] end |
#gross ⇒ Object
252 253 254 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 252 def gross ::Money.new(@params['TradeAmt'].to_i * 100, currency) end |
#merchant_id ⇒ Object
229 230 231 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 229 def merchant_id @params['MerchantID'] end |
#merchant_trade_no ⇒ Object Also known as: item_id
廠商交易編號
234 235 236 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 234 def merchant_trade_no @params['MerchantTradeNo'] end |
#payment_date ⇒ Object
256 257 258 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 256 def payment_date @params['PaymentDate'] end |
#payment_no ⇒ Object
for CVS
294 295 296 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 294 def payment_no @params['PaymentNo'] end |
#payment_type ⇒ Object
260 261 262 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 260 def payment_type @params['PaymentType'] end |
#payment_type_charge_fee ⇒ Object
264 265 266 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 264 def payment_type_charge_fee @params['PaymentTypeChargeFee'] end |
#rtn_code ⇒ Object
225 226 227 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 225 def rtn_code @params['RtnCode'] end |
#rtn_msg ⇒ Object
239 240 241 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 239 def rtn_msg @params['RtnMsg'] end |
#simulate_paid ⇒ Object
272 273 274 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 272 def simulate_paid @params['SimulatePaid'] end |
#status ⇒ Object
176 177 178 179 180 181 182 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 176 def status if rtn_code == '1' true else false end end |
#trade_amt ⇒ Object
249 250 251 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 249 def trade_amt @params['TradeAmt'] end |
#trade_date ⇒ Object
268 269 270 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 268 def trade_date @params['TradeDate'] end |
#trade_no ⇒ Object Also known as: transaction_id
AllPay 的交易編號
244 245 246 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 244 def trade_no @params['TradeNo'] end |
#v_account ⇒ Object
285 286 287 |
# File 'lib/offsite_payments/integrations/allpay.rb', line 285 def v_account @params['vAccount'] end |