Module: ActiveMerchant::Billing::PayflowCommonAPI

Included in:
PayflowExpressGateway, PayflowGateway
Defined in:
lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb

Constant Summary collapse

XMLNS =
'http://www.paypal.com/XMLPay'
CARD_MAPPING =
{
  :visa => 'Visa',
  :master => 'MasterCard',
  :discover => 'Discover',
  :american_express => 'Amex',
  :jcb => 'JCB',
  :diners_club => 'DinersClub',
}
TRANSACTIONS =
{
  :purchase       => 'Sale',
  :authorization  => 'Authorization',
  :capture        => 'Capture',
  :void           => 'Void',
  :credit         => 'Credit'
}
CVV_CODE =
{
  'Match' => 'M',
  'No Match' => 'N',
  'Service Not Available' => 'U',
  'Service not Requested' => 'P'
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb', line 5

def self.included(base)
  base.default_currency = 'USD'

  base.class_attribute :partner

  # Set the default partner to PayPal
  base.partner = 'PayPal'

  base.supported_countries = ['US', 'CA', 'NZ', 'AU']

  base.class_attribute :timeout
  base.timeout = 60

  base.test_url = 'https://pilot-payflowpro.paypal.com'
  base.live_url = 'https://payflowpro.paypal.com'

  # Enable safe retry of failed connections
  # Payflow is safe to retry because retried transactions use the same
  # X-VPS-Request-ID header. If a transaction is detected as a duplicate
  # only the original transaction data will be used by Payflow, and the
  # subsequent Responses will have a :duplicate parameter set in the params
  # hash.
  base.retry_safe = true

  # Send Payflow requests to PayPal directly by activating the NVP protocol.
  # Valid XMLPay documents may have issues being parsed correctly by
  # Payflow but will be accepted by PayPal if a PAYPAL-NVP request header
  # is declared.
  base.class_attribute :use_paypal_nvp
  base.use_paypal_nvp = false
end

Instance Method Details

#capture(money, authorization, options = {}) ⇒ Object



70
71
72
73
# File 'lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb', line 70

def capture(money, authorization, options = {})
  request = build_reference_request(:capture, money, authorization, options)
  commit(request, options)
end

#initialize(options = {}) ⇒ Object



63
64
65
66
67
68
# File 'lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb', line 63

def initialize(options = {})
  requires!(options, :login, :password)

  options[:partner] = partner if options[:partner].blank?
  super
end

#void(authorization, options = {}) ⇒ Object



75
76
77
78
# File 'lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb', line 75

def void(authorization, options = {})
  request = build_reference_request(:void, nil, authorization, options)
  commit(request, options)
end