Class: OffsitePayments::Integrations::SagePayForm::Helper
- Includes:
- Encryption
- Defined in:
- lib/offsite_payments/integrations/sage_pay_form.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Attributes inherited from Helper
Instance Method Summary collapse
- #form_fields ⇒ Object
-
#initialize(order, account, options = {}) ⇒ Helper
constructor
A new instance of Helper.
- #map_billing_address_to_shipping_address ⇒ Object
- #shipping_address(params = {}) ⇒ Object
Methods included from Encryption
#sage_decrypt, #sage_encrypt, #sage_encrypt_salt
Methods inherited from Helper
#add_field, #add_fields, #add_raw_html_field, #billing_address, #form_method, inherited, mapping, #raw_html_fields, #test?
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
74 75 76 77 78 |
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 74 def initialize(order, account, ={}) super @identifier = rand(0..99999).to_s.rjust(5, '0') add_field 'VendorTxCode', "#{order}-#{@identifier}" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OffsitePayments::Helper
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
72 73 74 |
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 72 def identifier @identifier end |
Instance Method Details
#form_fields ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 129 def form_fields map_billing_address_to_shipping_address unless @shipping_address_set fields['DeliveryFirstnames'] ||= fields['BillingFirstnames'] fields['DeliverySurname'] ||= fields['BillingSurname'] fields['FailureURL'] ||= fields['SuccessURL'] fields['BillingPostCode'] ||= "0000" fields['DeliveryPostCode'] ||= "0000" fields['ReferrerID'] = referrer_id if referrer_id crypt_skip = ['Vendor', 'EncryptKey', 'SendEmail'] crypt_skip << 'BillingState' unless fields['BillingCountry'] == 'US' crypt_skip << 'DeliveryState' unless fields['DeliveryCountry'] == 'US' crypt_skip << 'CustomerEMail' unless fields['SendEmail'] key = fields['EncryptKey'] @crypt ||= create_crypt_field(fields.except(*crypt_skip), key) { 'VPSProtocol' => '3.00', 'TxType' => 'PAYMENT', 'Vendor' => @fields['Vendor'], 'Crypt' => @crypt } end |
#map_billing_address_to_shipping_address ⇒ Object
123 124 125 126 127 |
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 123 def map_billing_address_to_shipping_address %w(City Address1 Address2 State PostCode Country).each do |field| fields["Delivery#{field}"] = fields["Billing#{field}"] end end |
#shipping_address(params = {}) ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/offsite_payments/integrations/sage_pay_form.rb', line 114 def shipping_address(params = {}) @shipping_address_set = true unless params.empty? params.each do |k, v| field = mappings[:shipping_address][k] add_field(field, v) unless field.nil? end end |