Class: OffsitePayments::Integrations::PayuIn::Helper
- Defined in:
- lib/offsite_payments/integrations/payu_in.rb
Direct Known Subclasses
Constant Summary collapse
- CHECKSUM_FIELDS =
[ 'txnid', 'amount', 'productinfo', 'firstname', 'email', 'udf1', 'udf2', 'udf3', 'udf4', 'udf5', 'udf6', 'udf7', 'udf8', 'udf9', 'udf10']
Instance Attribute Summary
Attributes inherited from Helper
Instance Method Summary collapse
- #form_fields ⇒ Object
- #generate_checksum ⇒ Object
-
#initialize(order, account, options = {}) ⇒ Helper
constructor
A new instance of Helper.
- #sanitize_fields ⇒ Object
Methods inherited from Helper
#add_field, #add_fields, #add_raw_html_field, #billing_address, #form_method, inherited, mapping, #raw_html_fields, #shipping_address, #test?
Methods included from MoneyCompatibility
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
69 70 71 72 73 74 |
# File 'lib/offsite_payments/integrations/payu_in.rb', line 69 def initialize(order, account, = {}) super @options = self.pg = 'CC' add_field('udf5', application_id) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OffsitePayments::Helper
Instance Method Details
#form_fields ⇒ Object
76 77 78 79 |
# File 'lib/offsite_payments/integrations/payu_in.rb', line 76 def form_fields sanitize_fields @fields.merge(mappings[:checksum] => generate_checksum) end |
#generate_checksum ⇒ Object
81 82 83 84 85 |
# File 'lib/offsite_payments/integrations/payu_in.rb', line 81 def generate_checksum checksum_payload_items = CHECKSUM_FIELDS.map { |field| @fields[field] } PayuIn.checksum(@fields["key"], @options[:credential2], checksum_payload_items ) end |
#sanitize_fields ⇒ Object
87 88 89 90 91 92 |
# File 'lib/offsite_payments/integrations/payu_in.rb', line 87 def sanitize_fields @fields['phone'] = @fields['phone'].gsub(/[^0-9]/, '') if @fields['phone'] ['address1', 'address2', 'city', 'state', 'country', 'productinfo', 'email'].each do |field| @fields[field] = @fields[field].gsub(/[^a-zA-Z0-9\-_@\/\s.]/, '') if @fields[field] end end |