Class Index [+]

Quicksearch

ActiveMerchant::Billing::Integrations::Paypal::Helper

Constants

CANADIAN_PROVINCES

Public Class Methods

new(order, account, options = {}) click to toggle source
    # File lib/active_merchant/billing/integrations/paypal/helper.rb, line 23
23:           def initialize(order, account, options = {})
24:             super
25:             add_field('cmd', '_ext-enter')
26:             add_field('redirect_cmd', '_xclick')
27:             add_field('quantity', 1)
28:             add_field('item_name', 'Store purchase')
29:             add_field('no_shipping', '1')
30:             add_field('no_note', '1')
31:             add_field('charset', 'utf-8')
32:             add_field('address_override', '0')
33:             add_field('bn', application_id.to_s.slice(0,32)) unless application_id.blank?
34:           end

Public Instance Methods

shipping_address(params = {}) click to toggle source
     # File lib/active_merchant/billing/integrations/paypal/helper.rb, line 62
 62:           def shipping_address(params = {})
 63: 
 64:             # Get the country code in the correct format
 65:             # Use what we were given if we can't find anything
 66:             country_code = lookup_country_code(params.delete(:country))
 67:             add_field(mappings[:shipping_address][:country], country_code)
 68:             
 69:             if params.has_key?(:phone)
 70:               phone = params.delete(:phone).to_s
 71:           
 72:               # Whipe all non digits
 73:               phone.gsub!(/\D+/, '')
 74:               
 75:               if ['US', 'CA'].include?(country_code) && phone =~ /(\d{3})(\d{3})(\d{4})$/
 76:                 add_field('night_phone_a', $1) 
 77:                 add_field('night_phone_b', $2) 
 78:                 add_field('night_phone_c', $3) 
 79:               else
 80:                 add_field('night_phone_b', phone)                
 81:               end
 82:             end
 83:               
 84:             province_code = params.delete(:state)
 85:                        
 86:             case country_code
 87:             when 'CA'
 88:               add_field(mappings[:shipping_address][:state], CANADIAN_PROVINCES[province_code.upcase]) unless province_code.nil?
 89:             when 'US'
 90:               add_field(mappings[:shipping_address][:state], province_code)
 91:             else
 92:               add_field(mappings[:shipping_address][:state], province_code.blank? ? 'N/A' : province_code)
 93:             end
 94:               
 95:             # Everything else 
 96:             params.each do |k, v|
 97:               field = mappings[:shipping_address][k]
 98:               add_field(field, v) unless field.nil?
 99:             end
100:           end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.