activemerchant 1.71.0 → 1.72.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 +4 -4
- data/CHANGELOG +22 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +2 -2
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +10 -2
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +13 -4
- data/lib/active_merchant/billing/gateways/conekta.rb +3 -4
- data/lib/active_merchant/billing/gateways/data_cash.rb +2 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +11 -1
- data/lib/active_merchant/billing/gateways/kushki.rb +15 -5
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +18 -17
- data/lib/active_merchant/billing/gateways/payu_latam.rb +65 -45
- data/lib/active_merchant/billing/gateways/qvalent.rb +13 -1
- data/lib/active_merchant/billing/gateways/safe_charge.rb +3 -1
- data/lib/active_merchant/billing/gateways/wepay.rb +2 -11
- data/lib/active_merchant/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91813c36ae054c9add904f9965d29cfac9a24c35
|
4
|
+
data.tar.gz: d2cb404a124499f46cf62905fe0233ec3a34d39e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff2929501d9e434b2ffa8b47be745ae8fcb58ddafb2a74dcdfb7ce7699714f4605c7f75cb9bfccb9b917c9e24c2e01061ca49461573e6f1e0031c194f80869a7
|
7
|
+
data.tar.gz: 9fef03d8d88743d0396c359f0c29ce0a1d617d93c9c9c696ad48d9f0b3e2830dfe3ce524a5ee84f4432dd581bd48b18d0cae6e70c48db5e0d08978c68f6ca853
|
data/CHANGELOG
CHANGED
@@ -2,6 +2,27 @@
|
|
2
2
|
|
3
3
|
== HEAD
|
4
4
|
|
5
|
+
== Version 1.72.0 (September 20, 2017)
|
6
|
+
* Adyen: Fix failing remote tests [dtykocki] #2584
|
7
|
+
* Authorize.net: Remove numeric restriction on customer ID [dtykocki] #2579
|
8
|
+
* Authorize.net: Restore default state value for non-US addresses [jasonwebster] #2563
|
9
|
+
* Beanstream: Do not default state and zip with empty country [dtykocki] #2582
|
10
|
+
* Braintree Blue: Add eci_indicator field for Apple Pay [davidsantoso] #2565
|
11
|
+
* Conekta: Add guard clause for details fallbacks [curiousepic] #2573
|
12
|
+
* Conekta: Pull required details from billing address [nfarve] #2568
|
13
|
+
* DataCash: Enable refunding recurring transactions [davidsantoso] #2560
|
14
|
+
* Ebanx: Adds Brazil Specific Parameters [nfarve] #2559
|
15
|
+
* Kushki: Add support for refunds [dtykocki] #2575
|
16
|
+
* MercadoPago: Additional tweaks for transaction requests [davidsantoso]
|
17
|
+
* MercadoPago: Default to alphanumeric order_id [davidsantoso]
|
18
|
+
* MercadoPago: Send diners_club cards as diners [davidsantoso] #2585
|
19
|
+
* PayU Latam: Correctly condition buyer element fields [curiousepic] #2578
|
20
|
+
* PayU Latam: Pass unique buyer fields and country requirements [curiousepic] #2570
|
21
|
+
* Qvalent: Support general credit [curiousepic] #2558
|
22
|
+
* SafeCharge: Update to Version 4.1.0 [nfarve] #2556
|
23
|
+
* WePay: Don't default API version header [curiousepic] #2567
|
24
|
+
* WePay: Don't require email for Store [curiousepic] #2588
|
25
|
+
|
5
26
|
== Version 1.71.0 (August 22, 2017)
|
6
27
|
* Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551
|
7
28
|
* Checkout V2: Add localized_amount support to add_invoice function [nicolas-maalouf-cko] #2452
|
@@ -19,6 +40,7 @@
|
|
19
40
|
* TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550
|
20
41
|
* TransFirst: Fix partial refund [nfarve] #2541
|
21
42
|
* Vantiv (Litle): Pass 3DS fields [curiousepic] #2536
|
43
|
+
* Braintree Blue: Add phone to options [deedeelavinder] #2564
|
22
44
|
|
23
45
|
== Version 1.70.0 (August 4, 2017)
|
24
46
|
* Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520
|
@@ -535,7 +535,7 @@ module ActiveMerchant
|
|
535
535
|
|
536
536
|
def add_customer_data(xml, payment_source, options)
|
537
537
|
xml.customer do
|
538
|
-
xml.id(options[:customer]) unless empty?(options[:customer]) || options[:customer] !~ /^\
|
538
|
+
xml.id(options[:customer]) unless empty?(options[:customer]) || options[:customer] !~ /^\w+$/
|
539
539
|
xml.email(options[:email]) unless empty?(options[:email])
|
540
540
|
end
|
541
541
|
|
@@ -719,7 +719,7 @@ module ActiveMerchant
|
|
719
719
|
if ["US", "CA"].include?(address[:country])
|
720
720
|
address[:state] || 'NC'
|
721
721
|
else
|
722
|
-
address[:state]
|
722
|
+
address[:state] || 'n/a'
|
723
723
|
end
|
724
724
|
end
|
725
725
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
2
2
|
module Billing #:nodoc:
|
3
3
|
module BeanstreamCore
|
4
|
+
include Empty
|
5
|
+
|
4
6
|
RECURRING_URL = 'https://www.beanstream.com/scripts/recurring_billing.asp'
|
5
7
|
SECURE_PROFILE_URL = 'https://www.beanstream.com/scripts/payment_profile.asp'
|
6
8
|
|
@@ -177,6 +179,7 @@ module ActiveMerchant #:nodoc:
|
|
177
179
|
end
|
178
180
|
|
179
181
|
private
|
182
|
+
|
180
183
|
def purchase_action(source)
|
181
184
|
if source.is_a?(Check)
|
182
185
|
:check_purchase
|
@@ -227,7 +230,7 @@ module ActiveMerchant #:nodoc:
|
|
227
230
|
post[:ordAddress1] = billing_address[:address1]
|
228
231
|
post[:ordAddress2] = billing_address[:address2]
|
229
232
|
post[:ordCity] = billing_address[:city]
|
230
|
-
post[:ordProvince] =
|
233
|
+
post[:ordProvince] = state_for(billing_address)
|
231
234
|
post[:ordPostalCode] = billing_address[:zip]
|
232
235
|
post[:ordCountry] = billing_address[:country]
|
233
236
|
end
|
@@ -238,7 +241,7 @@ module ActiveMerchant #:nodoc:
|
|
238
241
|
post[:shipAddress1] = shipping_address[:address1]
|
239
242
|
post[:shipAddress2] = shipping_address[:address2]
|
240
243
|
post[:shipCity] = shipping_address[:city]
|
241
|
-
post[:shipProvince] =
|
244
|
+
post[:shipProvince] = state_for(shipping_address)
|
242
245
|
post[:shipPostalCode] = shipping_address[:zip]
|
243
246
|
post[:shipCountry] = shipping_address[:country]
|
244
247
|
post[:shippingMethod] = shipping_address[:shipping_method]
|
@@ -246,8 +249,13 @@ module ActiveMerchant #:nodoc:
|
|
246
249
|
end
|
247
250
|
end
|
248
251
|
|
252
|
+
def state_for(address)
|
253
|
+
STATES[address[:state].upcase] || address[:state] if address[:state]
|
254
|
+
end
|
255
|
+
|
249
256
|
def prepare_address_for_non_american_countries(options)
|
250
257
|
[ options[:billing_address], options[:shipping_address] ].compact.each do |address|
|
258
|
+
next if empty?(address[:country])
|
251
259
|
unless ['US', 'CA'].include?(address[:country])
|
252
260
|
address[:state] = '--'
|
253
261
|
address[:zip] = '000000' unless address[:zip]
|
@@ -158,6 +158,8 @@ module ActiveMerchant #:nodoc:
|
|
158
158
|
:first_name => creditcard.first_name,
|
159
159
|
:last_name => creditcard.last_name,
|
160
160
|
:email => scrub_email(options[:email]),
|
161
|
+
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
|
162
|
+
options[:billing_address][:phone]),
|
161
163
|
:credit_card => credit_card_params
|
162
164
|
)
|
163
165
|
Response.new(result.success?, message_from_result(result),
|
@@ -228,6 +230,8 @@ module ActiveMerchant #:nodoc:
|
|
228
230
|
:first_name => creditcard.first_name,
|
229
231
|
:last_name => creditcard.last_name,
|
230
232
|
:email => scrub_email(options[:email]),
|
233
|
+
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
|
234
|
+
options[:billing_address][:phone]),
|
231
235
|
:id => options[:customer],
|
232
236
|
}.merge credit_card_params
|
233
237
|
result = @braintree_gateway.customer.create(merge_credit_card_options(parameters, options))
|
@@ -312,7 +316,7 @@ module ActiveMerchant #:nodoc:
|
|
312
316
|
:region => address[:state],
|
313
317
|
:postal_code => scrub_zip(address[:zip]),
|
314
318
|
}
|
315
|
-
if(address[:country] || address[:country_code_alpha2])
|
319
|
+
if (address[:country] || address[:country_code_alpha2])
|
316
320
|
mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2])
|
317
321
|
elsif address[:country_name]
|
318
322
|
mapped[:country_name] = address[:country_name]
|
@@ -451,6 +455,7 @@ module ActiveMerchant #:nodoc:
|
|
451
455
|
def customer_hash(customer, include_credit_cards=false)
|
452
456
|
hash = {
|
453
457
|
"email" => customer.email,
|
458
|
+
"phone" => customer.phone,
|
454
459
|
"first_name" => customer.first_name,
|
455
460
|
"last_name" => customer.last_name,
|
456
461
|
"id" => customer.id
|
@@ -492,7 +497,8 @@ module ActiveMerchant #:nodoc:
|
|
492
497
|
|
493
498
|
customer_details = {
|
494
499
|
"id" => transaction.customer_details.id,
|
495
|
-
"email" => transaction.customer_details.email
|
500
|
+
"email" => transaction.customer_details.email,
|
501
|
+
"phone" => transaction.customer_details.phone,
|
496
502
|
}
|
497
503
|
|
498
504
|
billing_details = {
|
@@ -541,7 +547,9 @@ module ActiveMerchant #:nodoc:
|
|
541
547
|
:order_id => options[:order_id],
|
542
548
|
:customer => {
|
543
549
|
:id => options[:store] == true ? "" : options[:store],
|
544
|
-
:email => scrub_email(options[:email])
|
550
|
+
:email => scrub_email(options[:email]),
|
551
|
+
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
|
552
|
+
options[:billing_address][:phone])
|
545
553
|
},
|
546
554
|
:options => {
|
547
555
|
:store_in_vault => options[:store] ? true : false,
|
@@ -582,7 +590,8 @@ module ActiveMerchant #:nodoc:
|
|
582
590
|
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"),
|
583
591
|
:expiration_year => credit_card_or_vault_id.year.to_s,
|
584
592
|
:cardholder_name => credit_card_or_vault_id.name,
|
585
|
-
:cryptogram => credit_card_or_vault_id.payment_cryptogram
|
593
|
+
:cryptogram => credit_card_or_vault_id.payment_cryptogram,
|
594
|
+
:eci_indicator => credit_card_or_vault_id.eci
|
586
595
|
}
|
587
596
|
elsif credit_card_or_vault_id.source == :android_pay
|
588
597
|
parameters[:android_pay_card] = {
|
@@ -82,16 +82,15 @@ module ActiveMerchant #:nodoc:
|
|
82
82
|
|
83
83
|
def add_details_data(post, options)
|
84
84
|
details = {}
|
85
|
-
details[:name] = options[:customer] if options[:
|
85
|
+
details[:name] = options[:customer] || (options[:billing_address][:name] if options[:billing_address])
|
86
|
+
details[:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address])
|
86
87
|
details[:email] = options[:email] if options[:email]
|
87
|
-
details[:phone] = options[:phone] if options[:phone]
|
88
|
-
post[:device_fingerprint] = options[:device_fingerprint] if options[:device_fingerprint]
|
89
88
|
details[:ip] = options[:ip] if options[:ip]
|
90
89
|
add_billing_address(details, options)
|
91
90
|
add_line_items(details, options)
|
92
91
|
add_shipment(details, options)
|
93
|
-
|
94
92
|
post[:details] = details
|
93
|
+
post[:device_fingerprint] = options[:device_fingerprint] if options[:device_fingerprint]
|
95
94
|
end
|
96
95
|
|
97
96
|
def add_shipment(post, options)
|
@@ -168,6 +168,7 @@ module ActiveMerchant
|
|
168
168
|
unless money.nil?
|
169
169
|
xml.tag! :TxnDetails do
|
170
170
|
xml.tag! :amount, amount(money)
|
171
|
+
xml.tag! :capturemethod, 'ecomm'
|
171
172
|
end
|
172
173
|
end
|
173
174
|
end
|
@@ -188,6 +189,7 @@ module ActiveMerchant
|
|
188
189
|
xml.tag! :TxnDetails do
|
189
190
|
xml.tag! :merchantreference, format_reference_number(options[:order_id])
|
190
191
|
xml.tag! :amount, amount(money)
|
192
|
+
xml.tag! :capturemethod, 'ecomm'
|
191
193
|
end
|
192
194
|
end
|
193
195
|
end
|
@@ -48,7 +48,7 @@ module ActiveMerchant #:nodoc:
|
|
48
48
|
add_customer_data(post, payment, options)
|
49
49
|
add_payment(post, payment)
|
50
50
|
add_address(post, options)
|
51
|
-
|
51
|
+
add_customer_responsible_person(post, payment, options) if post[:payment][:country] == 'BR'
|
52
52
|
commit(:purchase, post)
|
53
53
|
end
|
54
54
|
|
@@ -60,6 +60,7 @@ module ActiveMerchant #:nodoc:
|
|
60
60
|
add_customer_data(post, payment, options)
|
61
61
|
add_payment(post, payment)
|
62
62
|
add_address(post, options)
|
63
|
+
add_customer_responsible_person(post, payment, options) if post[:payment][:country] == 'BR'
|
63
64
|
post[:payment][:creditcard][:auto_capture] = false
|
64
65
|
|
65
66
|
commit(:authorize, post)
|
@@ -129,6 +130,14 @@ module ActiveMerchant #:nodoc:
|
|
129
130
|
post[:payment][:name] = payment.name
|
130
131
|
post[:payment][:email] = options[:email] || "unspecified@example.com"
|
131
132
|
post[:payment][:document] = options[:document]
|
133
|
+
post[:payment][:birth_date] = options[:birth_date] if options[:birth_date]
|
134
|
+
end
|
135
|
+
|
136
|
+
def add_customer_responsible_person(post, payment, options)
|
137
|
+
post[:payment][:responsible] = {}
|
138
|
+
post[:payment][:responsible][:name] = payment.name
|
139
|
+
post[:payment][:responsible][:document] = options[:document]
|
140
|
+
post[:payment][:responsible][:birth_date] = options[:birth_date] if options[:birth_date]
|
132
141
|
end
|
133
142
|
|
134
143
|
def add_address(post, options)
|
@@ -147,6 +156,7 @@ module ActiveMerchant #:nodoc:
|
|
147
156
|
post[:payment][:amount_total] = amount(money)
|
148
157
|
post[:payment][:currency_code] = (options[:currency] || currency(money))
|
149
158
|
post[:payment][:merchant_payment_code] = options[:order_id]
|
159
|
+
post[:payment][:instalments] = options[:instalments] || 1
|
150
160
|
end
|
151
161
|
|
152
162
|
def add_payment(post, payment)
|
@@ -24,6 +24,15 @@ module ActiveMerchant #:nodoc:
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def refund(amount, authorization, options={})
|
28
|
+
action = "refund"
|
29
|
+
|
30
|
+
post = {}
|
31
|
+
post[:ticketNumber] = authorization
|
32
|
+
|
33
|
+
commit(action, post)
|
34
|
+
end
|
35
|
+
|
27
36
|
def void(authorization, options={})
|
28
37
|
action = "void"
|
29
38
|
|
@@ -129,7 +138,8 @@ module ActiveMerchant #:nodoc:
|
|
129
138
|
ENDPOINT = {
|
130
139
|
"tokenize" => "tokens",
|
131
140
|
"charge" => "charges",
|
132
|
-
"void" => "charges"
|
141
|
+
"void" => "charges",
|
142
|
+
"refund" => "refund"
|
133
143
|
}
|
134
144
|
|
135
145
|
def commit(action, params)
|
@@ -152,7 +162,7 @@ module ActiveMerchant #:nodoc:
|
|
152
162
|
end
|
153
163
|
|
154
164
|
def ssl_invoke(action, params)
|
155
|
-
if
|
165
|
+
if ["void", "refund"].include?(action)
|
156
166
|
ssl_request(:delete, url(action, params), nil, headers(action))
|
157
167
|
else
|
158
168
|
ssl_post(url(action, params), post_data(params), headers(action))
|
@@ -174,8 +184,8 @@ module ActiveMerchant #:nodoc:
|
|
174
184
|
def url(action, params)
|
175
185
|
base_url = test? ? test_url : live_url
|
176
186
|
|
177
|
-
if
|
178
|
-
base_url + ENDPOINT[action] + "/" + params[:ticketNumber]
|
187
|
+
if ["void", "refund"].include?(action)
|
188
|
+
base_url + ENDPOINT[action] + "/" + params[:ticketNumber].to_s
|
179
189
|
else
|
180
190
|
base_url + ENDPOINT[action]
|
181
191
|
end
|
@@ -194,7 +204,7 @@ module ActiveMerchant #:nodoc:
|
|
194
204
|
end
|
195
205
|
|
196
206
|
def success_from(response)
|
197
|
-
return true if response["token"] || response["ticketNumber"]
|
207
|
+
return true if response["token"] || response["ticketNumber"] || response["code"] == "K000"
|
198
208
|
end
|
199
209
|
|
200
210
|
def message_from(succeeded, response)
|
@@ -10,6 +10,11 @@ module ActiveMerchant #:nodoc:
|
|
10
10
|
self.display_name = 'Mercado Pago'
|
11
11
|
self.money_format = :dollars
|
12
12
|
|
13
|
+
CARD_BRAND = {
|
14
|
+
"american_express" => "amex",
|
15
|
+
"diners_club" => "diners"
|
16
|
+
}
|
17
|
+
|
13
18
|
def initialize(options={})
|
14
19
|
requires!(options, :access_token)
|
15
20
|
super
|
@@ -18,7 +23,7 @@ module ActiveMerchant #:nodoc:
|
|
18
23
|
def purchase(money, payment, options={})
|
19
24
|
MultiResponse.run do |r|
|
20
25
|
r.process { commit("tokenize", "card_tokens", card_token_request(money, payment, options)) }
|
21
|
-
options.merge!(card_brand: payment.brand)
|
26
|
+
options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
|
22
27
|
options.merge!(card_token: r.authorization.split("|").first)
|
23
28
|
r.process { commit("purchase", "payments", purchase_request(money, payment, options) ) }
|
24
29
|
end
|
@@ -27,7 +32,7 @@ module ActiveMerchant #:nodoc:
|
|
27
32
|
def authorize(money, payment, options={})
|
28
33
|
MultiResponse.run do |r|
|
29
34
|
r.process { commit("tokenize", "card_tokens", card_token_request(money, payment, options)) }
|
30
|
-
options.merge!(card_brand: payment.brand)
|
35
|
+
options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
|
31
36
|
options.merge!(card_token: r.authorization.split("|").first)
|
32
37
|
r.process { commit("authorize", "payments", authorize_request(money, payment, options) ) }
|
33
38
|
end
|
@@ -80,7 +85,13 @@ module ActiveMerchant #:nodoc:
|
|
80
85
|
post[:security_code] = payment.verification_value
|
81
86
|
post[:expiration_month] = payment.month
|
82
87
|
post[:expiration_year] = payment.year
|
83
|
-
post[:cardholder] = {
|
88
|
+
post[:cardholder] = {
|
89
|
+
name: payment.name,
|
90
|
+
identification: {
|
91
|
+
type: options[:cardholder_identification_type],
|
92
|
+
number: options[:cardholder_identification_number]
|
93
|
+
}
|
94
|
+
}
|
84
95
|
post
|
85
96
|
end
|
86
97
|
|
@@ -126,8 +137,7 @@ module ActiveMerchant #:nodoc:
|
|
126
137
|
payer: {
|
127
138
|
address: {
|
128
139
|
zip_code: address[:zip],
|
129
|
-
|
130
|
-
street_name: split_street_address(address[:address1]).last
|
140
|
+
street_name: "#{address[:address1]} #{address[:address2]}"
|
131
141
|
}
|
132
142
|
}
|
133
143
|
})
|
@@ -141,9 +151,7 @@ module ActiveMerchant #:nodoc:
|
|
141
151
|
shipments: {
|
142
152
|
receiver_address: {
|
143
153
|
zip_code: address[:zip],
|
144
|
-
|
145
|
-
street_name: split_street_address(address[:address1]).last,
|
146
|
-
apartment: address[:address2]
|
154
|
+
street_name: "#{address[:address1]} #{address[:address2]}"
|
147
155
|
}
|
148
156
|
}
|
149
157
|
})
|
@@ -167,15 +175,12 @@ module ActiveMerchant #:nodoc:
|
|
167
175
|
post[:description] = options[:description]
|
168
176
|
post[:installments] = options[:installments] ? options[:installments].to_i : 1
|
169
177
|
post[:statement_descriptor] = options[:statement_descriptor] if options[:statement_descriptor]
|
170
|
-
post[:
|
171
|
-
type: options[:order_type] || "mercadopago",
|
172
|
-
id: options[:order_id] || generate_integer_only_order_id
|
173
|
-
}
|
178
|
+
post[:external_reference] = options[:order_id] || SecureRandom.hex(16)
|
174
179
|
end
|
175
180
|
|
176
181
|
def add_payment(post, options)
|
177
182
|
post[:token] = options[:card_token]
|
178
|
-
post[:payment_method_id] = options[:card_brand]
|
183
|
+
post[:payment_method_id] = options[:card_brand]
|
179
184
|
end
|
180
185
|
|
181
186
|
def parse(body)
|
@@ -248,10 +253,6 @@ module ActiveMerchant #:nodoc:
|
|
248
253
|
raise ResponseError.new(response)
|
249
254
|
end
|
250
255
|
end
|
251
|
-
|
252
|
-
def generate_integer_only_order_id
|
253
|
-
Time.now.to_i + rand(0..1000)
|
254
|
-
end
|
255
256
|
end
|
256
257
|
end
|
257
258
|
end
|
@@ -118,11 +118,11 @@ module ActiveMerchant #:nodoc:
|
|
118
118
|
add_credentials(post, 'SUBMIT_TRANSACTION')
|
119
119
|
add_transaction_elements(post, transaction_type, options)
|
120
120
|
add_order(post, options)
|
121
|
-
add_buyer(post, options)
|
121
|
+
add_buyer(post, payment_method, options)
|
122
122
|
add_invoice(post, amount, options)
|
123
123
|
add_signature(post)
|
124
124
|
add_payment_method(post, payment_method, options)
|
125
|
-
add_payer(post, options)
|
125
|
+
add_payer(post, payment_method, options)
|
126
126
|
add_extra_parameters(post, options)
|
127
127
|
end
|
128
128
|
|
@@ -138,6 +138,7 @@ module ActiveMerchant #:nodoc:
|
|
138
138
|
|
139
139
|
def add_transaction_elements(post, type, options)
|
140
140
|
transaction = {}
|
141
|
+
transaction[:paymentCountry] = options[:payment_country] || (options[:billing_address][:country] if options[:billing_address])
|
141
142
|
transaction[:type] = type
|
142
143
|
transaction[:ipAddress] = options[:ip] if options[:ip]
|
143
144
|
transaction[:userAgent] = options[:user_agent] if options[:user_agent]
|
@@ -152,28 +153,69 @@ module ActiveMerchant #:nodoc:
|
|
152
153
|
order[:referenceCode] = options[:order_id] || generate_unique_id
|
153
154
|
order[:description] = options[:description] || 'unspecified'
|
154
155
|
order[:language] = 'en'
|
156
|
+
order[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address]
|
155
157
|
post[:transaction][:order] = order
|
156
158
|
end
|
157
159
|
|
158
|
-
def
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
160
|
+
def add_payer(post, payment_method, options)
|
161
|
+
address = options[:billing_address]
|
162
|
+
payer = {}
|
163
|
+
payer[:fullName] = payment_method.name.strip
|
164
|
+
payer[:contactPhone] = address[:phone] if (address && address[:phone])
|
165
|
+
payer[:dniNumber] = options[:dni_number] if options[:dni_number]
|
166
|
+
payer[:dniType] = options[:dni_type] if options[:dni_type]
|
167
|
+
payer[:emailAddress] = options[:email] if options[:email]
|
168
|
+
payer[:birthdate] = options[:birth_date] if options[:birth_date] && options[:payment_country] == 'MX'
|
169
|
+
payer[:billingAddress] = billing_address_fields(options)
|
170
|
+
post[:transaction][:payer] = payer
|
171
|
+
end
|
172
|
+
|
173
|
+
def billing_address_fields(options)
|
174
|
+
return unless address = options[:billing_address]
|
175
|
+
billing_address = {}
|
176
|
+
billing_address[:street1] = address[:address1]
|
177
|
+
billing_address[:street2] = address[:address2]
|
178
|
+
billing_address[:city] = address[:city]
|
179
|
+
billing_address[:state] = address[:state]
|
180
|
+
billing_address[:country] = address[:country]
|
181
|
+
billing_address[:postalCode] = address[:zip] if options[:payment_country] == 'MX'
|
182
|
+
billing_address[:phone] = address[:phone]
|
183
|
+
billing_address
|
184
|
+
end
|
185
|
+
|
186
|
+
def add_buyer(post, payment_method, options)
|
187
|
+
buyer = {}
|
188
|
+
if buyer_hash = options[:buyer]
|
189
|
+
buyer[:fullName] = buyer_hash[:name]
|
190
|
+
buyer[:dniNumber] = buyer_hash[:dni_number]
|
191
|
+
buyer[:dniType] = buyer_hash[:dni_type]
|
192
|
+
buyer[:cnpj] = buyer_hash[:cnpj] if options[:payment_country] == 'BR'
|
193
|
+
buyer[:emailAddress] = buyer_hash[:email]
|
194
|
+
buyer[:contactPhone] = options[:shipping_address][:phone] if options[:shipping_address]
|
195
|
+
buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address]
|
196
|
+
else
|
197
|
+
buyer[:fullName] = payment_method.name.strip
|
198
|
+
buyer[:dniNumber] = options[:dni_number]
|
199
|
+
buyer[:dniType] = options[:dni_type]
|
200
|
+
buyer[:cnpj] = options[:cnpj] if options[:payment_country] == 'BR'
|
201
|
+
buyer[:emailAddress] = options[:email]
|
202
|
+
buyer[:contactPhone] = (options[:shipping_address][:phone] if options[:shipping_address]) || (options[:billing_address][:phone] if options[:billing_address])
|
203
|
+
buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address]
|
176
204
|
end
|
205
|
+
post[:transaction][:order][:buyer] = buyer
|
206
|
+
end
|
207
|
+
|
208
|
+
def shipping_address_fields(options)
|
209
|
+
return unless address = options[:shipping_address]
|
210
|
+
shipping_address = {}
|
211
|
+
shipping_address[:street1] = address[:address1]
|
212
|
+
shipping_address[:street2] = address[:address2]
|
213
|
+
shipping_address[:city] = address[:city]
|
214
|
+
shipping_address[:state] = address[:state]
|
215
|
+
shipping_address[:country] = address[:country]
|
216
|
+
shipping_address[:postalCode] = address[:zip]
|
217
|
+
shipping_address[:phone] = address[:phone]
|
218
|
+
shipping_address
|
177
219
|
end
|
178
220
|
|
179
221
|
def add_invoice(post, money, options)
|
@@ -191,8 +233,8 @@ module ActiveMerchant #:nodoc:
|
|
191
233
|
|
192
234
|
additional_values = {}
|
193
235
|
additional_values[:TX_VALUE] = tx_value
|
194
|
-
additional_values[:TX_TAX] = tx_tax
|
195
|
-
additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base
|
236
|
+
additional_values[:TX_TAX] = tx_tax if options[:payment_country] == 'CO'
|
237
|
+
additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base if options[:payment_country] == 'CO'
|
196
238
|
|
197
239
|
post[:transaction][:order][:additionalValues] = additional_values
|
198
240
|
end
|
@@ -246,29 +288,6 @@ module ActiveMerchant #:nodoc:
|
|
246
288
|
false
|
247
289
|
end
|
248
290
|
|
249
|
-
def add_payer(post, options)
|
250
|
-
if address = options[:billing_address]
|
251
|
-
payer = {}
|
252
|
-
post[:transaction][:paymentCountry] = address[:country]
|
253
|
-
payer[:fullName] = address[:name]
|
254
|
-
payer[:contactPhone] = address[:phone]
|
255
|
-
payer[:dniNumber] = options[:dni_number] if options[:dni_number]
|
256
|
-
payer[:dniType] = options[:dni_type] if options[:dni_type]
|
257
|
-
payer[:emailAddress] = options[:email] if options[:email]
|
258
|
-
payer[:contactPhone] = address[:phone]
|
259
|
-
billing_address = {}
|
260
|
-
billing_address[:street1] = address[:address1]
|
261
|
-
billing_address[:street2] = address[:address2]
|
262
|
-
billing_address[:city] = address[:city]
|
263
|
-
billing_address[:state] = address[:state]
|
264
|
-
billing_address[:country] = address[:country]
|
265
|
-
billing_address[:postalCode] = address[:zip]
|
266
|
-
billing_address[:phone] = address[:phone]
|
267
|
-
payer[:billingAddress] = billing_address
|
268
|
-
post[:transaction][:payer] = payer
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
291
|
def add_extra_parameters(post, options)
|
273
292
|
extra_parameters = {}
|
274
293
|
extra_parameters[:INSTALLMENTS_NUMBER] = options[:installments_number] || 1
|
@@ -326,6 +345,7 @@ module ActiveMerchant #:nodoc:
|
|
326
345
|
end
|
327
346
|
|
328
347
|
def post_data(params)
|
348
|
+
params.merge(test: test?)
|
329
349
|
params.to_json
|
330
350
|
end
|
331
351
|
|
@@ -61,6 +61,18 @@ module ActiveMerchant #:nodoc:
|
|
61
61
|
commit("refund", post)
|
62
62
|
end
|
63
63
|
|
64
|
+
# Credit requires the merchant account to be enabled for "Adhoc Refunds"
|
65
|
+
def credit(amount, payment_method, options={})
|
66
|
+
post = {}
|
67
|
+
add_invoice(post, amount, options)
|
68
|
+
add_order_number(post, options)
|
69
|
+
add_payment_method(post, payment_method)
|
70
|
+
add_customer_data(post, options)
|
71
|
+
add_soft_descriptors(post, options)
|
72
|
+
|
73
|
+
commit("refund", post)
|
74
|
+
end
|
75
|
+
|
64
76
|
def void(authorization, options={})
|
65
77
|
post = {}
|
66
78
|
add_reference(post, authorization, options)
|
@@ -136,7 +148,7 @@ module ActiveMerchant #:nodoc:
|
|
136
148
|
end
|
137
149
|
|
138
150
|
def add_customer_data(post, options)
|
139
|
-
post["order.ipAddress"] = options[:ip]
|
151
|
+
post["order.ipAddress"] = options[:ip] || "127.0.0.1"
|
140
152
|
post["order.xid"] = options[:xid] if options[:xid]
|
141
153
|
post["order.cavv"] = options[:cavv] if options[:cavv]
|
142
154
|
end
|
@@ -13,7 +13,7 @@ module ActiveMerchant #:nodoc:
|
|
13
13
|
self.homepage_url = 'https://www.safecharge.com'
|
14
14
|
self.display_name = 'SafeCharge'
|
15
15
|
|
16
|
-
VERSION = '4.0
|
16
|
+
VERSION = '4.1.0'
|
17
17
|
|
18
18
|
def initialize(options={})
|
19
19
|
requires!(options, :client_login_id, :client_password)
|
@@ -118,6 +118,8 @@ module ActiveMerchant #:nodoc:
|
|
118
118
|
post[:sg_Version] = VERSION
|
119
119
|
post[:sg_ClientUniqueID] = options[:order_id] if options[:order_id]
|
120
120
|
post[:sg_UserID] = options[:user_id] if options[:user_id]
|
121
|
+
post[:sg_AuthType] = options[:auth_type] if options[:auth_type]
|
122
|
+
post[:sg_ExpectedFulfillmentCount] = options[:expected_fulfillment_count] if options[:expected_fulfillment_count]
|
121
123
|
end
|
122
124
|
|
123
125
|
def add_payment(post, payment)
|
@@ -10,8 +10,6 @@ module ActiveMerchant #:nodoc:
|
|
10
10
|
self.default_currency = 'USD'
|
11
11
|
self.display_name = 'WePay'
|
12
12
|
|
13
|
-
API_VERSION = "2017-02-01"
|
14
|
-
|
15
13
|
def initialize(options = {})
|
16
14
|
requires!(options, :client_id, :account_id, :access_token)
|
17
15
|
super(options)
|
@@ -78,8 +76,6 @@ module ActiveMerchant #:nodoc:
|
|
78
76
|
end
|
79
77
|
|
80
78
|
def store(creditcard, options = {})
|
81
|
-
requires!(options, :email)
|
82
|
-
|
83
79
|
post = {}
|
84
80
|
post[:client_id] = @options[:client_id]
|
85
81
|
post[:user_name] = "#{creditcard.first_name} #{creditcard.last_name}"
|
@@ -229,19 +225,14 @@ module ActiveMerchant #:nodoc:
|
|
229
225
|
headers = {
|
230
226
|
"Content-Type" => "application/json",
|
231
227
|
"User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
232
|
-
"Authorization" => "Bearer #{@options[:access_token]}"
|
233
|
-
"Api-Version" => api_version(options)
|
228
|
+
"Authorization" => "Bearer #{@options[:access_token]}"
|
234
229
|
}
|
235
|
-
|
230
|
+
headers["Api-Version"] = options[:version] if options[:version]
|
236
231
|
headers["Client-IP"] = options[:ip] if options[:ip]
|
237
232
|
headers["WePay-Risk-Token"] = options[:risk_token] if options[:risk_token]
|
238
233
|
|
239
234
|
headers
|
240
235
|
end
|
241
|
-
|
242
|
-
def api_version(options)
|
243
|
-
options[:version] || API_VERSION
|
244
|
-
end
|
245
236
|
end
|
246
237
|
end
|
247
238
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemerchant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.72.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|