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?

Methods included from MoneyCompatibility

#to_cents

Constructor Details

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

Returns a new instance of Helper.



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

def initialize(order, , options = {})
  super
  add_field 'paymentMode', 'NET_BANKING'
  add_field 'reqtime', (Time.now.to_i * 1000).to_s
  @secret_key = options[:credential2]
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



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

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



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

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

#generate_checksumObject



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

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