class OffsitePayments::Integrations::Universal::Helper
Constants
- CURRENCY_SPECIAL_MINOR_UNITS
Public Class Methods
new(order, account, options = {})
click to toggle source
Calls superclass method
# File lib/offsite_payments/integrations/universal.rb, line 49 def initialize(order, account, options = {}) @forward_url = options[:forward_url] @key = options[:credential2] @currency = options[:currency] super self.country = options[:country] self.account_name = options[:account_name] self.transaction_type = options[:transaction_type] add_field 'x_test', @test.to_s end
Public Instance Methods
amount=(amount)
click to toggle source
# File lib/offsite_payments/integrations/universal.rb, line 68 def amount=(amount) add_field 'x_amount', format_amount(amount, @currency) end
credential_based_url()
click to toggle source
# File lib/offsite_payments/integrations/universal.rb, line 60 def credential_based_url @forward_url end
form_fields()
click to toggle source
# File lib/offsite_payments/integrations/universal.rb, line 64 def form_fields sign_fields end
generate_signature()
click to toggle source
# File lib/offsite_payments/integrations/universal.rb, line 84 def generate_signature Universal.sign(@fields, @key) end
shipping(amount)
click to toggle source
# File lib/offsite_payments/integrations/universal.rb, line 72 def shipping(amount) add_field 'x_amount_shipping', format_amount(amount, @currency) end
sign_fields()
click to toggle source
# File lib/offsite_payments/integrations/universal.rb, line 80 def sign_fields @fields.merge!('x_signature' => generate_signature) end
tax(amount)
click to toggle source
# File lib/offsite_payments/integrations/universal.rb, line 76 def tax(amount) add_field 'x_amount_tax', format_amount(amount, @currency) end
Private Instance Methods
format_amount(amount, currency)
click to toggle source
# File lib/offsite_payments/integrations/universal.rb, line 119 def format_amount(amount, currency) units = CURRENCY_SPECIAL_MINOR_UNITS[currency] || 2 sprintf("%.#{units}f", amount) end