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



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

def 
  params['instId']
end

#acknowledge(authcode = nil) ⇒ Object



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

def acknowledge(authcode = nil)
  return true
end

#addressObject



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

def address
  params['address']
end

#address_statusObject



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

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

#card_typeObject



194
195
196
# File 'lib/offsite_payments/integrations/world_pay.rb', line 194

def card_type
  params['cardType']
end

#complete?Boolean

Returns:

  • (Boolean)


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

def complete?
  status == 'Completed'
end

#countryObject



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

def country
  params['country']
end

#country_statusObject



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

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

#currencyObject



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

def currency
  params['authCurrency']
end

#custom_paramsObject

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



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

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


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

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

#email_addressObject



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

def email_address
  params['email']
end

#fax_numberObject



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

def fax_number
  params['fax']
end

#grossObject

the money amount we received in X.2 decimal.



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

def gross
  params['authAmount']
end

#item_idObject



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

def item_id
  params['cartId']
end

#nameObject



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

def name
  params['name']
end

#phone_numberObject



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

def phone_number
  params['tel']
end

#postcodeObject



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

def postcode
  params['postcode']
end

#postcode_statusObject



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

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.



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

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

#security_keyObject

Callback password set in the WorldPay CMS



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

def security_key
  params['callbackPW']
end

#statusObject



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

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

#test?Boolean

Was this a test transaction?

Returns:

  • (Boolean)


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

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

#transaction_idObject



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

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)


235
236
237
238
# File 'lib/offsite_payments/integrations/world_pay.rb', line 235

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