Class: OffsitePayments::Integrations::WirecardCheckoutPage::Helper

Inherits:
Helper
  • Object
show all
Includes:
Common
Defined in:
lib/offsite_payments/integrations/wirecard_checkout_page.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, inherited, mapping, #raw_html_fields, #shipping_address, #test?

Constructor Details

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

Returns a new instance of Helper.



174
175
176
177
178
179
180
181
182
183
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 174

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 OffsitePayments::Helper

Instance Method Details

#add_request_fingerprint(fpfields) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 201

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)

  addfields
end

#add_standard_fieldsObject



189
190
191
192
193
194
195
196
197
198
199
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 189

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



185
186
187
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 185

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

#customer_idObject



232
233
234
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 232

def customer_id
  @customer_id
end

#form_fieldsObject



220
221
222
223
224
225
226
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 220

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

#secretObject



228
229
230
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 228

def secret
  @secret
end

#shop_idObject



236
237
238
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 236

def shop_id
  @shop_id
end