Class: OffsitePayments::Integrations::WorldPay::Notification

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

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

#amount, #empty!, #gross_cents, #initialize, #iso_currency

Constructor Details

This class inherits a constructor from OffsitePayments::Notification

Instance Method Details

#accountObject



121
122
123
# File 'lib/offsite_payments/integrations/world_pay.rb', line 121

def 
  params['instId']
end

#acknowledge(authcode = nil) ⇒ Object



220
221
222
# File 'lib/offsite_payments/integrations/world_pay.rb', line 220

def acknowledge(authcode = nil)
  return true
end

#addressObject



165
166
167
# File 'lib/offsite_payments/integrations/world_pay.rb', line 165

def address
  params['address']
end

#address_statusObject



212
213
214
# File 'lib/offsite_payments/integrations/world_pay.rb', line 212

def address_status
  return avs_value_to_symbol(params['AVS'][2].chr)
end

#card_typeObject



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

def card_type
  params['cardType']
end

#complete?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/offsite_payments/integrations/world_pay.rb', line 117

def complete?
  status == 'Completed'
end

#countryObject



173
174
175
# File 'lib/offsite_payments/integrations/world_pay.rb', line 173

def country
  params['country']
end

#country_statusObject



216
217
218
# File 'lib/offsite_payments/integrations/world_pay.rb', line 216

def country_status
  return avs_value_to_symbol(params['AVS'][3].chr)
end

#currencyObject



148
149
150
# File 'lib/offsite_payments/integrations/world_pay.rb', line 148

def currency
  params['currency']
end

#custom_paramsObject

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



225
226
227
# File 'lib/offsite_payments/integrations/world_pay.rb', line 225

def custom_params
  return @custom_params ||= read_custom_params
end

#cvv_statusObject

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


204
205
206
# File 'lib/offsite_payments/integrations/world_pay.rb', line 204

def cvv_status
  return avs_value_to_symbol(params['AVS'][0].chr)
end

#email_addressObject



185
186
187
# File 'lib/offsite_payments/integrations/world_pay.rb', line 185

def email_address
  params['email']
end

#fax_numberObject



181
182
183
# File 'lib/offsite_payments/integrations/world_pay.rb', line 181

def fax_number
  params['fax']
end

#grossObject

the money amount we received in X.2 decimal.



144
145
146
# File 'lib/offsite_payments/integrations/world_pay.rb', line 144

def gross
  params['amount']
end

#item_idObject



125
126
127
# File 'lib/offsite_payments/integrations/world_pay.rb', line 125

def item_id
  params['cartId']
end

#nameObject



161
162
163
# File 'lib/offsite_payments/integrations/world_pay.rb', line 161

def name
  params['name']
end

#phone_numberObject



177
178
179
# File 'lib/offsite_payments/integrations/world_pay.rb', line 177

def phone_number
  params['tel']
end

#postcodeObject



169
170
171
# File 'lib/offsite_payments/integrations/world_pay.rb', line 169

def postcode
  params['postcode']
end

#postcode_statusObject



208
209
210
# File 'lib/offsite_payments/integrations/world_pay.rb', line 208

def postcode_status
  return avs_value_to_symbol(params['AVS'][1].chr)
end

#received_atObject

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



134
135
136
# File 'lib/offsite_payments/integrations/world_pay.rb', line 134

def received_at
  Time.at(params['transTime'].to_i / 1000).utc
end

#security_keyObject

Callback password set in the WorldPay CMS



139
140
141
# File 'lib/offsite_payments/integrations/world_pay.rb', line 139

def security_key
  params['callbackPW']
end

#statusObject



157
158
159
# File 'lib/offsite_payments/integrations/world_pay.rb', line 157

def status
  params['transStatus'] == 'Y' ? 'Completed' : 'Cancelled'
end

#test?Boolean

Was this a test transaction?

Returns:

  • (Boolean)


153
154
155
# File 'lib/offsite_payments/integrations/world_pay.rb', line 153

def test?
  params.key?('testMode') && params['testMode'] != '0'
end

#transaction_idObject



129
130
131
# File 'lib/offsite_payments/integrations/world_pay.rb', line 129

def transaction_id
  params['transId']
end

#valid_sender?(ip) ⇒ Boolean

Check if the request comes from IP range 195.35.90.0 – 195.35.91.255

Returns:

  • (Boolean)


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

def valid_sender?(ip)
  return true if OffsitePayments.mode == :test 
  IPAddr.new("195.35.90.0/23").include?(IPAddr.new(ip))
end