Class: OffsitePayments::Integrations::DirecPay::Helper
- Defined in:
- lib/offsite_payments/integrations/direc_pay.rb
Constant Summary collapse
- OPERATING_MODE =
'DOM'
- COUNTRY =
'IND'
- CURRENCY =
'INR'
- OTHER_DETAILS =
'NULL'
- EDIT_ALLOWED =
'Y'
- PHONE_CODES =
{ 'IN' => '91', 'US' => '01', 'CA' => '01' }
- ENCODED_PARAMS =
[ :account, :operating_mode, :country, :currency, :amount, :order, :other_details, :return_url, :failure_url, :collaborator ]
Instance Attribute Summary
Attributes inherited from Helper
Instance Method Summary collapse
-
#amount=(money) ⇒ Object
Need to format the amount to have 2 decimal places.
- #billing_address(params = {}) ⇒ Object
- #customer(params = {}) ⇒ Object
- #form_fields ⇒ Object
-
#initialize(order, account, options = {}) ⇒ Helper
constructor
A new instance of Helper.
- #shipping_address(params = {}) ⇒ Object
Methods inherited from Helper
#add_field, #add_fields, #add_raw_html_field, #form_method, inherited, mapping, #raw_html_fields, #test?
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
82 83 84 85 86 87 88 89 90 |
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 82 def initialize(order, account, = {}) super collaborator = OffsitePayments.mode == :test || [:test] ? 'TOML' : 'DirecPay' add_field(mappings[:collaborator], collaborator) add_field(mappings[:country], 'IND') add_field(mappings[:operating_mode], OPERATING_MODE) add_field(mappings[:other_details], OTHER_DETAILS) add_field(mappings[:edit_allowed], EDIT_ALLOWED) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OffsitePayments::Helper
Instance Method Details
#amount=(money) ⇒ Object
Need to format the amount to have 2 decimal places
99 100 101 102 103 104 105 |
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 99 def amount=(money) cents = money.respond_to?(:cents) ? money.cents : money raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String) raise ActionViewHelperError, "amount must be greater than $0.00" if cents.to_i <= 0 add_field(mappings[:amount], sprintf("%.2f", cents.to_f/100)) end |
#billing_address(params = {}) ⇒ Object
111 112 113 |
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 111 def billing_address(params = {}) super(update_address(:billing_address, params)) end |
#customer(params = {}) ⇒ Object
93 94 95 96 |
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 93 def customer(params = {}) add_field(mappings[:customer][:name], full_name(params)) add_field(mappings[:customer][:email], params[:email]) end |
#form_fields ⇒ Object
115 116 117 118 119 120 |
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 115 def form_fields add_failure_url add_request_parameters unencoded_parameters end |
#shipping_address(params = {}) ⇒ Object
107 108 109 |
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 107 def shipping_address(params = {}) super(update_address(:shipping_address, params)) end |