WorldPay supports two different test modes - :always_succeed and :always_fail
# File lib/active_merchant/billing/integrations/world_pay/helper.rb, line 22 22: def initialize(order, account, options = {}) 23: super 24: 25: if ActiveMerchant::Billing::Base.integration_mode == :test || options[:test] 26: test_mode = case options[:test] 27: when :always_fail 28: 101 29: when false 30: 0 31: else 32: 100 33: end 34: add_field('testMode', test_mode.to_s) 35: elsif ActiveMerchant::Billing::Base.integration_mode == :always_succeed 36: add_field('testMode', '100') 37: elsif ActiveMerchant::Billing::Base.integration_mode == :always_fail 38: add_field('testMode', '101') 39: end 40: end
WorldPay only supports a single address field so we have to concat together - lines are separated using
# File lib/active_merchant/billing/integrations/world_pay/helper.rb, line 44 44: def billing_address(params={}) 45: add_field(mappings[:billing_address][:zip], params[:zip]) 46: add_field(mappings[:billing_address][:country], lookup_country_code(params[:country])) 47: 48: address = [params[:address1], params[:address2], params[:city], params[:state]].compact 49: add_field('address', address.join(' ')) 50: end
# File lib/active_merchant/billing/integrations/world_pay/helper.rb, line 89 89: def callback_params(params={}) 90: params.each{|k,v| add_field("M_#{k}",v)} 91: end
# File lib/active_merchant/billing/integrations/world_pay/helper.rb, line 93 93: def combined_params(params={}) 94: params.each{|k,v| add_field("MC_#{k}",v)} 95: end
WorldPay only supports a single name field so we have to concat
# File lib/active_merchant/billing/integrations/world_pay/helper.rb, line 53 53: def customer(params={}) 54: add_field(mappings[:customer][:email], params[:email]) 55: add_field(mappings[:customer][:phone], params[:phone]) 56: add_field('name', "#{params[:first_name]} #{params[:last_name]}") 57: end
Support for a MD5 hash of selected fields to prevent tampering For futher information read the tech note at the address below: support.worldpay.com/kb/integration_guides/junior/integration/help/tech_notes/sjig_tn_009.html
# File lib/active_merchant/billing/integrations/world_pay/helper.rb, line 62 62: def encrypt(secret, fields = [:amount, :currency, :account, :order]) 63: signature_fields = fields.collect{ |field| mappings[field] } 64: add_field('signatureFields', signature_fields.join(':')) 65: 66: field_values = fields.collect{ |field| form_fields[mappings[field]] } 67: signature = "#{secret}:#{field_values.join(':')}" 68: add_field('signature', Digest::MD5.hexdigest(signature)) 69: end
WorldPay supports the passing of custom parameters prefixed with the following: C_ : These parameters can be used in the response pages hosted on WorldPay’s site M_ : These parameters are passed through to the callback script (if enabled) MC_ or CM_ : These parameters are availble both in the response and callback contexts
# File lib/active_merchant/billing/integrations/world_pay/helper.rb, line 85 85: def response_params(params={}) 86: params.each{|k,v| add_field("C_#{k}",v)} 87: end
Add a time window for which the payment can be completed. Read the link below for how they work support.worldpay.com/kb/integration_guides/junior/integration/help/appendicies/sjig_10100.html
# File lib/active_merchant/billing/integrations/world_pay/helper.rb, line 73 73: def valid_from(from_time) 74: add_field('authValidFrom', from_time.to_i.to_s + '000') 75: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.