Class: ActiveMerchant::Billing::Integrations::SagePayForm::Helper

Inherits:
Helper
  • Object
show all
Includes:
Encryption
Defined in:
lib/active_merchant/billing/integrations/sage_pay_form/helper.rb

Instance Attribute Summary

Attributes inherited from Helper

#fields

Instance Method Summary collapse

Methods included from Encryption

#sage_decrypt, #sage_encrypt, #sage_encrypt_salt

Methods inherited from Helper

#add_field, #add_fields, #billing_address, #initialize, mapping, #shipping_address

Constructor Details

This class inherits a constructor from ActiveMerchant::Billing::Integrations::Helper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveMerchant::Billing::Integrations::Helper

Instance Method Details

#form_fieldsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/active_merchant/billing/integrations/sage_pay_form/helper.rb', line 43

def form_fields
  fields['DeliveryFirstnames'] ||= fields['BillingFirstnames']
  fields['DeliverySurname']    ||= fields['BillingSurname']
  
  fields['FailureURL'] ||= fields['SuccessURL']

  crypt_skip = ['Vendor', 'EncryptKey']
  crypt_skip << 'BillingState'  unless fields['BillingCountry']  == 'US'
  crypt_skip << 'DeliveryState' unless fields['DeliveryCountry'] == 'US'
  
  key = fields['EncryptKey']
  @crypt ||= create_crypt_field(fields.except(*crypt_skip), key)
  
  {
    'VPSProtocol' => '2.23',
    'TxType' => 'PAYMENT',
    'Vendor' => @fields['Vendor'],
    'Crypt'  => @crypt
  }
end