class OffsitePayments::Integrations::Spgateway::Notification

Constants

PARAMS_FIELDS

Public Instance Methods

acknowledge() click to toggle source

TODO 使用查詢功能實作 acknowledge Spgateway 沒有遠端驗證功能, 而以 checksum_ok? 代替

# File lib/offsite_payments/integrations/spgateway/notification.rb, line 43
def acknowledge
  checksum_ok?
end
checksum_ok?() click to toggle source
# File lib/offsite_payments/integrations/spgateway/notification.rb, line 51
def checksum_ok?
  raw_data = URI.encode_www_form OffsitePayments::Integrations::Spgateway::CHECK_CODE_FIELDS.sort.map { |field|
    [field, @params[field]]
  }

  hash_raw_data = "HashIV=#{hash_iv}&#{raw_data}&HashKey=#{hash_key}"
  Digest::SHA256.hexdigest(hash_raw_data).upcase == check_code
end
complete?() click to toggle source
# File lib/offsite_payments/integrations/spgateway/notification.rb, line 47
def complete?
  %w(SUCCESS CUSTOM).include? status
end
credit_card_agreement_first_trade?() click to toggle source

是否為約定信用卡授權首次交易

# File lib/offsite_payments/integrations/spgateway/notification.rb, line 61
def credit_card_agreement_first_trade?
  token_use_status == "1"
end
credit_card_agreement_token_trade?() click to toggle source

是否為信用卡授權 token 交易

# File lib/offsite_payments/integrations/spgateway/notification.rb, line 66
def credit_card_agreement_token_trade?
  token_use_status.blank? && token_life.present?
end
hash_iv() click to toggle source
# File lib/offsite_payments/integrations/spgateway/notification.rb, line 32
def hash_iv
  @hash_iv || OffsitePayments::Integrations::Spgateway.hash_iv
end
hash_iv=(iv) click to toggle source
# File lib/offsite_payments/integrations/spgateway/notification.rb, line 24
def hash_iv=(iv)
  @hash_iv = iv
end
hash_key() click to toggle source
# File lib/offsite_payments/integrations/spgateway/notification.rb, line 28
def hash_key
  @hash_key || OffsitePayments::Integrations::Spgateway.hash_key
end
hash_key=(key) click to toggle source
# File lib/offsite_payments/integrations/spgateway/notification.rb, line 20
def hash_key=(key)
  @hash_key = key
end
success?() click to toggle source
# File lib/offsite_payments/integrations/spgateway/notification.rb, line 36
def success?
  status == 'SUCCESS'
end