Class: ActiveMerchant::Billing::PaypalAdaptivePaymentGateway

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

Constant Summary collapse

TEST_URL =
'https://svcs.sandbox.paypal.com/AdaptivePayments'
LIVE_URL =
'https://svcs.paypal.com/AdaptivePayments'
API_VERSION =
'1.1.0'
SUCCESS_CODES =
[ 'Success', 'SuccessWithWarning' ]
PAYMENT_PERIODS =
['DAILY', 'WEEKLY', 'BIWEEKLY', 'SEMIMONTHLY', 'MONTHLY', 'ANNUALLY']
FEES_PAYER_OPTIONS =
['SENDER', 'PRIMARYRECEIVER', 'EACHRECEIVER', 'SECONDARYONLY']

Constants inherited from Gateway

Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods included from PaypalExpressCommon

included, #redirect_url

Methods inherited from Gateway

#card_brand, card_brand, inherited, supports?, #test?

Methods included from Utils

generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #ssl_get, #ssl_post

Constructor Details

#initialize(options = {}) ⇒ PaypalAdaptivePaymentGateway

Returns a new instance of PaypalAdaptivePaymentGateway.



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

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

Instance Method Details

#pay(*args) ⇒ Object

Pay money to one or more recievers

gateway.pay 1000, '[email protected]',
  :sender_email => "[email protected]", :return_url => "http://example.com/return", :cancel_url => "http://example.com/cancel"

gateway.pay [1000, '[email protected]'],
  [2450, '[email protected]', :primary => true],
  [2000, '[email protected]'],
  :sender_email => "[email protected]", :return_url => "http://example.com/return", :cancel_url => "http://example.com/cancel"


53
54
55
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments.rb', line 53

def pay(*args)
  commit('Pay', build_pay_request(*args))
end

#payment_details(token, options = {}) ⇒ Object



57
58
59
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments.rb', line 57

def payment_details(token, options = {})
  commit('PaymentDetails', build_payment_details_request(token, options))
end

#preapproval(options) ⇒ Object



61
62
63
64
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments.rb', line 61

def preapproval(options)
  requires!(options, :return_url, :cancel_url, :ending_date)
  commit('Preapproval', build_preapproval_request(options))
end

#preapproval_details(token, options = {}) ⇒ Object



66
67
68
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments.rb', line 66

def preapproval_details(token, options = {})
  commit('PreapprovalDetails', build_preapproval_details_request(token, options))
end

#redirect_url_for(token, options = {}) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments.rb', line 74

def redirect_url_for(token, options = {})
  if token =~ /AP\-/
    "#{redirect_url}_ap-payment&payKey=#{token}"
  elsif token =~ /PA\-/
    "#{redirect_url}_ap-preapproval&preapprovalkey=#{token}"
  end
end

#refund(*args) ⇒ Object



70
71
72
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments.rb', line 70

def refund(*args)
  commit('Refund', build_refund_request(*args))
end