Sha256: 0db66590ea508011fefed3c6284fe0ef80c2a6d74088a7550893160512ff38b6

Contents?: true

Size: 921 Bytes

Versions: 12

Compression:

Stored size: 921 Bytes

Contents

module ActiveMerchant
  module Billing
    module PaypalExpressCommon
      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

      def redirect_url
        test? ? test_redirect_url : live_redirect_url
      end

      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
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
activemerchant-1.114.0 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.113.0 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.112.0 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.111.0 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.110.0 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.109.0 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.108.0 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.107.4 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.107.3 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.107.2 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.107.1 lib/active_merchant/billing/gateways/paypal_express_common.rb
activemerchant-1.106.0 lib/active_merchant/billing/gateways/paypal_express_common.rb