class OffsitePayments::Integrations::Ipay88::Notification

Public Instance Methods

account() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 159
def account
  params["MerchantCode"]
end
acknowledge() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 195
def acknowledge
  secure? && (!success? || requery == "00")
end
auth_code() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 175
def auth_code
  params["AuthCode"]
end
complete?() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 143
def complete?
  status == 'Completed'
end
currency() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 155
def currency
  params["Currency"]
end
error() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 179
def error
  params["ErrDesc"]
end
gross() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 151
def gross
  params["Amount"].try(:gsub, /,(?=\d{3}\b)/, '')
end
item_id() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 147
def item_id
  params["RefNo"]
end
payment() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 163
def payment
  params["PaymentId"].to_i
end
remark() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 167
def remark
  params["Remark"]
end
secure?() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 187
def secure?
  generated_signature == signature
end
signature() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 183
def signature
  params["Signature"]
end
status() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 135
def status
  if params["Status"] == '1'
    'Completed'
  else
    error == CANCELLED_ERROR_DESCRIPTION ? 'Cancelled' : 'Failed'
  end
end
success?() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 191
def success?
  status == 'Completed'
end
transaction_id() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 171
def transaction_id
  params["TransId"]
end

Protected Instance Methods

generated_signature() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 201
def generated_signature
  Helper.sign(sig_components)
end
requery() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 214
def requery
  data   = { "MerchantCode" => account, "RefNo" => item_id, "Amount" => gross }
  params = parameterize(data)
  ssl_post Ipay88.requery_url, params, { "Content-Length" => params.size.to_s, "User-Agent" => "Active Merchant -- http://activemerchant.org" }
end
sig_components() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 205
def sig_components
  components = [@options[:credential2]]
  [:account, :payment, :item_id, :amount_in_cents, :currency].each do |i|
    components << send(i)
  end
  components << params["Status"]
  components.join
end

Private Instance Methods

amount_in_cents() click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 226
def amount_in_cents
  @amount_in_cents ||= (gross || "").gsub(/[.,]/, "")
end
parameterize(params) click to toggle source
# File lib/offsite_payments/integrations/ipay88.rb, line 222
def parameterize(params)
  params.reject { |k, v| v.blank? }.keys.sort.collect { |key| "#{key}=#{CGI.escape(params[key].to_s)}" }.join("&")
end