Class: ActiveMerchant::Billing::Integrations::WirecardCheckoutPage::Helper

Inherits:
Helper
  • Object
show all
Includes:
Common
Defined in:
lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb

Constant Summary collapse

PLUGIN_NAME =
'ActiveMerchant_WirecardCheckoutPage'
PLUGIN_VERSION =
'1.0.0'

Instance Attribute Summary

Attributes inherited from Helper

#fields

Instance Method Summary collapse

Methods included from Common

#message, #verify_response

Methods inherited from Helper

#add_field, #add_fields, #add_raw_html_field, #billing_address, #form_method, mapping, #raw_html_fields, #shipping_address, #test?

Constructor Details

#initialize(order, customer_id, options = {}) ⇒ Helper

Returns a new instance of Helper.



74
75
76
77
78
79
80
81
82
83
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb', line 74

def initialize(order, customer_id, options = {})
  @paymenttype = options.delete(:paymenttype)

  raise "Unknown Paymenttype: " + @paymenttype if paymenttypes.find_index(@paymenttype) == nil

  @secret = options.delete(:secret)
  @customer_id = customer_id
  @shop_id = options.delete(:shop_id)
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveMerchant::Billing::Integrations::Helper

Instance Method Details

#add_request_fingerprint(fpfields) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb', line 101

def add_request_fingerprint(fpfields)
  addfields = {}
  fingerprint_order = %w(secret)
  fingerprint_values = @secret.to_s
  fpfields.each { |key, value|
    next if key == 'pluginVersion'
    fingerprint_order.append key
    fingerprint_values += value.to_s
  }

  fingerprint_order.append 'requestFingerprintOrder'
  fingerprint_values += fingerprint_order.join(',')

  addfields['requestFingerprintOrder'] = fingerprint_order.join(',')
  addfields['requestFingerprint'] = Digest::MD5.hexdigest(fingerprint_values)

  return addfields
end

#add_standard_fieldsObject



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb', line 89

def add_standard_fields
  addfields = {}
  addfields['shopId'] = @shop_id if !@shop_id.blank?
  addfields['paymentType'] = @paymenttype

  addfields[mappings[:pending_url]] = @fields[mappings[:return_url]] unless @fields.has_key?(mappings[:pending_url])
  addfields[mappings[:cancel_return_url]] = @fields[mappings[:return_url]] unless @fields.has_key?(mappings[:cancel_return_url])
  addfields[mappings[:failure_url]] = @fields[mappings[:return_url]] unless @fields.has_key?(mappings[:failure_url])

  addfields
end

#add_version(shop_name, shop_version) ⇒ Object



85
86
87
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb', line 85

def add_version(shop_name, shop_version)
  add_field('pluginVersion', Base64.encode64(shop_name + ';' + shop_version + ';ActiveMerchant;' + PLUGIN_NAME + ';' + PLUGIN_VERSION))
end

#customer_idObject



132
133
134
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb', line 132

def customer_id
  @customer_id
end

#form_fieldsObject



120
121
122
123
124
125
126
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb', line 120

def form_fields
  result = {}
  result.merge!(@fields)
  result.merge!(add_standard_fields)
  result.merge!(add_request_fingerprint(result))
  result
end

#secretObject



128
129
130
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb', line 128

def secret
  @secret
end

#shop_idObject



136
137
138
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb', line 136

def shop_id
  @shop_id
end