activemerchant 1.21.0 → 1.22.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.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +63 -0
- data/CONTRIBUTORS +29 -0
- data/README.md +195 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +2 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +2 -2
- data/lib/active_merchant/billing/gateways/blue_pay.rb +492 -11
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +46 -19
- data/lib/active_merchant/billing/gateways/certo_direct.rb +1 -1
- data/lib/active_merchant/billing/gateways/cyber_source.rb +342 -106
- data/lib/active_merchant/billing/gateways/elavon.rb +2 -0
- data/lib/active_merchant/billing/gateways/epay.rb +3 -1
- data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
- data/lib/active_merchant/billing/gateways/migs.rb +259 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +211 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +104 -12
- data/lib/active_merchant/billing/gateways/orbital.rb +15 -6
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +1 -4
- data/lib/active_merchant/billing/gateways/payflow.rb +8 -3
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +4 -1
- data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -2
- data/lib/active_merchant/billing/gateways/payment_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal.rb +3 -18
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +287 -1
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +245 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +14 -66
- data/lib/active_merchant/billing/gateways/realex.rb +5 -7
- data/lib/active_merchant/billing/gateways/stripe.rb +1 -9
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +2 -2
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +1 -5
- data/lib/active_merchant/billing/gateways/viaklix.rb +7 -2
- data/lib/active_merchant/billing/gateways/vindicia.rb +359 -0
- data/lib/active_merchant/billing/integrations/dotpay.rb +22 -0
- data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
- data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
- data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/epay.rb +21 -0
- data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
- data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +2 -1
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +2 -3
- data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
- data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
- data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
- data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +25 -3
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +15 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +87 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
- data/lib/active_merchant/version.rb +1 -1
- metadata +59 -26
- metadata.gz.sig +0 -0
@@ -0,0 +1,245 @@
|
|
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>money</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
|
+
options[:credit_card] = credit_card
|
29
|
+
options[:amount] = amount
|
30
|
+
requires!(options, :description, :start_date, :period, :frequency, :amount)
|
31
|
+
commit 'CreateRecurringPaymentsProfile', build_create_profile_request(options)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Update a recurring payment's details.
|
35
|
+
#
|
36
|
+
# This transaction updates an existing Recurring Billing Profile
|
37
|
+
# and the subscription must have already been created previously
|
38
|
+
# by calling +recurring()+. The ability to change certain
|
39
|
+
# details about a recurring payment is dependent on transaction history
|
40
|
+
# and the type of plan you're subscribed with paypal. Web Payment Pro
|
41
|
+
# seems to have the ability to update the most field.
|
42
|
+
#
|
43
|
+
# ==== Parameters
|
44
|
+
#
|
45
|
+
# * <tt>options</tt> -- A hash of parameters.
|
46
|
+
#
|
47
|
+
# ==== Options
|
48
|
+
#
|
49
|
+
# * <tt>:profile_id</tt> -- A string containing the <tt>:profile_id</tt>
|
50
|
+
# of the recurring payment already in place for a given credit card. (REQUIRED)
|
51
|
+
def update_recurring(options={})
|
52
|
+
requires!(options, :profile_id)
|
53
|
+
opts = options.dup
|
54
|
+
commit 'UpdateRecurringPaymentsProfile', build_change_profile_request(opts.delete(:profile_id), opts)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Cancel a recurring payment.
|
58
|
+
#
|
59
|
+
# This transaction cancels an existing recurring billing profile. Your account must have recurring billing enabled
|
60
|
+
# and the subscription must have already been created previously by calling recurring()
|
61
|
+
#
|
62
|
+
# ==== Parameters
|
63
|
+
#
|
64
|
+
# * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
|
65
|
+
# recurring payment already in place for a given credit card. (REQUIRED)
|
66
|
+
# * <tt>options</tt> -- A hash with extra info ('note' for ex.)
|
67
|
+
def cancel_recurring(profile_id, options = {})
|
68
|
+
raise_error_if_blank('profile_id', profile_id)
|
69
|
+
commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Cancel', options)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Get Subscription Status of a recurring payment profile.
|
73
|
+
#
|
74
|
+
# ==== Parameters
|
75
|
+
#
|
76
|
+
# * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
|
77
|
+
# recurring payment already in place for a given credit card. (REQUIRED)
|
78
|
+
def status_recurring(profile_id)
|
79
|
+
raise_error_if_blank('profile_id', profile_id)
|
80
|
+
commit 'GetRecurringPaymentsProfileDetails', build_get_profile_details_request(profile_id)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Suspends a recurring payment profile.
|
84
|
+
#
|
85
|
+
# ==== Parameters
|
86
|
+
#
|
87
|
+
# * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
|
88
|
+
# recurring payment already in place for a given credit card. (REQUIRED)
|
89
|
+
def suspend_recurring(profile_id, options = {})
|
90
|
+
raise_error_if_blank('profile_id', profile_id)
|
91
|
+
commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Suspend', options)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Reactivates a suspended recurring payment profile.
|
95
|
+
#
|
96
|
+
# ==== Parameters
|
97
|
+
#
|
98
|
+
# * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
|
99
|
+
# recurring payment already in place for a given credit card. (REQUIRED)
|
100
|
+
def reactivate_recurring(profile_id, options = {})
|
101
|
+
raise_error_if_blank('profile_id', profile_id)
|
102
|
+
commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Reactivate', options)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Bills outstanding amount to a recurring payment profile.
|
106
|
+
#
|
107
|
+
# ==== Parameters
|
108
|
+
#
|
109
|
+
# * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
|
110
|
+
# recurring payment already in place for a given credit card. (REQUIRED)
|
111
|
+
def bill_outstanding_amount(profile_id, options = {})
|
112
|
+
raise_error_if_blank('profile_id', profile_id)
|
113
|
+
commit 'BillOutstandingAmount', build_bill_outstanding_amount(profile_id, options)
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
def raise_error_if_blank(field_name, field)
|
118
|
+
raise ArgumentError.new("Missing required parameter: #{field_name}") if field.blank?
|
119
|
+
end
|
120
|
+
def build_create_profile_request(options)
|
121
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
122
|
+
xml.tag! 'CreateRecurringPaymentsProfileReq', 'xmlns' => PAYPAL_NAMESPACE do
|
123
|
+
xml.tag! 'CreateRecurringPaymentsProfileRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
124
|
+
xml.tag! 'n2:Version', API_VERSION
|
125
|
+
xml.tag! 'n2:CreateRecurringPaymentsProfileRequestDetails' do
|
126
|
+
xml.tag! 'Token', options[:token] unless options[:token].blank?
|
127
|
+
if options[:credit_card]
|
128
|
+
add_credit_card(xml, options[:credit_card], (options[:billing_address] || options[:address]), options)
|
129
|
+
end
|
130
|
+
xml.tag! 'n2:RecurringPaymentsProfileDetails' do
|
131
|
+
xml.tag! 'n2:BillingStartDate', (options[:start_date].is_a?(Date) ? options[:start_date].to_time : options[:start_date]).utc.iso8601
|
132
|
+
xml.tag! 'n2:ProfileReference', options[:profile_reference] unless options[:profile_reference].blank?
|
133
|
+
end
|
134
|
+
xml.tag! 'n2:ScheduleDetails' do
|
135
|
+
xml.tag! 'n2:Description', options[:description]
|
136
|
+
xml.tag! 'n2:PaymentPeriod' do
|
137
|
+
xml.tag! 'n2:BillingPeriod', options[:period] || 'Month'
|
138
|
+
xml.tag! 'n2:BillingFrequency', options[:frequency]
|
139
|
+
xml.tag! 'n2:TotalBillingCycles', options[:total_billing_cycles] unless options[:total_billing_cycles].blank?
|
140
|
+
xml.tag! 'n2:Amount', amount(options[:amount]), 'currencyID' => options[:currency] || 'USD'
|
141
|
+
xml.tag! 'n2:TaxAmount', amount(options[:tax_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:tax_amount].blank?
|
142
|
+
xml.tag! 'n2:ShippingAmount', amount(options[:shipping_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:shipping_amount].blank?
|
143
|
+
end
|
144
|
+
if !options[:trial_amount].blank?
|
145
|
+
xml.tag! 'n2:TrialPeriod' do
|
146
|
+
xml.tag! 'n2:BillingPeriod', options[:trial_period] || 'Month'
|
147
|
+
xml.tag! 'n2:BillingFrequency', options[:trial_frequency]
|
148
|
+
xml.tag! 'n2:TotalBillingCycles', options[:trial_cycles] || 1
|
149
|
+
xml.tag! 'n2:Amount', amount(options[:trial_amount]), 'currencyID' => options[:currency] || 'USD'
|
150
|
+
xml.tag! 'n2:TaxAmount', amount(options[:trial_tax_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:trial_tax_amount].blank?
|
151
|
+
xml.tag! 'n2:ShippingAmount', amount(options[:trial_shipping_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:trial_shipping_amount].blank?
|
152
|
+
end
|
153
|
+
end
|
154
|
+
if !options[:initial_amount].blank?
|
155
|
+
xml.tag! 'n2:ActivationDetails' do
|
156
|
+
xml.tag! 'n2:InitialAmount', amount(options[:initial_amount]), 'currencyID' => options[:currency] || 'USD'
|
157
|
+
xml.tag! 'n2:FailedInitialAmountAction', options[:continue_on_failure] ? 'ContinueOnFailure' : 'CancelOnFailure'
|
158
|
+
end
|
159
|
+
end
|
160
|
+
xml.tag! 'n2:MaxFailedPayments', options[:max_failed_payments] unless options[:max_failed_payments].blank?
|
161
|
+
xml.tag! 'n2:AutoBillOutstandingAmount', options[:auto_bill_outstanding] ? 'AddToNextBilling' : 'NoAutoBill'
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
xml.target!
|
167
|
+
end
|
168
|
+
|
169
|
+
def build_get_profile_details_request(profile_id)
|
170
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
171
|
+
xml.tag! 'GetRecurringPaymentsProfileDetailsReq', 'xmlns' => PAYPAL_NAMESPACE do
|
172
|
+
xml.tag! 'GetRecurringPaymentsProfileDetailsRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
173
|
+
xml.tag! 'n2:Version', API_VERSION
|
174
|
+
xml.tag! 'ProfileID', profile_id
|
175
|
+
end
|
176
|
+
end
|
177
|
+
xml.target!
|
178
|
+
end
|
179
|
+
|
180
|
+
def build_change_profile_request(profile_id, options)
|
181
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
182
|
+
xml.tag! 'UpdateRecurringPaymentsProfileReq', 'xmlns' => PAYPAL_NAMESPACE do
|
183
|
+
xml.tag! 'UpdateRecurringPaymentsProfileRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
184
|
+
xml.tag! 'n2:Version', API_VERSION
|
185
|
+
xml.tag! 'n2:UpdateRecurringPaymentsProfileRequestDetails' do
|
186
|
+
xml.tag! 'ProfileID', profile_id
|
187
|
+
if options[:credit_card]
|
188
|
+
add_credit_card(xml, options[:credit_card], options[:address], options)
|
189
|
+
end
|
190
|
+
xml.tag! 'n2:Note', options[:note] unless options[:note].blank?
|
191
|
+
xml.tag! 'n2:Description', options[:description] unless options[:description].blank?
|
192
|
+
xml.tag! 'n2:ProfileReference', options[:reference] unless options[:reference].blank?
|
193
|
+
xml.tag! 'n2:AdditionalBillingCycles', options[:additional_billing_cycles] unless options[:additional_billing_cycles].blank?
|
194
|
+
xml.tag! 'n2:MaxFailedPayments', options[:max_failed_payments] unless options[:max_failed_payments].blank?
|
195
|
+
xml.tag! 'n2:AutoBillOutstandingAmount', options[:auto_bill_outstanding] ? 'AddToNextBilling' : 'NoAutoBill'
|
196
|
+
if options.has_key?(:amount)
|
197
|
+
xml.tag! 'n2:Amount', amount(options[:amount]), 'currencyID' => options[:currency] || 'USD'
|
198
|
+
end
|
199
|
+
if options.has_key?(:tax_amount)
|
200
|
+
xml.tag! 'n2:TaxAmount', amount(options[:tax_amount] || 0), 'currencyID' => options[:currency] || 'USD'
|
201
|
+
end
|
202
|
+
if options.has_key?(:start_date)
|
203
|
+
xml.tag! 'n2:BillingStartDate', (options[:start_date].is_a?(Date) ? options[:start_date].to_time : options[:start_date]).utc.iso8601
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
xml.target!
|
209
|
+
end
|
210
|
+
|
211
|
+
def build_manage_profile_request(profile_id, action, options)
|
212
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
213
|
+
xml.tag! 'ManageRecurringPaymentsProfileStatusReq', 'xmlns' => PAYPAL_NAMESPACE do
|
214
|
+
xml.tag! 'ManageRecurringPaymentsProfileStatusRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
215
|
+
xml.tag! 'n2:Version', API_VERSION
|
216
|
+
xml.tag! 'n2:ManageRecurringPaymentsProfileStatusRequestDetails' do
|
217
|
+
xml.tag! 'ProfileID', profile_id
|
218
|
+
xml.tag! 'n2:Action', action
|
219
|
+
xml.tag! 'n2:Note', options[:note] unless options[:note].blank?
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
xml.target!
|
224
|
+
end
|
225
|
+
|
226
|
+
def build_bill_outstanding_amount(profile_id, options)
|
227
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
228
|
+
xml.tag! 'BillOutstandingAmountReq', 'xmlns' => PAYPAL_NAMESPACE do
|
229
|
+
xml.tag! 'BillOutstandingAmountRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
230
|
+
xml.tag! 'n2:Version', API_VERSION
|
231
|
+
xml.tag! 'n2:BillOutstandingAmountRequestDetails' do
|
232
|
+
xml.tag! 'ProfileID', profile_id
|
233
|
+
if options.has_key?(:amount)
|
234
|
+
xml.tag! 'n2:Amount', amount(options[:amount]), 'currencyID' => options[:currency] || 'USD'
|
235
|
+
end
|
236
|
+
xml.tag! 'n2:Note', options[:note] unless options[:note].blank?
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
xml.target!
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
@@ -71,24 +71,7 @@ module ActiveMerchant #:nodoc:
|
|
71
71
|
xml.tag! 'n2:PaymentAction', action
|
72
72
|
xml.tag! 'n2:Token', options[:token]
|
73
73
|
xml.tag! 'n2:PayerID', options[:payer_id]
|
74
|
-
xml
|
75
|
-
xml.tag! 'n2:OrderTotal', localized_amount(money, currency_code), 'currencyID' => currency_code
|
76
|
-
|
77
|
-
# All of the values must be included together and add up to the order total
|
78
|
-
if [:subtotal, :shipping, :handling, :tax].all?{ |o| options.has_key?(o) }
|
79
|
-
xml.tag! 'n2:ItemTotal', localized_amount(options[:subtotal], currency_code), 'currencyID' => currency_code
|
80
|
-
xml.tag! 'n2:ShippingTotal', localized_amount(options[:shipping], currency_code),'currencyID' => currency_code
|
81
|
-
xml.tag! 'n2:HandlingTotal', localized_amount(options[:handling], currency_code),'currencyID' => currency_code
|
82
|
-
xml.tag! 'n2:TaxTotal', localized_amount(options[:tax], currency_code), 'currencyID' => currency_code
|
83
|
-
end
|
84
|
-
|
85
|
-
xml.tag! 'n2:NotifyURL', options[:notify_url]
|
86
|
-
xml.tag! 'n2:ButtonSource', application_id.to_s.slice(0,32) unless application_id.blank?
|
87
|
-
xml.tag! 'n2:InvoiceID', options[:order_id]
|
88
|
-
xml.tag! 'n2:OrderDescription', options[:description]
|
89
|
-
|
90
|
-
add_items_xml(xml, options, currency_code) if options[:items]
|
91
|
-
end
|
74
|
+
add_payment_details(xml, money, currency_code, options)
|
92
75
|
end
|
93
76
|
end
|
94
77
|
end
|
@@ -98,7 +81,10 @@ module ActiveMerchant #:nodoc:
|
|
98
81
|
|
99
82
|
def build_setup_request(action, money, options)
|
100
83
|
currency_code = options[:currency] || currency(money)
|
101
|
-
|
84
|
+
options[:payment_action] = action
|
85
|
+
options[:express_request] = true
|
86
|
+
options[:shipping_address] ||= options[:address]
|
87
|
+
|
102
88
|
xml = Builder::XmlMarkup.new :indent => 2
|
103
89
|
xml.tag! 'SetExpressCheckoutReq', 'xmlns' => PAYPAL_NAMESPACE do
|
104
90
|
xml.tag! 'SetExpressCheckoutRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
@@ -121,7 +107,7 @@ module ActiveMerchant #:nodoc:
|
|
121
107
|
xml.tag! 'n2:cpp-payflow-color', options[:background_color] unless options[:background_color].blank?
|
122
108
|
if options[:allow_guest_checkout]
|
123
109
|
xml.tag! 'n2:SolutionType', 'Sole'
|
124
|
-
xml.tag! 'n2:LandingPage', 'Billing'
|
110
|
+
xml.tag! 'n2:LandingPage', options[:landing_page] || 'Billing'
|
125
111
|
end
|
126
112
|
xml.tag! 'n2:BuyerEmail', options[:email] unless options[:email].blank?
|
127
113
|
|
@@ -137,28 +123,8 @@ module ActiveMerchant #:nodoc:
|
|
137
123
|
xml.tag! 'n2:AllowNote', options[:allow_note] ? '1' : '0'
|
138
124
|
end
|
139
125
|
xml.tag! 'n2:CallbackURL', options[:callback_url] unless options[:callback_url].blank?
|
140
|
-
|
141
|
-
xml
|
142
|
-
xml.tag! 'n2:OrderTotal', amount(money).to_f.zero? ? localized_amount(100, currency_code) : localized_amount(money, currency_code), 'currencyID' => currency_code
|
143
|
-
# All of the values must be included together and add up to the order total
|
144
|
-
if [:subtotal, :shipping, :handling, :tax].all? { |o| options.has_key?(o) }
|
145
|
-
xml.tag! 'n2:ItemTotal', localized_amount(options[:subtotal], currency_code), 'currencyID' => currency_code
|
146
|
-
xml.tag! 'n2:ShippingTotal', localized_amount(options[:shipping], currency_code), 'currencyID' => currency_code
|
147
|
-
xml.tag! 'n2:HandlingTotal', localized_amount(options[:handling], currency_code), 'currencyID' => currency_code
|
148
|
-
xml.tag! 'n2:TaxTotal', localized_amount(options[:tax], currency_code), 'currencyID' => currency_code
|
149
|
-
end
|
150
|
-
|
151
|
-
xml.tag! 'n2:OrderDescription', options[:description]
|
152
|
-
xml.tag! 'n2:InvoiceID', options[:order_id]
|
153
|
-
|
154
|
-
add_address(xml, 'n2:ShipToAddress', options[:shipping_address] || options[:address])
|
155
|
-
|
156
|
-
add_items_xml(xml, options, currency_code) if options[:items]
|
157
|
-
|
158
|
-
xml.tag! 'n2:PaymentAction', action
|
159
|
-
xml.tag! 'n2:Custom', options[:custom] unless options[:custom].blank?
|
160
|
-
end
|
161
|
-
|
126
|
+
|
127
|
+
add_payment_details(xml, with_money_default(money), currency_code, options)
|
162
128
|
if options[:shipping_options]
|
163
129
|
options[:shipping_options].each do |shipping_option|
|
164
130
|
xml.tag! 'n2:FlatRateShippingOptions' do
|
@@ -180,7 +146,9 @@ module ActiveMerchant #:nodoc:
|
|
180
146
|
|
181
147
|
def build_reference_transaction_request(action, money, options)
|
182
148
|
currency_code = options[:currency] || currency(money)
|
183
|
-
|
149
|
+
|
150
|
+
# I am not sure why it's set like this for express gateway
|
151
|
+
# but I don't want to break the existing behavior
|
184
152
|
xml = Builder::XmlMarkup.new :indent => 2
|
185
153
|
xml.tag! 'DoReferenceTransactionReq', 'xmlns' => PAYPAL_NAMESPACE do
|
186
154
|
xml.tag! 'DoReferenceTransactionRequest', 'xmlns:n2' => EBAY_NAMESPACE do
|
@@ -189,13 +157,7 @@ module ActiveMerchant #:nodoc:
|
|
189
157
|
xml.tag! 'n2:ReferenceID', options[:reference_id]
|
190
158
|
xml.tag! 'n2:PaymentAction', action
|
191
159
|
xml.tag! 'n2:PaymentType', options[:payment_type] || 'Any'
|
192
|
-
xml
|
193
|
-
xml.tag! 'n2:OrderTotal', amount(money).to_f.zero? ? localized_amount(100, currency_code) : localized_amount(money, currency_code), 'currencyID' => currency_code
|
194
|
-
xml.tag! 'n2:OrderDescription', options[:description]
|
195
|
-
xml.tag! 'n2:InvoiceID', options[:invoice_id]
|
196
|
-
xml.tag! 'n2:ButtonSource', 'ActiveMerchant'
|
197
|
-
xml.tag! 'n2:NotifyURL', ''
|
198
|
-
end
|
160
|
+
add_payment_details(xml, with_money_default(money), currency_code, options)
|
199
161
|
xml.tag! 'n2:IPAddress', options[:ip]
|
200
162
|
end
|
201
163
|
end
|
@@ -208,22 +170,8 @@ module ActiveMerchant #:nodoc:
|
|
208
170
|
PaypalExpressResponse.new(success, message, response, options)
|
209
171
|
end
|
210
172
|
|
211
|
-
|
212
|
-
|
213
|
-
def add_items_xml(xml, options, currency_code)
|
214
|
-
options[:items].each do |item|
|
215
|
-
xml.tag! 'n2:PaymentDetailsItem' do
|
216
|
-
xml.tag! 'n2:Name', item[:name]
|
217
|
-
xml.tag! 'n2:Number', item[:number]
|
218
|
-
xml.tag! 'n2:Quantity', item[:quantity]
|
219
|
-
if item[:amount]
|
220
|
-
xml.tag! 'n2:Amount', localized_amount(item[:amount], currency_code), 'currencyID' => currency_code
|
221
|
-
end
|
222
|
-
xml.tag! 'n2:Description', item[:description]
|
223
|
-
xml.tag! 'n2:ItemURL', item[:url]
|
224
|
-
xml.tag! 'n2:ItemCategory', item[:category] if item[:category]
|
225
|
-
end
|
226
|
-
end
|
173
|
+
def with_money_default(money)
|
174
|
+
amount(money).to_f.zero? ? 100 : money
|
227
175
|
end
|
228
176
|
end
|
229
177
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'nokogiri'
|
2
2
|
require 'digest/sha1'
|
3
3
|
|
4
4
|
module ActiveMerchant
|
@@ -101,9 +101,8 @@ module ActiveMerchant
|
|
101
101
|
def parse(xml)
|
102
102
|
response = {}
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
104
|
+
doc = Nokogiri::XML(xml)
|
105
|
+
doc.xpath('//response/*').each do |node|
|
107
106
|
if (node.elements.size == 0)
|
108
107
|
response[node.name.downcase.to_sym] = normalize(node.text)
|
109
108
|
else
|
@@ -112,8 +111,7 @@ module ActiveMerchant
|
|
112
111
|
response[name.to_sym] = normalize(childnode.text)
|
113
112
|
end
|
114
113
|
end
|
115
|
-
|
116
|
-
end unless xml.root.nil?
|
114
|
+
end unless doc.root.nil?
|
117
115
|
|
118
116
|
response
|
119
117
|
end
|
@@ -312,4 +310,4 @@ module ActiveMerchant
|
|
312
310
|
end
|
313
311
|
end
|
314
312
|
end
|
315
|
-
end
|
313
|
+
end
|
@@ -58,14 +58,6 @@ module ActiveMerchant #:nodoc:
|
|
58
58
|
commit(:post, 'charges', post, meta)
|
59
59
|
end
|
60
60
|
|
61
|
-
def authorize(money, creditcard, options = {})
|
62
|
-
raise "Stripe does not support separate authorization and capture"
|
63
|
-
end
|
64
|
-
|
65
|
-
def capture(money, identification, options = {})
|
66
|
-
raise "Stripe does not support separate authorization and capture"
|
67
|
-
end
|
68
|
-
|
69
61
|
def void(identification, options = {})
|
70
62
|
commit(:post, "charges/#{CGI.escape(identification)}/refund", {})
|
71
63
|
end
|
@@ -215,7 +207,7 @@ module ActiveMerchant #:nodoc:
|
|
215
207
|
Response.new(success,
|
216
208
|
success ? "Transaction approved" : response["error"]["message"],
|
217
209
|
response,
|
218
|
-
:test => !response["livemode"],
|
210
|
+
:test => response.has_key?("livemode") ? !response["livemode"] : false,
|
219
211
|
:authorization => response["id"],
|
220
212
|
:avs_result => { :code => avs_code },
|
221
213
|
:cvv_result => cvc_code
|
@@ -1239,7 +1239,7 @@ module ActiveMerchant #:nodoc:
|
|
1239
1239
|
when payment_method[:method].kind_of?(ActiveMerchant::Billing::CreditCard)
|
1240
1240
|
build_tag soap, :string, 'CardNumber', payment_method[:method].number
|
1241
1241
|
build_tag soap, :string, 'CardExpiration',
|
1242
|
-
"#{
|
1242
|
+
"#{"%02d" % payment_method[:method].month}#{payment_method[:method].year}"
|
1243
1243
|
if options[:billing_address]
|
1244
1244
|
build_tag soap, :string, 'AvsStreet', options[:billing_address][:address1]
|
1245
1245
|
build_tag soap, :string, 'AvsZip', options[:billing_address][:zip]
|
@@ -1319,7 +1319,7 @@ module ActiveMerchant #:nodoc:
|
|
1319
1319
|
soap.CreditCardData 'xsi:type' => "ns1:CreditCardData" do |soap|
|
1320
1320
|
build_tag soap, :string, 'CardNumber', options[:payment_method].number
|
1321
1321
|
build_tag soap, :string, 'CardExpiration',
|
1322
|
-
"#{
|
1322
|
+
"#{"%02d" % options[:payment_method].month}#{options[:payment_method].year}"
|
1323
1323
|
if options[:billing_address]
|
1324
1324
|
build_tag soap, :string, 'AvsStreet', options[:billing_address][:address1]
|
1325
1325
|
build_tag soap, :string, 'AvsZip', options[:billing_address][:zip]
|
@@ -175,11 +175,7 @@ module ActiveMerchant #:nodoc:
|
|
175
175
|
:test => @options[:test] || test?,
|
176
176
|
:authorization => response[:ref_num],
|
177
177
|
:cvv_result => response[:cvv2_result_code],
|
178
|
-
:avs_result => {
|
179
|
-
:street_match => response[:avs_result_code].to_s[0,1],
|
180
|
-
:postal_match => response[:avs_result_code].to_s[1,1],
|
181
|
-
:code => response[:avs_result_code].to_s[2,1]
|
182
|
-
}
|
178
|
+
:avs_result => { :code => response[:avs_result_code] }
|
183
179
|
)
|
184
180
|
end
|
185
181
|
|