class OffsitePayments::Integrations::WorldPay::Notification

Public Instance Methods

account() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 125
def account
  params['instId']
end
acknowledge(authcode = nil) click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 224
def acknowledge(authcode = nil)
  return true
end
address() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 169
def address
  params['address']
end
address_status() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 216
def address_status
  return avs_value_to_symbol(params['AVS'][2].chr)
end
card_type() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 193
def card_type
  params['cardType']
end
complete?() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 121
def complete?
  status == 'Completed'
end
country() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 177
def country
  params['country']
end
country_status() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 220
def country_status
  return avs_value_to_symbol(params['AVS'][3].chr)
end
currency() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 152
def currency
  params['authCurrency']
end
custom_params() click to toggle source

WorldPay supports the passing of custom parameters through to the callback script

# File lib/offsite_payments/integrations/world_pay.rb, line 229
def custom_params
  return @custom_params ||= read_custom_params
end
cvv_status() click to toggle source

WorldPay extended fraud checks returned as a 4 character string

1st char: Credit card CVV check
2nd char: Postcode AVS check
3rd char: Address AVS check
4th char: Country comparison check

Possible values are:

:not_supported   -  0
:not_checked     -  1
:matched         -  2
:not_matched     -  4
:partial_match   -  8
# File lib/offsite_payments/integrations/world_pay.rb, line 208
def cvv_status
  return avs_value_to_symbol(params['AVS'][0].chr)
end
email_address() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 189
def email_address
  params['email']
end
fax_number() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 185
def fax_number
  params['fax']
end
gross() click to toggle source

the money amount we received in X.2 decimal.

# File lib/offsite_payments/integrations/world_pay.rb, line 148
def gross
  params['authAmount']
end
item_id() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 129
def item_id
  params['cartId']
end
name() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 165
def name
  params['name']
end
phone_number() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 181
def phone_number
  params['tel']
end
postcode() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 173
def postcode
  params['postcode']
end
postcode_status() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 212
def postcode_status
  return avs_value_to_symbol(params['AVS'][1].chr)
end
received_at() click to toggle source

Time this payment was received by the client in UTC time.

# File lib/offsite_payments/integrations/world_pay.rb, line 138
def received_at
  Time.at(params['transTime'].to_i / 1000).utc
end
security_key() click to toggle source

Callback password set in the WorldPay CMS

# File lib/offsite_payments/integrations/world_pay.rb, line 143
def security_key
  params['callbackPW']
end
status() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 161
def status
  params['transStatus'] == 'Y' ? 'Completed' : 'Cancelled'
end
test?() click to toggle source

Was this a test transaction?

# File lib/offsite_payments/integrations/world_pay.rb, line 157
def test?
  params.key?('testMode') && params['testMode'] != '0'
end
transaction_id() click to toggle source
# File lib/offsite_payments/integrations/world_pay.rb, line 133
def transaction_id
  params['transId']
end

Private Instance Methods

avs_value_to_symbol(value) click to toggle source

Convert a AVS value to a symbol - see above for more about AVS

# File lib/offsite_payments/integrations/world_pay.rb, line 256
def avs_value_to_symbol(value)
  case value.to_s
  when '8'
    :partial_match
  when '4'
    :no_match
  when '2'
    :matched
  when '1'
    :not_checked
  else
    :not_supported
  end
end
parse(post) click to toggle source

Take the posted data and move the relevant data into a hash

# File lib/offsite_payments/integrations/world_pay.rb, line 236
def parse(post)
  @raw = post
  for line in post.split('&')
    key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
    params[key] = value
  end
end
read_custom_params() click to toggle source

Read the custom params into a hash

# File lib/offsite_payments/integrations/world_pay.rb, line 245
def read_custom_params
  custom = {}
  params.each do |key, value|
    if /\A(M_|MC_|CM_)/ === key
      custom[key.gsub(/\A(M_|MC_|CM_)/, '').to_sym] = value
    end
  end
  custom
end