Class: ActiveMerchant::Billing::PaypalExpressGateway

Inherits:
Gateway
  • Object
show all
Includes:
PaypalCommonAPI
Defined in:
lib/active_merchant/billing/gateways/paypal_express.rb

Constant Summary collapse

LIVE_REDIRECT_URL =
'https://www.paypal.com/cgibin/webscr?cmd=_express-checkout&token='
TEST_REDIRECT_URL =
'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='

Constants included from PaypalCommonAPI

ActiveMerchant::Billing::PaypalCommonAPI::CREDENTIALS_NAMESPACES, ActiveMerchant::Billing::PaypalCommonAPI::ENVELOPE_NAMESPACES, ActiveMerchant::Billing::PaypalCommonAPI::LIVE_URL, ActiveMerchant::Billing::PaypalCommonAPI::TEST_URL

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods included from PaypalCommonAPI

#capture, included, #initialize, #test?, #void

Methods inherited from Gateway

gateway, #initialize, supported_cardtypes, supports?, #test?

Methods included from RequiresParameters

#requires!

Methods included from PostsData

#included?, #ssl_post

Instance Method Details

#authorize(money, options = {}) ⇒ Object



36
37
38
39
40
# File 'lib/active_merchant/billing/gateways/paypal_express.rb', line 36

def authorize(money, options = {})
  requires!(options, :token, :payer_id)

  commit 'DoExpressCheckoutPayment', build_sale_or_authorization_request('Authorization', money, options)
end

#details_for(token) ⇒ Object



32
33
34
# File 'lib/active_merchant/billing/gateways/paypal_express.rb', line 32

def details_for(token)
  commit 'GetExpressCheckoutDetails', build_get_details_request(token)
end

#purchase(money, token, payer_id, options = {}) ⇒ Object



42
43
44
45
46
# File 'lib/active_merchant/billing/gateways/paypal_express.rb', line 42

def purchase(money, token, payer_id, options = {})
  requires!(options, :token, :payer_id)
  
  commit 'DoExpressCheckoutPayment', build_sale_or_authorization_request('Sale', money, options)
end

#redirect_urlObject



12
13
14
# File 'lib/active_merchant/billing/gateways/paypal_express.rb', line 12

def redirect_url
  test? ? TEST_REDIRECT_URL : LIVE_REDIRECT_URL 
end

#redirect_url_for(token) ⇒ Object



16
17
18
# File 'lib/active_merchant/billing/gateways/paypal_express.rb', line 16

def redirect_url_for(token)
  "#{redirect_url}#{token}"
end

#setup_authorization(money, options = {}) ⇒ Object



20
21
22
23
24
# File 'lib/active_merchant/billing/gateways/paypal_express.rb', line 20

def setup_authorization(money, options = {})
  requires!(options, :return_url, :cancel_return_url)
  
  commit 'SetExpressCheckout', build_setup_request('Authorization', money, options)
end

#setup_purchase(money, options = {}) ⇒ Object



26
27
28
29
30
# File 'lib/active_merchant/billing/gateways/paypal_express.rb', line 26

def setup_purchase(money, options = {})
  requires!(options, :return_url, :cancel_return_url)
  
  commit 'SetExpressCheckout', build_setup_request('Sale', money, options)
end