Class: ActiveMerchant::Billing::Integrations::Ipay88::Helper
- Includes:
- RequiresParameters
- Defined in:
- lib/active_merchant/billing/integrations/ipay88/helper.rb
Constant Summary collapse
- SUPPORTED_CURRENCIES =
Currencies supported
MYR (Malaysian Ringgit - for all payment methods except China Union Pay and PayPal) USD (US Dollar - only for PayPal) CNY (Yuan Renminbi - only for China Union Pay)
%w[MYR USD CNY]
- SUPPORTED_LANGS =
Languages supported
ISO-8859-1 (English) UTF-8 (Unicode) GB2312 (Chinese Simplified) GD18030 (Chinese Simplified) BIG5 (Chinese Traditional)
%w[ISO-8859-1 UTF-8 GB2312 GD18030 BIG5]
- PAYMENT_METHODS =
Payment methods supported
8 (Alliance Online Transfer) 10 (AmBank) 21 (China Union Pay) 20 (CIMB Click) 2 (Credit Card MYR) 16 (FPX) 15 (Hong Leong Bank Transfer) 6 (Maybank2u.com) 23 (MEPS Cash) 17 (Mobile Money) 33 (PayPal) 14 (RHB)
%w[8 10 21 20 2 16 15 6 23 17 33 14]
Instance Attribute Summary collapse
-
#amount_in_cents ⇒ Object
readonly
Returns the value of attribute amount_in_cents.
Attributes inherited from Helper
Class Method Summary collapse
-
.sign(str) ⇒ Object
Generate a Base64-encoded SHA1 given a string.
Instance Method Summary collapse
- #amount=(money) ⇒ Object
- #currency(symbol) ⇒ Object
-
#initialize(order, account, options = {}) ⇒ Helper
constructor
A new instance of Helper.
- #language(lang) ⇒ Object
- #payment(pay_method) ⇒ Object
- #signature ⇒ Object
Methods included from RequiresParameters
Methods inherited from Helper
#add_field, #add_fields, #billing_address, #form_fields, mapping, #shipping_address
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
41 42 43 44 45 46 |
# File 'lib/active_merchant/billing/integrations/ipay88/helper.rb', line 41 def initialize(order, account, = {}) requires!(, :amount, :currency) @amount_in_cents = [:amount] super add_field mappings[:signature], signature end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveMerchant::Billing::Integrations::Helper
Instance Attribute Details
#amount_in_cents ⇒ Object (readonly)
Returns the value of attribute amount_in_cents.
39 40 41 |
# File 'lib/active_merchant/billing/integrations/ipay88/helper.rb', line 39 def amount_in_cents @amount_in_cents end |
Class Method Details
.sign(str) ⇒ Object
Generate a Base64-encoded SHA1 given a string
72 73 74 |
# File 'lib/active_merchant/billing/integrations/ipay88/helper.rb', line 72 def self.sign(str) [Digest::SHA1.digest(str)].pack("m").chomp end |
Instance Method Details
#amount=(money) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/active_merchant/billing/integrations/ipay88/helper.rb', line 48 def amount=(money) cents = money.respond_to?(:cents) ? money.cents : money if money.is_a?(String) or cents.to_i < 0 raise ArgumentError, "money amount must be either a Money object or a positive integer in cents." end add_field mappings[:amount], sprintf("%.2f", cents.to_f/100) end |
#currency(symbol) ⇒ Object
56 57 58 59 |
# File 'lib/active_merchant/billing/integrations/ipay88/helper.rb', line 56 def currency(symbol) raise ArgumentError, "unsupported currency" unless SUPPORTED_CURRENCIES.include?(symbol) add_field mappings[:currency], symbol end |
#language(lang) ⇒ Object
61 62 63 64 |
# File 'lib/active_merchant/billing/integrations/ipay88/helper.rb', line 61 def language(lang) raise ArgumentError, "unsupported language" unless SUPPORTED_LANGS.include?(lang) add_field mappings[:language], lang end |
#payment(pay_method) ⇒ Object
66 67 68 69 |
# File 'lib/active_merchant/billing/integrations/ipay88/helper.rb', line 66 def payment(pay_method) raise ArgumentError, "unsupported payment method" unless PAYMENT_METHODS.include?(pay_method.to_s) add_field mappings[:payment], pay_method end |
#signature ⇒ Object
76 77 78 |
# File 'lib/active_merchant/billing/integrations/ipay88/helper.rb', line 76 def signature self.class.sign(self.sig_components) end |