Class: ActiveMerchant::Billing::PaypalGateway

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

Direct Known Subclasses

PaypalCaGateway

Constant Summary

Constants included from PaypalRecurringApi

ActiveMerchant::Billing::PaypalRecurringApi::API_VERSION, ActiveMerchant::Billing::PaypalRecurringApi::EBAY_NAMESPACE, ActiveMerchant::Billing::PaypalRecurringApi::PAYPAL_NAMESPACE

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::FRAUD_REVIEW_CODE, ActiveMerchant::Billing::PaypalCommonAPI::PAYPAL_NAMESPACE, ActiveMerchant::Billing::PaypalCommonAPI::SUCCESS_CODES, ActiveMerchant::Billing::PaypalCommonAPI::URLS

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods included from PaypalRecurringApi

#bill_outstanding_amount, #cancel_recurring, #reactivate_recurring, #recurring, #status_recurring, #suspend_recurring, #update_recurring

Methods included from PaypalCommonAPI

#authorize_transaction, #balance, #capture, #credit, included, #initialize, #manage_pending_transaction, #reauthorize, #reference_transaction, #refund, #transaction_details, #transaction_search, #transfer, #void

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, #initialize, non_fractional_currency?, supported_countries, #supported_countries, supported_countries=, supports?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Instance Method Details

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


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

def authorize(money, credit_card_or_referenced_id, options = {})
  requires!(options, :ip)
  commit define_transaction_type(credit_card_or_referenced_id), build_sale_or_authorization_request('Authorization', money, credit_card_or_referenced_id, options)
end

#expressObject


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

def express
  @express ||= PaypalExpressGateway.new(@options)
end

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


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

def purchase(money, credit_card_or_referenced_id, options = {})
  requires!(options, :ip)
  commit define_transaction_type(credit_card_or_referenced_id), build_sale_or_authorization_request('Sale', money, credit_card_or_referenced_id, options)
end

#scrub(transcript) ⇒ Object


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

def scrub(transcript)
  transcript.
    gsub(%r((<n1:Password>).+(</n1:Password>)), '\1[FILTERED]\2').
    gsub(%r((<n1:Username>).+(</n1:Username>)), '\1[FILTERED]\2').
    gsub(%r((<n2:CreditCardNumber>).+(</n2:CreditCardNumber)), '\1[FILTERED]\2').
    gsub(%r((<n2:CVV2>).+(</n2:CVV2)), '\1[FILTERED]\2')
end

#supports_scrubbing?Boolean


41
42
43
# File 'lib/active_merchant/billing/gateways/paypal.rb', line 41

def supports_scrubbing?
  true
end

#verify(credit_card, options = {}) ⇒ Object


26
27
28
29
30
31
32
33
34
35
# File 'lib/active_merchant/billing/gateways/paypal.rb', line 26

def verify(credit_card, options = {})
  if %w(visa master).include?(credit_card.brand)
    authorize(0, credit_card, options)
  else
    MultiResponse.run(:use_first_response) do |r|
      r.process { authorize(100, credit_card, options) }
      r.process(:ignore_result) { void(r.authorization, options) }
    end
  end
end