class OffsitePayments::Integrations::SagePayForm::Notification

Public Class Methods

new(post_data, options) click to toggle source
Calls superclass method OffsitePayments::Notification::new
# 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

Public Instance Methods

acknowledge() click to toggle source
# File lib/offsite_payments/integrations/sage_pay_form.rb, line 377
def acknowledge
  true
end
address_result() click to toggle source

Numeric address check. Possible values:

NOTPROVIDED
NOTCHECKED
MATCHED
NOTMATCHED
# File lib/offsite_payments/integrations/sage_pay_form.rb, line 291
def address_result
  params['AddressResult']
end
address_status() click to toggle source

Address confirmation status. PayPal only. Possible values:

NONE
CONFIRMED
UNCONFIRMED
# File lib/offsite_payments/integrations/sage_pay_form.rb, line 338
def address_status
  params['AddressStatus']
end
auth_id() click to toggle source

Authorization number (only if completed?).

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 267
def auth_id
  params['TxAuthNo']
end
avs_cv2_result() click to toggle source

AVS and CV2 check results. Possible values:

ALL MATCH
SECURITY CODE MATCH ONLY
ADDRESS MATCH ONLY
NO DATA MATCHES
DATA NOT CHECKED
# File lib/offsite_payments/integrations/sage_pay_form.rb, line 282
def avs_cv2_result
  params['AVSCV2']
end
buyer_auth_result() click to toggle source

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.

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 325
def buyer_auth_result
  params['3DSecureStatus']
end
buyer_auth_result_code() click to toggle source

Encoded 3D Secure result code.

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 330
def buyer_auth_result_code
  params['CAVV']
end
cancelled?() click to toggle source

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

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 228
def cancelled?
  status_code == 'ABORT'
end
complete?() click to toggle source

Was the transaction complete?

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 222
def complete?
  status_code == 'OK'
end
credit_card_last_4_digits() click to toggle source

Last four digits of credit card.

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 364
def credit_card_last_4_digits
  params['Last4Digits']
end
credit_card_type() click to toggle source

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

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 359
def credit_card_type
  params['CardType']
end
currency() click to toggle source

Used by composition methods, but not supplied by SagePay.

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 369
def currency
  Money::NULL_CURRENCY
end
cv2_result() click to toggle source

CV2 code check. Possible values:

NOTPROVIDED
NOTCHECKED
MATCHED
NOTMATCHED
# File lib/offsite_payments/integrations/sage_pay_form.rb, line 309
def cv2_result
  params['CV2Result']
end
gift_aid?() click to toggle source

Was the Gift Aid box checked?

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 314
def gift_aid?
  params['GiftAid'] == '1'
end
gross() click to toggle source

Total amount (no fees).

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 272
def gross
  params['Amount'].gsub(/,(?=\d{3}\b)/, '')
end
item_id() click to toggle source

Vendor-supplied code (:order mapping).

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 257
def item_id
  params['VendorTxCode'].rpartition('-').first
end
message() click to toggle source

Check this if completed? is false.

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 252
def message
  params['StatusDetail']
end
payer_verified?() click to toggle source

Payer verification. Undocumented.

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 343
def payer_verified?
  params['PayerStatus'] == 'VERIFIED'
end
post_code_result() click to toggle source

Post code check. Possible values:

NOTPROVIDED
NOTCHECKED
MATCHED
NOTMATCHED
# File lib/offsite_payments/integrations/sage_pay_form.rb, line 300
def post_code_result
  params['PostCodeResult']
end
status() click to toggle source

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

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 233
def status
  complete? ? 'Completed' : 'Failed'
end
status_code() click to toggle source

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.

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 247
def status_code
  params['Status']
end
test?() click to toggle source
# File lib/offsite_payments/integrations/sage_pay_form.rb, line 373
def test?
  false
end
transaction_id() click to toggle source

Internal SagePay code, typically “{LONG-UUID}”.

# File lib/offsite_payments/integrations/sage_pay_form.rb, line 262
def transaction_id
  params['VPSTxId']
end

Private Instance Methods

load_crypt_params(crypt, key) click to toggle source
# File lib/offsite_payments/integrations/sage_pay_form.rb, line 383
def load_crypt_params(crypt, key)
  raise MissingCryptData if crypt.blank?
  raise MissingCryptKey  if key.blank?

  crypt_data = sage_decrypt(crypt.gsub(' ', '+'), key)
  raise InvalidCryptData unless crypt_data =~ /(^|&)Status=/

  params.clear
  parse(crypt_data)
end