Class: OffsitePayments::Integrations::Molpay::Helper
- Includes:
- ActiveUtils::RequiresParameters
- Defined in:
- lib/offsite_payments/integrations/molpay.rb
Overview
(Optional Parameter) = channel //will generate URL to go directly to specific channel, e.g maybank2u, cimb
Please refer MOLPay API spec for the channel routing
Constant Summary collapse
- SUPPORTED_CURRENCIES =
['MYR', 'USD', 'SGD', 'PHP', 'VND', 'IDR', 'AUD', 'CNY', 'THB', 'GBP', 'EUR', 'HKD']
- SUPPORTED_LANGUAGES =
Defaults to en
['en', 'cn']
- SERVICE_URL =
'https://www.onlinepayment.com.my/MOLPay/pay/'.freeze
Instance Attribute Summary collapse
-
#amount_in_cents ⇒ Object
readonly
Returns the value of attribute amount_in_cents.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#verify_key ⇒ Object
readonly
Returns the value of attribute verify_key.
Attributes inherited from Helper
Instance Method Summary collapse
- #amount=(money) ⇒ Object
- #credential_based_url ⇒ Object
- #currency=(cur) ⇒ Object
- #form_fields ⇒ Object
-
#initialize(order, account, options = {}) ⇒ Helper
constructor
A new instance of Helper.
- #language=(lang) ⇒ 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.
50 51 52 53 54 55 56 |
# File 'lib/offsite_payments/integrations/molpay.rb', line 50 def initialize(order, account, = {}) requires!(, :amount, :currency, :credential2) @verify_key = [:credential2] if [:credential2] @amount_in_cents = [:amount] @channel = .delete(:channel) super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OffsitePayments::Helper
Instance Attribute Details
#amount_in_cents ⇒ Object (readonly)
Returns the value of attribute amount_in_cents.
42 43 44 |
# File 'lib/offsite_payments/integrations/molpay.rb', line 42 def amount_in_cents @amount_in_cents end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
42 43 44 |
# File 'lib/offsite_payments/integrations/molpay.rb', line 42 def channel @channel end |
#verify_key ⇒ Object (readonly)
Returns the value of attribute verify_key.
42 43 44 |
# File 'lib/offsite_payments/integrations/molpay.rb', line 42 def verify_key @verify_key end |
Instance Method Details
#amount=(money) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/offsite_payments/integrations/molpay.rb', line 63 def amount=(money) unless money > 0 raise ArgumentError, "amount must be greater than $0.00." end add_field mappings[:amount], sprintf("%.2f", money.to_f) end |
#credential_based_url ⇒ Object
44 45 46 47 48 |
# File 'lib/offsite_payments/integrations/molpay.rb', line 44 def credential_based_url service_url = SERVICE_URL + @fields[mappings[:account]] + "/" service_url = service_url + @channel if @channel service_url end |
#currency=(cur) ⇒ Object
70 71 72 73 |
# File 'lib/offsite_payments/integrations/molpay.rb', line 70 def currency=(cur) raise ArgumentError, "unsupported currency" unless SUPPORTED_CURRENCIES.include?(cur) add_field mappings[:currency], cur end |
#form_fields ⇒ Object
58 59 60 61 |
# File 'lib/offsite_payments/integrations/molpay.rb', line 58 def form_fields add_field mappings[:signature], signature @fields end |
#language=(lang) ⇒ Object
75 76 77 78 |
# File 'lib/offsite_payments/integrations/molpay.rb', line 75 def language=(lang) raise ArgumentError, "unsupported language" unless SUPPORTED_LANGUAGES.include?(lang) add_field mappings[:language], lang end |