class OffsitePayments::Integrations::Megakassa::Helper
Public Class Methods
new(order, account, options = {})
click to toggle source
Calls superclass method
# File lib/offsite_payments/integrations/megakassa.rb, line 52 def initialize(order, account, options = {}) @md5secret = options.delete(:secret) super add_field :debug, test? ? '1' : '' add_field :amount, normalize_amount(options[:amount]) add_field :description, options[:description] end
Public Instance Methods
form_fields()
click to toggle source
# File lib/offsite_payments/integrations/megakassa.rb, line 62 def form_fields @fields.merge(OffsitePayments::Integrations::Megakassa.signature_parameter_name => generate_signature) end
generate_signature()
click to toggle source
# File lib/offsite_payments/integrations/megakassa.rb, line 43 def generate_signature Digest::MD5.hexdigest(secret + Digest::MD5.hexdigest(generate_signature_string)) end
generate_signature_string()
click to toggle source
# File lib/offsite_payments/integrations/megakassa.rb, line 39 def generate_signature_string "#{params['shop_id']}:#{params['amount']}:#{params['currency']}:#{params['description']}:#{params['order_id']}:#{params['method_id']}:#{params['client_email']}:#{params['debug']}:#{secret}" end
normalize_amount(amount)
click to toggle source
# File lib/offsite_payments/integrations/megakassa.rb, line 47 def normalize_amount(amount) int, float = amount.to_i, amount.to_f int == float ? int : float end
params()
click to toggle source
# File lib/offsite_payments/integrations/megakassa.rb, line 66 def params @fields end
secret()
click to toggle source
# File lib/offsite_payments/integrations/megakassa.rb, line 70 def secret @md5secret end