aktivemerchant 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG +1596 -0
- data/CONTRIBUTORS +511 -0
- data/MIT-LICENSE +20 -0
- data/README.md +18 -0
- data/lib/active_merchant.rb +108 -0
- data/lib/active_merchant/billing.rb +13 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +72 -0
- data/lib/active_merchant/billing/check.rb +76 -0
- data/lib/active_merchant/billing/compatibility.rb +120 -0
- data/lib/active_merchant/billing/credit_card.rb +352 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +160 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +268 -0
- data/lib/active_merchant/billing/gateways.rb +17 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +209 -0
- data/lib/active_merchant/billing/gateways/alfabank.rb +117 -0
- data/lib/active_merchant/billing/gateways/app55.rb +176 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +419 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +976 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +105 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +314 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +188 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +393 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +506 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +140 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +210 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +515 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +20 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +189 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +220 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +191 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +201 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +229 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +213 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +209 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +709 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +600 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +219 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +348 -0
- data/lib/active_merchant/billing/gateways/epay.rb +275 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
- data/lib/active_merchant/billing/gateways/eway.rb +214 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +291 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +524 -0
- data/lib/active_merchant/billing/gateways/exact.rb +218 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +173 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +160 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +23 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +160 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +355 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +257 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +183 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/hps.rb +288 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +251 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +246 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +66 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +163 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +457 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +438 -0
- data/lib/active_merchant/billing/gateways/litle.rb +346 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +197 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +170 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +114 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +268 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +195 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +333 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/migs.rb +265 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +219 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +309 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +291 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +280 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +181 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +190 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +242 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +256 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +435 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +194 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +313 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +803 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +207 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +261 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +112 -0
- data/lib/active_merchant/billing/gateways/pay_u_latam.rb +462 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +188 -0
- data/lib/active_merchant/billing/gateways/payex.rb +412 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +304 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +209 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +353 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +281 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +117 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +670 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +264 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +162 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +199 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +197 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +216 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +303 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +292 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +367 -0
- data/lib/active_merchant/billing/gateways/realex.rb +298 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +391 -0
- data/lib/active_merchant/billing/gateways/sage.rb +175 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +87 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +114 -0
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +149 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +102 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +398 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +143 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +252 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +201 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +281 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +105 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +452 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +283 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +247 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +411 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +157 -0
- data/lib/active_merchant/billing/gateways/tns.rb +227 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +126 -0
- data/lib/active_merchant/billing/gateways/transax.rb +23 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +10 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +416 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1516 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +254 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +183 -0
- data/lib/active_merchant/billing/gateways/vindicia.rb +385 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +189 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +421 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +331 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +181 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/payment_token.rb +21 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +91 -0
- data/lib/active_merchant/country.rb +332 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +29 -0
- data/lib/active_merchant/offsite_payments_shim.rb +19 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/support/gateway_support.rb +71 -0
- data/lib/support/outbound_hosts.rb +25 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +400 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class PaypalExpressResponse < Response
|
4
|
+
def email
|
5
|
+
info['Payer']
|
6
|
+
end
|
7
|
+
|
8
|
+
def info
|
9
|
+
(@params['PayerInfo']||{})
|
10
|
+
end
|
11
|
+
|
12
|
+
def details
|
13
|
+
(@params['PaymentDetails']||{})
|
14
|
+
end
|
15
|
+
|
16
|
+
def name
|
17
|
+
payer = (info['PayerName']||{})
|
18
|
+
[payer['FirstName'], payer['MiddleName'], payer['LastName']].compact.join(' ')
|
19
|
+
end
|
20
|
+
|
21
|
+
def token
|
22
|
+
@params['Token']
|
23
|
+
end
|
24
|
+
|
25
|
+
def payer_id
|
26
|
+
info['PayerID']
|
27
|
+
end
|
28
|
+
|
29
|
+
def payer_country
|
30
|
+
info['PayerCountry']
|
31
|
+
end
|
32
|
+
|
33
|
+
# PayPal returns a contact telephone number only if your Merchant account
|
34
|
+
# profile settings require that the buyer enter one.
|
35
|
+
def contact_phone
|
36
|
+
@params['ContactPhone']
|
37
|
+
end
|
38
|
+
|
39
|
+
def address
|
40
|
+
address = (details['ShipToAddress']||{})
|
41
|
+
{ 'name' => address['Name'],
|
42
|
+
'company' => info['PayerBusiness'],
|
43
|
+
'address1' => address['Street1'],
|
44
|
+
'address2' => address['Street2'],
|
45
|
+
'city' => address['CityName'],
|
46
|
+
'state' => address['StateOrProvince'],
|
47
|
+
'country' => address['Country'],
|
48
|
+
'zip' => address['PostalCode'],
|
49
|
+
'phone' => (contact_phone || address['Phone'])
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def shipping
|
54
|
+
shipping = (@params['UserSelectedOptions']||{})
|
55
|
+
{ 'amount' => shipping['ShippingOptionAmount'],
|
56
|
+
'name' => shipping['ShippingOptionName']
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def note
|
61
|
+
@params['note_text']
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,262 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/paypal_common_api'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
# This module is included in both PaypalGateway and PaypalExpressGateway
|
6
|
+
module PaypalRecurringApi
|
7
|
+
PAYPAL_NAMESPACE = ActiveMerchant::Billing::PaypalCommonAPI::PAYPAL_NAMESPACE
|
8
|
+
API_VERSION = ActiveMerchant::Billing::PaypalCommonAPI::API_VERSION
|
9
|
+
EBAY_NAMESPACE = ActiveMerchant::Billing::PaypalCommonAPI::EBAY_NAMESPACE
|
10
|
+
# Create a recurring payment.
|
11
|
+
#
|
12
|
+
# This transaction creates a recurring payment profile
|
13
|
+
# ==== Parameters
|
14
|
+
#
|
15
|
+
# * <tt>amount</tt> -- The amount to be charged to the customer at each interval as an Integer value in cents.
|
16
|
+
# * <tt>credit_card</tt> -- The CreditCard details for the transaction.
|
17
|
+
# * <tt>options</tt> -- A hash of parameters.
|
18
|
+
#
|
19
|
+
# ==== Options
|
20
|
+
#
|
21
|
+
# * <tt>:period</tt> -- [Day, Week, SemiMonth, Month, Year] default: Month
|
22
|
+
# * <tt>:frequency</tt> -- a number
|
23
|
+
# * <tt>:cycles</tt> -- Limit to certain # of cycles (OPTIONAL)
|
24
|
+
# * <tt>:start_date</tt> -- When does the charging starts (REQUIRED)
|
25
|
+
# * <tt>:description</tt> -- The description to appear in the profile (REQUIRED)
|
26
|
+
|
27
|
+
def recurring(amount, credit_card, options = {})
|
28
|
+
ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE
|
29
|
+
|
30
|
+
options[:credit_card] = credit_card
|
31
|
+
options[:amount] = amount
|
32
|
+
requires!(options, :description, :start_date, :period, :frequency, :amount)
|
33
|
+
commit 'CreateRecurringPaymentsProfile', build_create_profile_request(options)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Update a recurring payment's details.
|
37
|
+
#
|
38
|
+
# This transaction updates an existing Recurring Billing Profile
|
39
|
+
# and the subscription must have already been created previously
|
40
|
+
# by calling +recurring()+. The ability to change certain
|
41
|
+
# details about a recurring payment is dependent on transaction history
|
42
|
+
# and the type of plan you're subscribed with paypal. Web Payment Pro
|
43
|
+
# seems to have the ability to update the most field.
|
44
|
+
#
|
45
|
+
# ==== Parameters
|
46
|
+
#
|
47
|
+
# * <tt>options</tt> -- A hash of parameters.
|
48
|
+
#
|
49
|
+
# ==== Options
|
50
|
+
#
|
51
|
+
# * <tt>:profile_id</tt> -- A string containing the <tt>:profile_id</tt>
|
52
|
+
# of the recurring payment already in place for a given credit card. (REQUIRED)
|
53
|
+
def update_recurring(options={})
|
54
|
+
ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE
|
55
|
+
|
56
|
+
requires!(options, :profile_id)
|
57
|
+
opts = options.dup
|
58
|
+
commit 'UpdateRecurringPaymentsProfile', build_change_profile_request(opts.delete(:profile_id), opts)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Cancel a recurring payment.
|
62
|
+
#
|
63
|
+
# This transaction cancels an existing recurring billing profile. Your account must have recurring billing enabled
|
64
|
+
# and the subscription must have already been created previously by calling recurring()
|
65
|
+
#
|
66
|
+
# ==== Parameters
|
67
|
+
#
|
68
|
+
# * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
|
69
|
+
# recurring payment already in place for a given credit card. (REQUIRED)
|
70
|
+
# * <tt>options</tt> -- A hash with extra info ('note' for ex.)
|
71
|
+
def cancel_recurring(profile_id, options = {})
|
72
|
+
ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE
|
73
|
+
|
74
|
+
raise_error_if_blank('profile_id', profile_id)
|
75
|
+
commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Cancel', options)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Get Subscription Status of a recurring payment profile.
|
79
|
+
#
|
80
|
+
# ==== Parameters
|
81
|
+
#
|
82
|
+
# * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
|
83
|
+
# recurring payment already in place for a given credit card. (REQUIRED)
|
84
|
+
def status_recurring(profile_id)
|
85
|
+
ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE
|
86
|
+
|
87
|
+
raise_error_if_blank('profile_id', profile_id)
|
88
|
+
commit 'GetRecurringPaymentsProfileDetails', build_get_profile_details_request(profile_id)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Suspends a recurring payment profile.
|
92
|
+
#
|
93
|
+
# ==== Parameters
|
94
|
+
#
|
95
|
+
# * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
|
96
|
+
# recurring payment already in place for a given credit card. (REQUIRED)
|
97
|
+
def suspend_recurring(profile_id, options = {})
|
98
|
+
ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE
|
99
|
+
|
100
|
+
raise_error_if_blank('profile_id', profile_id)
|
101
|
+
commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Suspend', options)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Reactivates a suspended recurring payment profile.
|
105
|
+
#
|
106
|
+
# ==== Parameters
|
107
|
+
#
|
108
|
+
# * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
|
109
|
+
# recurring payment already in place for a given credit card. (REQUIRED)
|
110
|
+
def reactivate_recurring(profile_id, options = {})
|
111
|
+
ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE
|
112
|
+
|
113
|
+
raise_error_if_blank('profile_id', profile_id)
|
114
|
+
commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Reactivate', options)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Bills outstanding amount to a recurring payment profile.
|
118
|
+
#
|
119
|
+
# ==== Parameters
|
120
|
+
#
|
121
|
+
# * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
|
122
|
+
# recurring payment already in place for a given credit card. (REQUIRED)
|
123
|
+
def bill_outstanding_amount(profile_id, options = {})
|
124
|
+
ActiveMerchant.deprecated Gateway::RECURRING_DEPRECATION_MESSAGE
|
125
|
+
|
126
|
+
raise_error_if_blank('profile_id', profile_id)
|
127
|
+
commit 'BillOutstandingAmount', build_bill_outstanding_amount(profile_id, options)
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
def raise_error_if_blank(field_name, field)
|
132
|
+
raise ArgumentError.new("Missing required parameter: #{field_name}") if field.blank?
|
133
|
+
end
|
134
|
+
def build_create_profile_request(options)
|
135
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
136
|
+
xml.tag! 'CreateRecurringPaymentsProfileReq', 'xmlns' => PAYPAL_NAMESPACE do
|
137
|
+
xml.tag! 'CreateRecurringPaymentsProfileRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
138
|
+
xml.tag! 'n2:Version', API_VERSION
|
139
|
+
xml.tag! 'n2:CreateRecurringPaymentsProfileRequestDetails' do
|
140
|
+
xml.tag! 'Token', options[:token] unless options[:token].blank?
|
141
|
+
if options[:credit_card]
|
142
|
+
add_credit_card(xml, options[:credit_card], (options[:billing_address] || options[:address]), options)
|
143
|
+
end
|
144
|
+
xml.tag! 'n2:RecurringPaymentsProfileDetails' do
|
145
|
+
xml.tag! 'n2:BillingStartDate', (options[:start_date].is_a?(Date) ? options[:start_date].to_time : options[:start_date]).utc.iso8601
|
146
|
+
xml.tag! 'n2:ProfileReference', options[:profile_reference] unless options[:profile_reference].blank?
|
147
|
+
end
|
148
|
+
xml.tag! 'n2:ScheduleDetails' do
|
149
|
+
xml.tag! 'n2:Description', options[:description]
|
150
|
+
xml.tag! 'n2:PaymentPeriod' do
|
151
|
+
xml.tag! 'n2:BillingPeriod', options[:period] || 'Month'
|
152
|
+
xml.tag! 'n2:BillingFrequency', options[:frequency]
|
153
|
+
xml.tag! 'n2:TotalBillingCycles', options[:total_billing_cycles] unless options[:total_billing_cycles].blank?
|
154
|
+
xml.tag! 'n2:Amount', amount(options[:amount]), 'currencyID' => options[:currency] || 'USD'
|
155
|
+
xml.tag! 'n2:TaxAmount', amount(options[:tax_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:tax_amount].blank?
|
156
|
+
xml.tag! 'n2:ShippingAmount', amount(options[:shipping_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:shipping_amount].blank?
|
157
|
+
end
|
158
|
+
if !options[:trial_amount].blank?
|
159
|
+
xml.tag! 'n2:TrialPeriod' do
|
160
|
+
xml.tag! 'n2:BillingPeriod', options[:trial_period] || 'Month'
|
161
|
+
xml.tag! 'n2:BillingFrequency', options[:trial_frequency]
|
162
|
+
xml.tag! 'n2:TotalBillingCycles', options[:trial_cycles] || 1
|
163
|
+
xml.tag! 'n2:Amount', amount(options[:trial_amount]), 'currencyID' => options[:currency] || 'USD'
|
164
|
+
xml.tag! 'n2:TaxAmount', amount(options[:trial_tax_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:trial_tax_amount].blank?
|
165
|
+
xml.tag! 'n2:ShippingAmount', amount(options[:trial_shipping_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:trial_shipping_amount].blank?
|
166
|
+
end
|
167
|
+
end
|
168
|
+
if !options[:initial_amount].blank?
|
169
|
+
xml.tag! 'n2:ActivationDetails' do
|
170
|
+
xml.tag! 'n2:InitialAmount', amount(options[:initial_amount]), 'currencyID' => options[:currency] || 'USD'
|
171
|
+
xml.tag! 'n2:FailedInitialAmountAction', options[:continue_on_failure] ? 'ContinueOnFailure' : 'CancelOnFailure'
|
172
|
+
end
|
173
|
+
end
|
174
|
+
xml.tag! 'n2:MaxFailedPayments', options[:max_failed_payments] unless options[:max_failed_payments].blank?
|
175
|
+
xml.tag! 'n2:AutoBillOutstandingAmount', options[:auto_bill_outstanding] ? 'AddToNextBilling' : 'NoAutoBill'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
xml.target!
|
181
|
+
end
|
182
|
+
|
183
|
+
def build_get_profile_details_request(profile_id)
|
184
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
185
|
+
xml.tag! 'GetRecurringPaymentsProfileDetailsReq', 'xmlns' => PAYPAL_NAMESPACE do
|
186
|
+
xml.tag! 'GetRecurringPaymentsProfileDetailsRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
187
|
+
xml.tag! 'n2:Version', API_VERSION
|
188
|
+
xml.tag! 'ProfileID', profile_id
|
189
|
+
end
|
190
|
+
end
|
191
|
+
xml.target!
|
192
|
+
end
|
193
|
+
|
194
|
+
def build_change_profile_request(profile_id, options)
|
195
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
196
|
+
xml.tag! 'UpdateRecurringPaymentsProfileReq', 'xmlns' => PAYPAL_NAMESPACE do
|
197
|
+
xml.tag! 'UpdateRecurringPaymentsProfileRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
198
|
+
xml.tag! 'n2:Version', API_VERSION
|
199
|
+
xml.tag! 'n2:UpdateRecurringPaymentsProfileRequestDetails' do
|
200
|
+
xml.tag! 'ProfileID', profile_id
|
201
|
+
if options[:credit_card]
|
202
|
+
add_credit_card(xml, options[:credit_card], options[:address], options)
|
203
|
+
end
|
204
|
+
xml.tag! 'n2:Note', options[:note] unless options[:note].blank?
|
205
|
+
xml.tag! 'n2:Description', options[:description] unless options[:description].blank?
|
206
|
+
xml.tag! 'n2:ProfileReference', options[:reference] unless options[:reference].blank?
|
207
|
+
xml.tag! 'n2:AdditionalBillingCycles', options[:additional_billing_cycles] unless options[:additional_billing_cycles].blank?
|
208
|
+
xml.tag! 'n2:MaxFailedPayments', options[:max_failed_payments] unless options[:max_failed_payments].blank?
|
209
|
+
xml.tag! 'n2:AutoBillOutstandingAmount', options[:auto_bill_outstanding] ? 'AddToNextBilling' : 'NoAutoBill'
|
210
|
+
if options.has_key?(:amount)
|
211
|
+
xml.tag! 'n2:Amount', amount(options[:amount]), 'currencyID' => options[:currency] || 'USD'
|
212
|
+
end
|
213
|
+
if options.has_key?(:tax_amount)
|
214
|
+
xml.tag! 'n2:TaxAmount', amount(options[:tax_amount] || 0), 'currencyID' => options[:currency] || 'USD'
|
215
|
+
end
|
216
|
+
if options.has_key?(:start_date)
|
217
|
+
xml.tag! 'n2:BillingStartDate', (options[:start_date].is_a?(Date) ? options[:start_date].to_time : options[:start_date]).utc.iso8601
|
218
|
+
end
|
219
|
+
if options.has_key?(:outstanding_balance)
|
220
|
+
xml.tag! 'n2:OutstandingBalance', amount(options[:outstanding_balance]), 'currencyID' => options[:currency] || 'USD'
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
xml.target!
|
226
|
+
end
|
227
|
+
|
228
|
+
def build_manage_profile_request(profile_id, action, options)
|
229
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
230
|
+
xml.tag! 'ManageRecurringPaymentsProfileStatusReq', 'xmlns' => PAYPAL_NAMESPACE do
|
231
|
+
xml.tag! 'ManageRecurringPaymentsProfileStatusRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
232
|
+
xml.tag! 'n2:Version', API_VERSION
|
233
|
+
xml.tag! 'n2:ManageRecurringPaymentsProfileStatusRequestDetails' do
|
234
|
+
xml.tag! 'ProfileID', profile_id
|
235
|
+
xml.tag! 'n2:Action', action
|
236
|
+
xml.tag! 'n2:Note', options[:note] unless options[:note].blank?
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
xml.target!
|
241
|
+
end
|
242
|
+
|
243
|
+
def build_bill_outstanding_amount(profile_id, options)
|
244
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
245
|
+
xml.tag! 'BillOutstandingAmountReq', 'xmlns' => PAYPAL_NAMESPACE do
|
246
|
+
xml.tag! 'BillOutstandingAmountRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
247
|
+
xml.tag! 'n2:Version', API_VERSION
|
248
|
+
xml.tag! 'n2:BillOutstandingAmountRequestDetails' do
|
249
|
+
xml.tag! 'ProfileID', profile_id
|
250
|
+
if options.has_key?(:amount)
|
251
|
+
xml.tag! 'n2:Amount', amount(options[:amount]), 'currencyID' => options[:currency] || 'USD'
|
252
|
+
end
|
253
|
+
xml.tag! 'n2:Note', options[:note] unless options[:note].blank?
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
xml.target!
|
258
|
+
end
|
259
|
+
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/paypal'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
# The PayPal gateway for PayPal Website Payments Pro Canada only supports Visa and MasterCard
|
6
|
+
class PaypalCaGateway < PaypalGateway
|
7
|
+
self.supported_cardtypes = [:visa, :master]
|
8
|
+
self.supported_countries = ['CA']
|
9
|
+
self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside'
|
10
|
+
self.display_name = 'PayPal Website Payments Pro (CA)'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/paypal/paypal_common_api'
|
2
|
+
require File.dirname(__FILE__) + '/paypal/paypal_express_response'
|
3
|
+
require File.dirname(__FILE__) + '/paypal_express_common'
|
4
|
+
|
5
|
+
module ActiveMerchant #:nodoc:
|
6
|
+
module Billing #:nodoc:
|
7
|
+
class PaypalDigitalGoodsGateway < PaypalExpressGateway
|
8
|
+
self.test_redirect_url = 'https://www.sandbox.paypal.com/incontext'
|
9
|
+
self.live_redirect_url = 'https://www.paypal.com/incontext'
|
10
|
+
|
11
|
+
self.supported_countries = %w(AU CA CN FI GB ID IN IT MY NO NZ PH PL SE SG TH VN)
|
12
|
+
self.homepage_url = 'https://www.x.com/community/ppx/xspaces/digital_goods'
|
13
|
+
self.display_name = 'PayPal Express Checkout for Digital Goods'
|
14
|
+
|
15
|
+
def redirect_url_for(token, options = {})
|
16
|
+
options[:review] ||= false
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
# GATEWAY.setup_purchase(100,
|
21
|
+
# :ip => "127.0.0.1",
|
22
|
+
# :description => "Test Title",
|
23
|
+
# :return_url => "http://return.url",
|
24
|
+
# :cancel_return_url => "http://cancel.url",
|
25
|
+
# :items => [ { :name => "Charge",
|
26
|
+
# :number => "1",
|
27
|
+
# :quantity => "1",
|
28
|
+
# :amount => 100,
|
29
|
+
# :description => "Description",
|
30
|
+
# :category => "Digital" } ] )
|
31
|
+
def build_setup_request(action, money, options)
|
32
|
+
requires!(options, :items)
|
33
|
+
raise ArgumentError, "Must include at least 1 Item" unless options[:items].length > 0
|
34
|
+
options[:items].each do |item|
|
35
|
+
requires!(item, :name, :number, :quantity, :amount, :description, :category)
|
36
|
+
raise ArgumentError, "Each of the items must have the category 'Digital'" unless item[:category] == 'Digital'
|
37
|
+
end
|
38
|
+
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,264 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/paypal/paypal_common_api'
|
2
|
+
require File.dirname(__FILE__) + '/paypal/paypal_express_response'
|
3
|
+
require File.dirname(__FILE__) + '/paypal/paypal_recurring_api'
|
4
|
+
require File.dirname(__FILE__) + '/paypal_express_common'
|
5
|
+
|
6
|
+
module ActiveMerchant #:nodoc:
|
7
|
+
module Billing #:nodoc:
|
8
|
+
class PaypalExpressGateway < Gateway
|
9
|
+
include PaypalCommonAPI
|
10
|
+
include PaypalExpressCommon
|
11
|
+
include PaypalRecurringApi
|
12
|
+
|
13
|
+
NON_STANDARD_LOCALE_CODES = {
|
14
|
+
'DK' => 'da_DK',
|
15
|
+
'IL' => 'he_IL',
|
16
|
+
'ID' => 'id_ID',
|
17
|
+
'JP' => 'jp_JP',
|
18
|
+
'NO' => 'no_NO',
|
19
|
+
'BR' => 'pt_BR',
|
20
|
+
'RU' => 'ru_RU',
|
21
|
+
'SE' => 'sv_SE',
|
22
|
+
'TH' => 'th_TH',
|
23
|
+
'TR' => 'tr_TR',
|
24
|
+
'CN' => 'zh_CN',
|
25
|
+
'HK' => 'zh_HK',
|
26
|
+
'TW' => 'zh_TW'
|
27
|
+
}
|
28
|
+
|
29
|
+
self.test_redirect_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'
|
30
|
+
self.supported_countries = ['US']
|
31
|
+
self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=xpt/merchant/ExpressCheckoutIntro-outside'
|
32
|
+
self.display_name = 'PayPal Express Checkout'
|
33
|
+
|
34
|
+
def setup_authorization(money, options = {})
|
35
|
+
requires!(options, :return_url, :cancel_return_url)
|
36
|
+
|
37
|
+
commit 'SetExpressCheckout', build_setup_request('Authorization', money, options)
|
38
|
+
end
|
39
|
+
|
40
|
+
def setup_purchase(money, options = {})
|
41
|
+
requires!(options, :return_url, :cancel_return_url)
|
42
|
+
|
43
|
+
commit 'SetExpressCheckout', build_setup_request('Sale', money, options)
|
44
|
+
end
|
45
|
+
|
46
|
+
def details_for(token)
|
47
|
+
commit 'GetExpressCheckoutDetails', build_get_details_request(token)
|
48
|
+
end
|
49
|
+
|
50
|
+
def authorize(money, options = {})
|
51
|
+
requires!(options, :token, :payer_id)
|
52
|
+
|
53
|
+
commit 'DoExpressCheckoutPayment', build_sale_or_authorization_request('Authorization', money, options)
|
54
|
+
end
|
55
|
+
|
56
|
+
def purchase(money, options = {})
|
57
|
+
requires!(options, :token, :payer_id)
|
58
|
+
|
59
|
+
commit 'DoExpressCheckoutPayment', build_sale_or_authorization_request('Sale', money, options)
|
60
|
+
end
|
61
|
+
|
62
|
+
def store(token, options = {})
|
63
|
+
commit 'CreateBillingAgreement', build_create_billing_agreement_request(token, options)
|
64
|
+
end
|
65
|
+
|
66
|
+
def unstore(token, options = {})
|
67
|
+
commit 'BAUpdate', build_cancel_billing_agreement_request(token)
|
68
|
+
end
|
69
|
+
|
70
|
+
def agreement_details(reference_id, options = {})
|
71
|
+
commit 'BAUpdate', build_details_billing_agreement_request(reference_id)
|
72
|
+
end
|
73
|
+
|
74
|
+
def authorize_reference_transaction(money, options = {})
|
75
|
+
requires!(options, :reference_id, :payment_type, :invoice_id, :description, :ip)
|
76
|
+
|
77
|
+
commit 'DoReferenceTransaction', build_reference_transaction_request('Authorization', money, options)
|
78
|
+
end
|
79
|
+
|
80
|
+
def reference_transaction(money, options = {})
|
81
|
+
requires!(options, :reference_id)
|
82
|
+
|
83
|
+
commit 'DoReferenceTransaction', build_reference_transaction_request('Sale', money, options)
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
def build_get_details_request(token)
|
88
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
89
|
+
xml.tag! 'GetExpressCheckoutDetailsReq', 'xmlns' => PAYPAL_NAMESPACE do
|
90
|
+
xml.tag! 'GetExpressCheckoutDetailsRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
91
|
+
xml.tag! 'n2:Version', API_VERSION
|
92
|
+
xml.tag! 'Token', token
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
xml.target!
|
97
|
+
end
|
98
|
+
|
99
|
+
def build_sale_or_authorization_request(action, money, options)
|
100
|
+
currency_code = options[:currency] || currency(money)
|
101
|
+
|
102
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
103
|
+
xml.tag! 'DoExpressCheckoutPaymentReq', 'xmlns' => PAYPAL_NAMESPACE do
|
104
|
+
xml.tag! 'DoExpressCheckoutPaymentRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
105
|
+
xml.tag! 'n2:Version', API_VERSION
|
106
|
+
xml.tag! 'n2:DoExpressCheckoutPaymentRequestDetails' do
|
107
|
+
xml.tag! 'n2:PaymentAction', action
|
108
|
+
xml.tag! 'n2:Token', options[:token]
|
109
|
+
xml.tag! 'n2:PayerID', options[:payer_id]
|
110
|
+
add_payment_details(xml, money, currency_code, options)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
xml.target!
|
116
|
+
end
|
117
|
+
|
118
|
+
def build_setup_request(action, money, options)
|
119
|
+
currency_code = options[:currency] || currency(money)
|
120
|
+
options[:payment_action] = action
|
121
|
+
options[:express_request] = true
|
122
|
+
options[:shipping_address] ||= options[:address]
|
123
|
+
|
124
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
125
|
+
xml.tag! 'SetExpressCheckoutReq', 'xmlns' => PAYPAL_NAMESPACE do
|
126
|
+
xml.tag! 'SetExpressCheckoutRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
127
|
+
xml.tag! 'n2:Version', API_VERSION
|
128
|
+
xml.tag! 'n2:SetExpressCheckoutRequestDetails' do
|
129
|
+
xml.tag! 'n2:ReturnURL', options[:return_url]
|
130
|
+
xml.tag! 'n2:CancelURL', options[:cancel_return_url]
|
131
|
+
if options[:max_amount]
|
132
|
+
xml.tag! 'n2:MaxAmount', localized_amount(options[:max_amount], currency_code), 'currencyID' => currency_code
|
133
|
+
end
|
134
|
+
xml.tag! 'n2:ReqBillingAddress', options[:req_billing_address] ? '1' : '0'
|
135
|
+
xml.tag! 'n2:NoShipping', options[:no_shipping] ? '1' : '0'
|
136
|
+
xml.tag! 'n2:AddressOverride', options[:address_override] ? '1' : '0'
|
137
|
+
xml.tag! 'n2:LocaleCode', locale_code(options[:locale]) unless options[:locale].blank?
|
138
|
+
xml.tag! 'n2:BrandName', options[:brand_name] unless options[:brand_name].blank?
|
139
|
+
# Customization of the payment page
|
140
|
+
xml.tag! 'n2:PageStyle', options[:page_style] unless options[:page_style].blank?
|
141
|
+
xml.tag! 'n2:cpp-logo-image', options[:logo_image] unless options[:logo_image].blank?
|
142
|
+
xml.tag! 'n2:cpp-header-image', options[:header_image] unless options[:header_image].blank?
|
143
|
+
xml.tag! 'n2:cpp-header-border-color', options[:header_border_color] unless options[:header_border_color].blank?
|
144
|
+
xml.tag! 'n2:cpp-header-back-color', options[:header_background_color] unless options[:header_background_color].blank?
|
145
|
+
xml.tag! 'n2:cpp-payflow-color', options[:background_color] unless options[:background_color].blank?
|
146
|
+
if options[:allow_guest_checkout]
|
147
|
+
xml.tag! 'n2:SolutionType', 'Sole'
|
148
|
+
xml.tag! 'n2:LandingPage', options[:landing_page] || 'Billing'
|
149
|
+
end
|
150
|
+
xml.tag! 'n2:BuyerEmail', options[:email] unless options[:email].blank?
|
151
|
+
|
152
|
+
if options[:billing_agreement]
|
153
|
+
xml.tag! 'n2:BillingAgreementDetails' do
|
154
|
+
xml.tag! 'n2:BillingType', options[:billing_agreement][:type]
|
155
|
+
xml.tag! 'n2:BillingAgreementDescription', options[:billing_agreement][:description]
|
156
|
+
xml.tag! 'n2:PaymentType', options[:billing_agreement][:payment_type] || 'InstantOnly'
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
if !options[:allow_note].nil?
|
161
|
+
xml.tag! 'n2:AllowNote', options[:allow_note] ? '1' : '0'
|
162
|
+
end
|
163
|
+
|
164
|
+
if options[:funding_sources]
|
165
|
+
xml.tag! 'n2:FundingSourceDetails' do
|
166
|
+
xml.tag! 'n2:UserSelectedFundingSource', options[:funding_sources][:source]
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
xml.tag! 'n2:CallbackURL', options[:callback_url] unless options[:callback_url].blank?
|
171
|
+
|
172
|
+
add_payment_details(xml, money, currency_code, options)
|
173
|
+
if options[:shipping_options]
|
174
|
+
options[:shipping_options].each do |shipping_option|
|
175
|
+
xml.tag! 'n2:FlatRateShippingOptions' do
|
176
|
+
xml.tag! 'n2:ShippingOptionIsDefault', shipping_option[:default]
|
177
|
+
xml.tag! 'n2:ShippingOptionAmount', localized_amount(shipping_option[:amount], currency_code), 'currencyID' => currency_code
|
178
|
+
xml.tag! 'n2:ShippingOptionName', shipping_option[:name]
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
xml.tag! 'n2:CallbackTimeout', options[:callback_timeout] unless options[:callback_timeout].blank?
|
184
|
+
xml.tag! 'n2:CallbackVersion', options[:callback_version] unless options[:callback_version].blank?
|
185
|
+
|
186
|
+
if options.has_key?(:allow_buyer_optin)
|
187
|
+
xml.tag! 'n2:BuyerEmailOptInEnable', (options[:allow_buyer_optin] ? '1' : '0')
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
xml.target!
|
194
|
+
end
|
195
|
+
|
196
|
+
def build_create_billing_agreement_request(token, options = {})
|
197
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
198
|
+
xml.tag! 'CreateBillingAgreementReq', 'xmlns' => PAYPAL_NAMESPACE do
|
199
|
+
xml.tag! 'CreateBillingAgreementRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
200
|
+
xml.tag! 'n2:Version', API_VERSION
|
201
|
+
xml.tag! 'Token', token
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
xml.target!
|
206
|
+
end
|
207
|
+
|
208
|
+
def build_cancel_billing_agreement_request(token)
|
209
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
210
|
+
xml.tag! 'BillAgreementUpdateReq', 'xmlns' => PAYPAL_NAMESPACE do
|
211
|
+
xml.tag! 'BAUpdateRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
212
|
+
xml.tag! 'n2:Version', API_VERSION
|
213
|
+
xml.tag! 'ReferenceID', token
|
214
|
+
xml.tag! 'BillingAgreementStatus', "Canceled"
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
xml.target!
|
219
|
+
end
|
220
|
+
|
221
|
+
def build_details_billing_agreement_request(reference_id)
|
222
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
223
|
+
xml.tag! 'BillAgreementUpdateReq', 'xmlns' => PAYPAL_NAMESPACE do
|
224
|
+
xml.tag! 'BAUpdateRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
225
|
+
xml.tag! 'n2:Version', API_VERSION
|
226
|
+
xml.tag! 'ReferenceID', reference_id
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
xml.target!
|
231
|
+
end
|
232
|
+
|
233
|
+
def build_reference_transaction_request(action, money, options)
|
234
|
+
currency_code = options[:currency] || currency(money)
|
235
|
+
|
236
|
+
# I am not sure why it's set like this for express gateway
|
237
|
+
# but I don't want to break the existing behavior
|
238
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
239
|
+
xml.tag! 'DoReferenceTransactionReq', 'xmlns' => PAYPAL_NAMESPACE do
|
240
|
+
xml.tag! 'DoReferenceTransactionRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
241
|
+
xml.tag! 'n2:Version', API_VERSION
|
242
|
+
xml.tag! 'n2:DoReferenceTransactionRequestDetails' do
|
243
|
+
xml.tag! 'n2:ReferenceID', options[:reference_id]
|
244
|
+
xml.tag! 'n2:PaymentAction', action
|
245
|
+
xml.tag! 'n2:PaymentType', options[:payment_type] || 'Any'
|
246
|
+
add_payment_details(xml, money, currency_code, options)
|
247
|
+
xml.tag! 'n2:IPAddress', options[:ip]
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
xml.target!
|
253
|
+
end
|
254
|
+
|
255
|
+
def build_response(success, message, response, options = {})
|
256
|
+
PaypalExpressResponse.new(success, message, response, options)
|
257
|
+
end
|
258
|
+
|
259
|
+
def locale_code(country_code)
|
260
|
+
NON_STANDARD_LOCALE_CODES[country_code] || country_code
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|