Class: OffsitePayments::Integrations::SagePayForm::Notification

Inherits:
Notification
  • Object
show all
Includes:
Encryption
Defined in:
lib/offsite_payments/integrations/sage_pay_form.rb

Defined Under Namespace

Classes: CryptError, InvalidCryptData, MissingCryptData, MissingCryptKey

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods included from Encryption

#sage_decrypt, #sage_encrypt, #sage_encrypt_salt

Methods inherited from Notification

#amount, #empty!, #gross_cents, #iso_currency, #valid_sender?

Constructor Details

#initialize(post_data, options) ⇒ Notification

Returns a new instance of Notification.



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

def initialize(post_data, options)
  super
  load_crypt_params(params['crypt'], options[:credential2])
end

Instance Method Details

#acknowledgeObject



377
378
379
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 377

def acknowledge
  true
end

#address_resultObject

Numeric address check. Possible values:

NOTPROVIDED
NOTCHECKED
MATCHED
NOTMATCHED


291
292
293
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 291

def address_result
  params['AddressResult']
end

#address_statusObject

Address confirmation status. PayPal only. Possible values:

NONE
CONFIRMED
UNCONFIRMED


338
339
340
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 338

def address_status
  params['AddressStatus']
end

#auth_idObject

Authorization number (only if #completed?).



267
268
269
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 267

def auth_id
  params['TxAuthNo']
end

#avs_cv2_resultObject

AVS and CV2 check results. Possible values:

ALL MATCH
SECURITY CODE MATCH ONLY
ADDRESS MATCH ONLY
NO DATA MATCHES
DATA NOT CHECKED


282
283
284
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 282

def avs_cv2_result
  params['AVSCV2']
end

#buyer_auth_resultObject

Result of 3D Secure checks. Possible values:

OK

Authenticated correctly.

NOTCHECKED

Authentication not performed.

NOTAVAILABLE

Card not auth-capable, or auth is otherwise impossible.

NOTAUTHED

User failed authentication.

INCOMPLETE

Authentication unable to complete.

ERROR

Unable to attempt authentication due to data / service errors.



325
326
327
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 325

def buyer_auth_result
  params['3DSecureStatus']
end

#buyer_auth_result_codeObject

Encoded 3D Secure result code.



330
331
332
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 330

def buyer_auth_result_code
  params['CAVV']
end

#cancelled?Boolean

Was the transaction cancelled? Unfortunately, we can’t distinguish “user abort” from “idle too long”.

Returns:

  • (Boolean)


228
229
230
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 228

def cancelled?
  status_code == 'ABORT'
end

#complete?Boolean

Was the transaction complete?

Returns:

  • (Boolean)


222
223
224
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 222

def complete?
  status_code == 'OK'
end

#credit_card_last_4_digitsObject

Last four digits of credit card.



364
365
366
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 364

def credit_card_last_4_digits
  params['Last4Digits']
end

#credit_card_typeObject

Credit card type. Possible values:

VISA

Visa

MC

MasterCard

DELTA

Delta

SOLO

Solo

MAESTRO

Maestro (UK and International)

UKE

Visa Electron

AMEX

American Express

DC

Diners Club

JCB

JCB

LASER

Laser

PAYPAL

PayPal



359
360
361
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 359

def credit_card_type
  params['CardType']
end

#currencyObject

Used by composition methods, but not supplied by SagePay.



369
370
371
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 369

def currency
  Money::NULL_CURRENCY
end

#cv2_resultObject

CV2 code check. Possible values:

NOTPROVIDED
NOTCHECKED
MATCHED
NOTMATCHED


309
310
311
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 309

def cv2_result
  params['CV2Result']
end

#gift_aid?Boolean

Was the Gift Aid box checked?

Returns:

  • (Boolean)


314
315
316
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 314

def gift_aid?
  params['GiftAid'] == '1'
end

#grossObject

Total amount (no fees).



272
273
274
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 272

def gross
  params['Amount'].gsub(/,(?=\d{3}\b)/, '')
end

#item_idObject

Vendor-supplied code (:order mapping).



257
258
259
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 257

def item_id
  params['VendorTxCode'].rpartition('-').first
end

#messageObject

Check this if #completed? is false.



252
253
254
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 252

def message
  params['StatusDetail']
end

#payer_verified?Boolean

Payer verification. Undocumented.

Returns:

  • (Boolean)


343
344
345
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 343

def payer_verified?
  params['PayerStatus'] == 'VERIFIED'
end

#post_code_resultObject

Post code check. Possible values:

NOTPROVIDED
NOTCHECKED
MATCHED
NOTMATCHED


300
301
302
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 300

def post_code_result
  params['PostCodeResult']
end

#statusObject

Text version of #complete?, since we don’t support Pending.



233
234
235
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 233

def status
  complete? ? 'Completed' : 'Failed'
end

#status_codeObject

Status of transaction. List of possible values:

OK

Transaction completed successfully.

NOTAUTHED

Incorrect card details / insufficient funds.

MALFORMED

Invalid input data.

INVALID

Valid input data, but some fields are incorrect.

ABORT

User hit cancel button or went idle for 15+ minutes.

REJECTED

Rejected by account fraud screening rules.

AUTHENTICATED

Authenticated card details secured at SagePay.

REGISTERED

Non-authenticated card details secured at SagePay.

ERROR

Problem internal to SagePay.



247
248
249
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 247

def status_code
  params['Status']
end

#test?Boolean

Returns:

  • (Boolean)


373
374
375
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 373

def test?
  false
end

#transaction_idObject

Internal SagePay code, typically “LONG-UUID”.



262
263
264
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 262

def transaction_id
  params['VPSTxId']
end