Module: ActiveMerchant::Billing::PaypalCommonAPI
- Included in:
- PaypalExpressGateway, PaypalGateway
- Defined in:
- lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb
Overview
This module is included in both PaypalGateway and PaypalExpressGateway
Constant Summary collapse
- API_VERSION =
'72'
- URLS =
{ :test => { :certificate => 'https://api.sandbox.paypal.com/2.0/', :signature => 'https://api-3t.sandbox.paypal.com/2.0/' }, :live => { :certificate => 'https://api-aa.paypal.com/2.0/', :signature => 'https://api-3t.paypal.com/2.0/' } }
- PAYPAL_NAMESPACE =
'urn:ebay:api:PayPalAPI'
- EBAY_NAMESPACE =
'urn:ebay:apis:eBLBaseComponents'
- ENVELOPE_NAMESPACES =
{ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' }
- CREDENTIALS_NAMESPACES =
{ 'xmlns' => PAYPAL_NAMESPACE, 'xmlns:n1' => EBAY_NAMESPACE, 'env:mustUnderstand' => '0' }
- AUSTRALIAN_STATES =
{ 'ACT' => 'Australian Capital Territory', 'NSW' => 'New South Wales', 'NT' => 'Northern Territory', 'QLD' => 'Queensland', 'SA' => 'South Australia', 'TAS' => 'Tasmania', 'VIC' => 'Victoria', 'WA' => 'Western Australia' }
- SUCCESS_CODES =
[ 'Success', 'SuccessWithWarning' ]
- FRAUD_REVIEW_CODE =
"11610"
Class Method Summary collapse
Instance Method Summary collapse
- #capture(money, authorization, options = {}) ⇒ Object
- #credit(money, identification, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Object
The gateway must be configured with either your PayPal PEM file or your PayPal API Signature.
- #reauthorize(money, authorization, options = {}) ⇒ Object
- #refund(money, identification, options = {}) ⇒ Object
- #test? ⇒ Boolean
-
#transfer(*args) ⇒ Object
Transfer money to one or more recipients.
- #void(authorization, options = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 |
# File 'lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb', line 5 def self.included(base) base.default_currency = 'USD' base.cattr_accessor :pem_file base.cattr_accessor :signature end |
Instance Method Details
#capture(money, authorization, options = {}) ⇒ Object
89 90 91 |
# File 'lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb', line 89 def capture(money, , = {}) commit 'DoCapture', build_capture_request(money, , ) end |
#credit(money, identification, options = {}) ⇒ Object
115 116 117 118 |
# File 'lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb', line 115 def credit(money, identification, = {}) deprecated Gateway::CREDIT_DEPRECATION_MESSAGE refund(money, identification, ) end |
#initialize(options = {}) ⇒ Object
The gateway must be configured with either your PayPal PEM file or your PayPal API Signature. Only one is required.
:pem
The text of your PayPal PEM file. Note
this is not the path to file, but its
contents. If you are only using one PEM
file on your site you can declare it
globally and then you won't need to
include this option
:signature
The text of your PayPal signature.
If you are only using one API Signature
on your site you can declare it
globally and then you won't need to
include this option
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb', line 63 def initialize( = {}) requires!(, :login, :password) headers = {'X-PP-AUTHORIZATION' => .delete(:auth_signature), 'X-PAYPAL-MESSAGE-PROTOCOL' => 'SOAP11'} if [:auth_signature] @options = { :pem => pem_file, :signature => signature, :headers => headers || {} }.update() if @options[:pem].blank? && @options[:signature].blank? raise ArgumentError, "An API Certificate or API Signature is required to make requests to PayPal" end super end |
#reauthorize(money, authorization, options = {}) ⇒ Object
85 86 87 |
# File 'lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb', line 85 def (money, , = {}) commit 'DoReauthorization', (money, , ) end |
#refund(money, identification, options = {}) ⇒ Object
111 112 113 |
# File 'lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb', line 111 def refund(money, identification, = {}) commit 'RefundTransaction', build_refund_request(money, identification, ) end |
#test? ⇒ Boolean
81 82 83 |
# File 'lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb', line 81 def test? @options[:test] || Base.gateway_mode == :test end |
#transfer(*args) ⇒ Object
Transfer money to one or more recipients.
gateway.transfer 1000, '[email protected]',
:subject => "The money I owe you", :note => "Sorry it's so late"
gateway.transfer [1000, '[email protected]'],
[2450, '[email protected]', :note => 'You will receive another payment on 3/24'],
[2000, '[email protected]'],
:subject => "Your Earnings", :note => "Thanks for your business."
103 104 105 |
# File 'lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb', line 103 def transfer(*args) commit 'MassPay', build_mass_pay_request(*args) end |
#void(authorization, options = {}) ⇒ Object
107 108 109 |
# File 'lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb', line 107 def void(, = {}) commit 'DoVoid', build_void_request(, ) end |