Module: ActiveMerchant::Billing::PaypalExpressCommon

Included in:
PayflowExpressGateway, PaypalExpressGateway
Defined in:
lib/active_merchant/billing/gateways/paypal_express_common.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/active_merchant/billing/gateways/paypal_express_common.rb', line 4

def self.included(base)
  if base.respond_to?(:class_attribute)
    base.class_attribute :test_redirect_url
    base.class_attribute :live_redirect_url
  else
    base.class_inheritable_accessor :test_redirect_url
    base.class_inheritable_accessor :live_redirect_url
  end
  base.live_redirect_url = 'https://www.paypal.com/cgi-bin/webscr'
end

Instance Method Details

#redirect_urlObject



15
16
17
# File 'lib/active_merchant/billing/gateways/paypal_express_common.rb', line 15

def redirect_url
  test? ? test_redirect_url : live_redirect_url
end

#redirect_url_for(token, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/active_merchant/billing/gateways/paypal_express_common.rb', line 19

def redirect_url_for(token, options = {})
  options = {review: true, mobile: false}.update(options)

  cmd  = options[:mobile] ? '_express-checkout-mobile' : '_express-checkout'
  url  = "#{redirect_url}?cmd=#{cmd}&token=#{token}"
  url += '&useraction=commit' unless options[:review]

  url
end