Module: OffsitePayments::Integrations::PayFast::Common
- Included in:
- Helper, Notification
- Defined in:
- lib/offsite_payments/integrations/pay_fast.rb
Instance Method Summary collapse
- #generate_signature(type) ⇒ Object
- #notify_signature_string ⇒ Object
- #request_attributes ⇒ Object
- #request_signature_string ⇒ Object
Instance Method Details
#generate_signature(type) ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/offsite_payments/integrations/pay_fast.rb', line 62 def generate_signature(type) string = case type when :request request_signature_string when :notify notify_signature_string end Digest::MD5.hexdigest(string) end |
#notify_signature_string ⇒ Object
89 90 91 92 93 |
# File 'lib/offsite_payments/integrations/pay_fast.rb', line 89 def notify_signature_string params.map do |key, value| "#{key}=#{CGI.escape(value)}" unless key == PayFast.signature_parameter_name end.compact.join('&') end |
#request_attributes ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/offsite_payments/integrations/pay_fast.rb', line 73 def request_attributes [:merchant_id, :merchant_key, :return_url, :cancel_url, :notify_url, :name_first, :name_last, :email_address, :payment_id, :amount, :item_name, :item_description, :custom_str1, :custom_str2, :custom_str3, :custom_str4, :custom_str5, :custom_int1, :custom_int2, :custom_int3, :custom_int4, :custom_int5, :email_confirmation, :confirmation_address] end |
#request_signature_string ⇒ Object
83 84 85 86 87 |
# File 'lib/offsite_payments/integrations/pay_fast.rb', line 83 def request_signature_string request_attributes.map do |attr| "#{mappings[attr]}=#{CGI.escape(@fields[mappings[attr]])}" if @fields[mappings[attr]].present? end.compact.join('&') end |