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::API_VERSION, ActiveMerchant::Billing::PaypalCommonAPI::AUSTRALIAN_STATES, ActiveMerchant::Billing::PaypalCommonAPI::CREDENTIALS_NAMESPACES, ActiveMerchant::Billing::PaypalCommonAPI::EBAY_NAMESPACE, ActiveMerchant::Billing::PaypalCommonAPI::ENVELOPE_NAMESPACES, ActiveMerchant::Billing::PaypalCommonAPI::PAYPAL_NAMESPACE, ActiveMerchant::Billing::PaypalCommonAPI::SUCCESS_CODES, ActiveMerchant::Billing::PaypalCommonAPI::URLS

Constants inherited from Gateway

Gateway::DEBIT_CARDS

Constants included from PostsData

PostsData::MAX_RETRIES, PostsData::OPEN_TIMEOUT, PostsData::READ_TIMEOUT

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods included from PaypalCommonAPI

#capture, #credit, included, #initialize, #reauthorize, #test?, #transfer, #void

Methods inherited from Gateway

inherited, #initialize, supports?, #test?

Methods included from Utils

generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #retry_exceptions, #ssl_post

Instance Method Details

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



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

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

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

#details_for(token) ⇒ Object



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

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

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



47
48
49
50
51
# File 'lib/active_merchant/billing/gateways/paypal_express.rb', line 47

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

#redirect_urlObject



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

def redirect_url
  test? ? TEST_REDIRECT_URL : LIVE_REDIRECT_URL 
end

#redirect_url_for(token) ⇒ Object



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

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

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



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

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



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

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