Class: OffsitePayments::Integrations::Citrus::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/offsite_payments/integrations/citrus.rb

Constant Summary collapse

SANDBOX_URL =
'https://sandbox.citruspay.com/'.freeze
STAGING_URL =
'https://stg.citruspay.com/'.freeze
PRODUCTION_URL =
'https://www.citruspay.com/'.freeze

Instance Attribute Summary

Attributes inherited from Helper

#fields

Instance Method Summary collapse

Methods inherited from Helper

#add_field, #add_fields, #add_raw_html_field, #billing_address, #form_method, inherited, mapping, #raw_html_fields, #shipping_address, #test?

Constructor Details

#initialize(order, account, options = {}) ⇒ Helper


54
55
56
57
58
# File 'lib/offsite_payments/integrations/citrus.rb', line 54

def initialize(order, , options = {})
  super
  add_field 'paymentMode', 'NET_BANKING'
  add_field 'reqtime', (Time.now.to_i * 1000).to_s
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OffsitePayments::Helper

Instance Method Details

#credential_based_urlObject


40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/offsite_payments/integrations/citrus.rb', line 40

def credential_based_url
  pmt_url = @fields['pmt_url']
  case OffsitePayments.mode
  when :production
    PRODUCTION_URL + pmt_url
  when :test
    SANDBOX_URL    + pmt_url
  when :staging
    STAGING_URL    + pmt_url
  else
    raise StandardError, "Integration mode set to an invalid value: #{mode}"
  end
end

#form_fieldsObject


60
61
62
# File 'lib/offsite_payments/integrations/citrus.rb', line 60

def form_fields
  @fields.merge(mappings[:checksum] => generate_checksum)
end

#generate_checksumObject


64
65
66
67
# File 'lib/offsite_payments/integrations/citrus.rb', line 64

def generate_checksum
  checksum_fields = @fields["pmt_url"] + @fields["orderAmount"].to_s + @fields["merchantTxnId"] + @fields["currency"]
  Citrus.checksum(@fields["secret_key"],  checksum_fields )
end