activemerchant 1.70.0 → 1.71.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e4551f67805adf4841b97037e5340d2a628864e
4
- data.tar.gz: 289a668109a083ee0ee467972dddfd8adc65c5d6
3
+ metadata.gz: fff082133e880818be78a31b9df09e0c8e03e3a2
4
+ data.tar.gz: 47044f1c90dc309d2bc1f63fd7de727313c5b6de
5
5
  SHA512:
6
- metadata.gz: 79a3b02993aecc1c0b0fabc8a0d96901cb40388ee52f2fec05be7d6b6377b956ed60e46f72ab113103d430201ef3402ef94dc33c7022ae0d732e088b2be145a3
7
- data.tar.gz: a887ee071f9df0d1e49a5e92fd59576c142ae59a1a16df872c9c380b77ecb5eb6d7933090697564e1eaedd80685e859fd93b74be0344a451bdce297abc54292c
6
+ metadata.gz: 3e2990e84e388fd93ab8030964ec8b01835c9a133a871b458c49a20ccfaa98280d1a6849f46f5633cf5a4405e8031a32cbd84ad75615c9bb44c93cd0b9c6555a
7
+ data.tar.gz: 6f255b508c3ff0de4151bd38344c144f0c138166f716f9a262938709f463a24f2711d6f801402dd3600ad61c15c76b5ccc31932a8ef16b0abaa4d7adf3f5b6d6
data/CHANGELOG CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  == HEAD
4
4
 
5
+ == Version 1.71.0 (August 22, 2017)
6
+ * Bambora formerly Beanstream: Change casing on customerIp variable [aengusbates] #2551
7
+ * Checkout V2: Add localized_amount support to add_invoice function [nicolas-maalouf-cko] #2452
8
+ * Checkout V2: Add UAE to country list [shasum] #2548
9
+ * Checkout V2: Fix success response code validation [nicolas-maalouf-cko] #2452
10
+ * CreditCall: Only allow AVS when specified [curiousepic] #2549
11
+ * CreditCall: Parse additional params from responses [nfarve] #2552
12
+ * CreditCall: Parse more response params [nfavre] #2543
13
+ * MercadoPago: Small tweaks to building requests [davidsantoso] #2555
14
+ * Orbital: Support Network Tokenization Credit Cards [curiousepic] #2553
15
+ * Orbital: Updgrade schema version to 7.1 [curiousepic] #2546
16
+ * Remove HUF from default non-fractional currencies [curiousepic] #2538
17
+ * Stripe: Add support for statement_address parameters for EMV transactions [malcolm-mergulhao] #2524
18
+ * TransFirst Express: Don't send address2 without value [nfarve] #2545
19
+ * TransFirst Express: Fix Optional Fields Being Passed Blank [nfarve] #2550
20
+ * TransFirst: Fix partial refund [nfarve] #2541
21
+ * Vantiv (Litle): Pass 3DS fields [curiousepic] #2536
22
+
5
23
  == Version 1.70.0 (August 4, 2017)
6
24
  * Barclaycard Smartpay: Provider a default billing address house number [nfarve] #2520
7
25
  * FirstData E4: Fix duplicate XID and CAVV values in tokenized transactions [jasonwebster] #2529
@@ -15,6 +33,9 @@
15
33
  * Qvalent: Pass 3dSecure fields [curiousepic] #2508
16
34
  * SafeCharge: Correct UserID field name [curiousepic]
17
35
  * SafeCharge: Pass UserID field [curiousepic] #2507
36
+ * AuthorizeNet: Allow Response Code 4 to be returned as successful [nfarve] #2530
37
+ * Forte: Remove order number from captures in Forte Gateway [nfarve] #2532
38
+ * PayU Latam: Add additional mandatory fields [deedeelavinder] #2528
18
39
 
19
40
  == Version 1.69.0 (July 12, 2017)
20
41
  * WePay: Add payer_rbits and transaction_rbits optional fields [davidsantoso]
@@ -126,7 +126,7 @@ module ActiveMerchant #:nodoc:
126
126
  self.supported_cardtypes = []
127
127
 
128
128
  class_attribute :currencies_without_fractions, :currencies_with_three_decimal_places
129
- self.currencies_without_fractions = %w(BIF BYR CLP CVE DJF GNF HUF ISK JPY KMF KRW PYG RWF UGX VND VUV XAF XOF XPF)
129
+ self.currencies_without_fractions = %w(BIF BYR CLP CVE DJF GNF ISK JPY KMF KRW PYG RWF UGX VND VUV XAF XOF XPF)
130
130
  self.currencies_with_three_decimal_places = %w()
131
131
 
132
132
  class_attribute :homepage_url
@@ -898,7 +898,7 @@ module ActiveMerchant
898
898
  if cim?(action) || (action == :verify_credentials)
899
899
  response[:result_code] == "Ok"
900
900
  else
901
- response[:response_code] == APPROVED && TRANSACTION_ALREADY_ACTIONED.exclude?(response[:response_reason_code])
901
+ [APPROVED, FRAUD_REVIEW].include?(response[:response_code]) && TRANSACTION_ALREADY_ACTIONED.exclude?(response[:response_reason_code])
902
902
  end
903
903
  end
904
904
 
@@ -186,7 +186,7 @@ module ActiveMerchant #:nodoc:
186
186
  end
187
187
 
188
188
  def add_customer_ip(post, options)
189
- post[:customerIP] = options[:ip] if options[:ip]
189
+ post[:customerIp] = options[:ip] if options[:ip]
190
190
  end
191
191
 
192
192
  def void_action(original_transaction_type)
@@ -6,7 +6,7 @@ module ActiveMerchant #:nodoc:
6
6
  self.live_url = "https://api2.checkout.com/v2"
7
7
  self.test_url = "https://sandbox.checkout.com/api2/v2"
8
8
 
9
- self.supported_countries = ['AD', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA']
9
+ self.supported_countries = ['AD', 'AE', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA']
10
10
  self.default_currency = "USD"
11
11
  self.money_format = :cents
12
12
  self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
@@ -75,7 +75,7 @@ module ActiveMerchant #:nodoc:
75
75
  private
76
76
 
77
77
  def add_invoice(post, money, options)
78
- post[:value] = amount(money)
78
+ post[:value] = localized_amount(money, options[:currency])
79
79
  post[:trackId] = options[:order_id]
80
80
  post[:currency] = options[:currency] || currency(money)
81
81
  post[:descriptor] = {}
@@ -166,7 +166,7 @@ module ActiveMerchant #:nodoc:
166
166
  end
167
167
 
168
168
  def success_from(response)
169
- response["responseCode"] == "10000" || response["responseCode"] == "10100"
169
+ (response["responseCode"] == "10000" && !response["responseMessage"].start_with?("40")) || response["responseCode"] == "10100"
170
170
  end
171
171
 
172
172
  def message_from(succeeded, response)
@@ -14,6 +14,32 @@ module ActiveMerchant #:nodoc:
14
14
 
15
15
  self.homepage_url = 'https://www.creditcall.com'
16
16
  self.display_name = 'Creditcall'
17
+
18
+ CVV_CODE = {
19
+ "matched" => "M",
20
+ "notmatched" => "N",
21
+ "notchecked" => "P",
22
+ "partialmatch" => "N"
23
+ }
24
+
25
+ AVS_CODE = {
26
+ "matched;matched" => "D",
27
+ "matched;notchecked" =>"B",
28
+ "matched;notmatched" => "A",
29
+ "matched;partialmatch" => "A",
30
+ "notchecked;matched" => "P",
31
+ "notchecked;notchecked" =>"I",
32
+ "notchecked;notmatched" => "I",
33
+ "notchecked;partialmatch" => "I",
34
+ "notmatched;matched" => "W",
35
+ "notmatched;notchecked" =>"C",
36
+ "notmatched;notmatched" => "C",
37
+ "notmatched;partialmatch" => "C",
38
+ "partialmatched;matched" => "W",
39
+ "partialmatched;notchecked" =>"C",
40
+ "partialmatched;notmatched" => "C",
41
+ "partialmatched;partialmatch" => "C"
42
+ }
17
43
 
18
44
  def initialize(options={})
19
45
  requires!(options, :terminal_id, :transaction_key)
@@ -26,11 +52,16 @@ module ActiveMerchant #:nodoc:
26
52
  r.process { capture(money, r.authorization, options) }
27
53
  end
28
54
 
55
+ merged_params = multi_response.responses.map { |r| r.params }.reduce({}, :merge)
56
+
29
57
  Response.new(
30
58
  multi_response.primary_response.success?,
31
59
  multi_response.primary_response.message,
32
- multi_response.primary_response.params,
60
+ merged_params,
33
61
  authorization: multi_response.responses.first.authorization,
62
+ avs_result: AVSResult.new(code: avs_result_code_from(merged_params)),
63
+ cvv_result: CVVResult.new(cvv_result_code_from(merged_params)),
64
+ error_code: error_result_code_from(merged_params),
34
65
  test: test?
35
66
  )
36
67
  end
@@ -92,6 +123,18 @@ module ActiveMerchant #:nodoc:
92
123
 
93
124
  private
94
125
 
126
+ def avs_result_code_from(params)
127
+ AVS_CODE["#{params['Address']};#{params['Zip']}"]
128
+ end
129
+
130
+ def cvv_result_code_from(params)
131
+ CVV_CODE[params["CSC"]]
132
+ end
133
+
134
+ def error_result_code_from(params)
135
+ params["ErrorCode"]
136
+ end
137
+
95
138
  def build_xml_request
96
139
  builder = Nokogiri::XML::Builder.new do |xml|
97
140
  xml.Request(type: "CardEaseXML", version: "1.0.0") do
@@ -120,17 +163,22 @@ module ActiveMerchant #:nodoc:
120
163
 
121
164
  def add_card_details(xml, payment_method, options={})
122
165
  xml.CardDetails do
123
- xml.Manual(type: "ecommerce") do
166
+ xml.Manual(type: manual_type(options)) do
124
167
  xml.PAN payment_method.number
125
168
  xml.ExpiryDate exp_date(payment_method)
126
169
  xml.CSC payment_method.verification_value unless empty?(payment_method.verification_value)
127
170
  end
128
171
 
129
- if address = options[:billing_address]
130
- xml.AdditionalVerification do
131
- xml.Address address[:address1]
132
- xml.Zip address[:zip]
133
- end
172
+ add_additional_verification(xml, options)
173
+ end
174
+ end
175
+
176
+ def add_additional_verification(xml, options)
177
+ return unless (options[:verify_zip].to_s == 'true') || (options[:verify_address].to_s == 'true')
178
+ if address = options[:billing_address]
179
+ xml.AdditionalVerification do
180
+ xml.Zip address[:zip] if options[:verify_zip].to_s == 'true'
181
+ xml.Address address[:address1] if options[:verify_address].to_s == 'true'
134
182
  end
135
183
  end
136
184
  end
@@ -157,6 +205,16 @@ module ActiveMerchant #:nodoc:
157
205
  end
158
206
  end
159
207
 
208
+ node = xml.xpath("//Response/CardDetails")
209
+ node.children.each do |childnode|
210
+ if childnode.elements.empty?
211
+ response[childnode.name] = childnode.text
212
+ else
213
+ childnode_to_response(response, childnode)
214
+ end
215
+ end
216
+
217
+
160
218
  response
161
219
  end
162
220
 
@@ -179,8 +237,9 @@ module ActiveMerchant #:nodoc:
179
237
  message_from(response),
180
238
  response,
181
239
  authorization: authorization_from(response),
182
- avs_result: AVSResult.new(code: response["some_avs_response_key"]),
183
- cvv_result: CVVResult.new(response["some_cvv_response_key"]),
240
+ avs_result: AVSResult.new(code: avs_result_code_from(response)),
241
+ cvv_result: CVVResult.new(cvv_result_code_from(response)),
242
+ error_code: error_result_code_from(response),
184
243
  test: test?
185
244
  )
186
245
  end
@@ -205,6 +264,9 @@ module ActiveMerchant #:nodoc:
205
264
  response["CardEaseReference"]
206
265
  end
207
266
 
267
+ def manual_type(options)
268
+ options[:manual_type] ? options[:manual_type] : "ecommerce"
269
+ end
208
270
  end
209
271
  end
210
272
  end
@@ -46,7 +46,6 @@ module ActiveMerchant #:nodoc:
46
46
 
47
47
  def capture(money, authorization, options={})
48
48
  post = {}
49
- add_invoice(post, options)
50
49
  post[:transaction_id] = transaction_id_from(authorization)
51
50
  post[:authorization_code] = authorization_code_from(authorization) || ""
52
51
  post[:action] = "capture"
@@ -175,7 +175,7 @@ module ActiveMerchant #:nodoc:
175
175
  add_order_source(doc, payment_method, options)
176
176
  add_billing_address(doc, payment_method, options)
177
177
  add_shipping_address(doc, payment_method, options)
178
- add_payment_method(doc, payment_method)
178
+ add_payment_method(doc, payment_method, options)
179
179
  add_pos(doc, payment_method)
180
180
  add_descriptor(doc, options)
181
181
  add_debt_repayment(doc, options)
@@ -194,7 +194,7 @@ module ActiveMerchant #:nodoc:
194
194
  doc.debtRepayment(true) if options[:debt_repayment] == true
195
195
  end
196
196
 
197
- def add_payment_method(doc, payment_method)
197
+ def add_payment_method(doc, payment_method, options)
198
198
  if payment_method.is_a?(String)
199
199
  doc.token do
200
200
  doc.litleToken(payment_method)
@@ -214,6 +214,11 @@ module ActiveMerchant #:nodoc:
214
214
  doc.cardholderAuthentication do
215
215
  doc.authenticationValue(payment_method.payment_cryptogram)
216
216
  end
217
+ elsif options[:order_source] && options[:order_source].start_with?('3ds')
218
+ doc.cardholderAuthentication do
219
+ doc.authenticationValue(options[:cavv]) if options[:cavv]
220
+ doc.authenticationTransactionId(options[:xid]) if options[:xid]
221
+ end
217
222
  end
218
223
  end
219
224
  end
@@ -91,6 +91,7 @@ module ActiveMerchant #:nodoc:
91
91
  add_additional_data(post, options)
92
92
  add_customer_data(post, payment, options)
93
93
  add_address(post, options)
94
+ post[:binary_mode] = true
94
95
  post
95
96
  end
96
97
 
@@ -101,12 +102,13 @@ module ActiveMerchant #:nodoc:
101
102
  end
102
103
 
103
104
  def add_additional_data(post, options)
104
- post[:sponsor_id] = options["sponsor_id"]
105
+ post[:sponsor_id] = options[:sponsor_id]
105
106
  post[:additional_info] = {
106
107
  ip_address: options[:ip_address]
107
108
  }
108
109
 
109
110
  add_address(post, options)
111
+ add_shipping_address(post, options)
110
112
  end
111
113
 
112
114
  def add_customer_data(post, payment, options)
@@ -119,21 +121,47 @@ module ActiveMerchant #:nodoc:
119
121
 
120
122
  def add_address(post, options)
121
123
  if address = (options[:billing_address] || options[:address])
122
- street_number = address[:address1].split(" ").first
123
- street_name = address[:address1].split(" ")[1..-1].join(" ")
124
124
 
125
- post[:additional_info] = {
125
+ post[:additional_info].merge!({
126
126
  payer: {
127
127
  address: {
128
128
  zip_code: address[:zip],
129
- street_number: street_number,
130
- street_name: street_name,
129
+ street_number: split_street_address(address[:address1]).first,
130
+ street_name: split_street_address(address[:address1]).last
131
131
  }
132
132
  }
133
- }
133
+ })
134
134
  end
135
135
  end
136
136
 
137
+ def add_shipping_address(post, options)
138
+ if address = options[:shipping_address]
139
+
140
+ post[:additional_info].merge!({
141
+ shipments: {
142
+ receiver_address: {
143
+ zip_code: address[:zip],
144
+ street_number: split_street_address(address[:address1]).first,
145
+ street_name: split_street_address(address[:address1]).last,
146
+ apartment: address[:address2]
147
+ }
148
+ }
149
+ })
150
+ end
151
+ end
152
+
153
+ def split_street_address(address1)
154
+ street_number = address1.split(" ").first
155
+
156
+ if street_name = address1.split(" ")[1..-1]
157
+ street_name = street_name.join(" ")
158
+ else
159
+ nil
160
+ end
161
+
162
+ [street_number, street_name]
163
+ end
164
+
137
165
  def add_invoice(post, money, options)
138
166
  post[:transaction_amount] = amount(money).to_f
139
167
  post[:description] = options[:description]
@@ -147,7 +175,7 @@ module ActiveMerchant #:nodoc:
147
175
 
148
176
  def add_payment(post, options)
149
177
  post[:token] = options[:card_token]
150
- post[:payment_method_id] = options[:card_brand]
178
+ post[:payment_method_id] = options[:card_brand] == "american_express" ? "amex" : options[:card_brand]
151
179
  end
152
180
 
153
181
  def parse(body)
@@ -30,11 +30,11 @@ module ActiveMerchant #:nodoc:
30
30
  class OrbitalGateway < Gateway
31
31
  include Empty
32
32
 
33
- API_VERSION = "5.6"
33
+ API_VERSION = "7.1"
34
34
 
35
35
  POST_HEADERS = {
36
36
  "MIME-Version" => "1.1",
37
- "Content-Type" => "application/PTI56",
37
+ "Content-Type" => "application/PTI#{API_VERSION.gsub(/\./, '')}",
38
38
  "Content-transfer-encoding" => "text",
39
39
  "Request-number" => '1',
40
40
  "Document-type" => "Request",
@@ -191,7 +191,7 @@ module ActiveMerchant #:nodoc:
191
191
 
192
192
  # A – Authorization request
193
193
  def authorize(money, creditcard, options = {})
194
- order = build_new_order_xml(AUTH_ONLY, money, options) do |xml|
194
+ order = build_new_order_xml(AUTH_ONLY, money, creditcard, options) do |xml|
195
195
  add_creditcard(xml, creditcard, options[:currency])
196
196
  add_address(xml, creditcard, options)
197
197
  if @options[:customer_profiles]
@@ -211,7 +211,7 @@ module ActiveMerchant #:nodoc:
211
211
 
212
212
  # AC – Authorization and Capture
213
213
  def purchase(money, creditcard, options = {})
214
- order = build_new_order_xml(AUTH_AND_CAPTURE, money, options) do |xml|
214
+ order = build_new_order_xml(AUTH_AND_CAPTURE, money, creditcard, options) do |xml|
215
215
  add_creditcard(xml, creditcard, options[:currency])
216
216
  add_address(xml, creditcard, options)
217
217
  if @options[:customer_profiles]
@@ -229,7 +229,7 @@ module ActiveMerchant #:nodoc:
229
229
 
230
230
  # R – Refund request
231
231
  def refund(money, authorization, options = {})
232
- order = build_new_order_xml(REFUND, money, options.merge(:authorization => authorization)) do |xml|
232
+ order = build_new_order_xml(REFUND, money, nil, options.merge(:authorization => authorization)) do |xml|
233
233
  add_refund(xml, options[:currency])
234
234
  xml.tag! :CustomerRefNum, options[:customer_ref_num] if @options[:customer_profiles] && options[:profile_txn]
235
235
  end
@@ -463,6 +463,16 @@ module ActiveMerchant #:nodoc:
463
463
  end
464
464
  end
465
465
 
466
+ def add_cdpt_eci_and_xid(xml, creditcard)
467
+ xml.tag! :AuthenticationECIInd, creditcard.eci
468
+ xml.tag! :XID, creditcard.transaction_id if creditcard.transaction_id
469
+ end
470
+
471
+ def add_cdpt_payment_cryptogram(xml, creditcard)
472
+ xml.tag! :DPANInd, 'Y'
473
+ xml.tag! :DigitalTokenCryptogram, creditcard.payment_cryptogram
474
+ end
475
+
466
476
  def add_refund(xml, currency=nil)
467
477
  xml.tag! :AccountNum, nil
468
478
 
@@ -566,7 +576,7 @@ module ActiveMerchant #:nodoc:
566
576
  @options[:ip_authentication] == true
567
577
  end
568
578
 
569
- def build_new_order_xml(action, money, parameters = {})
579
+ def build_new_order_xml(action, money, creditcard, parameters = {})
570
580
  requires!(parameters, :order_id)
571
581
  xml = xml_envelope
572
582
  xml.tag! :Request do
@@ -589,6 +599,10 @@ module ActiveMerchant #:nodoc:
589
599
 
590
600
  yield xml if block_given?
591
601
 
602
+ if creditcard.is_a?(NetworkTokenizationCreditCard)
603
+ add_cdpt_eci_and_xid(xml, creditcard)
604
+ end
605
+
592
606
  xml.tag! :OrderID, format_order_id(parameters[:order_id])
593
607
  xml.tag! :Amount, amount(money)
594
608
  xml.tag! :Comments, parameters[:comments] if parameters[:comments]
@@ -598,6 +612,10 @@ module ActiveMerchant #:nodoc:
598
612
 
599
613
  # CustomerAni, AVSPhoneType and AVSDestPhoneType could be added here.
600
614
 
615
+ if creditcard.is_a?(NetworkTokenizationCreditCard)
616
+ add_cdpt_payment_cryptogram(xml, creditcard)
617
+ end
618
+
601
619
  if parameters[:soft_descriptors].is_a?(OrbitalSoftDescriptors)
602
620
  add_soft_descriptors(xml, parameters[:soft_descriptors])
603
621
  elsif parameters[:soft_descriptors].is_a?(Hash)
@@ -49,7 +49,7 @@ module ActiveMerchant #:nodoc:
49
49
  post = {}
50
50
 
51
51
  add_credentials(post, 'SUBMIT_TRANSACTION')
52
- add_transaction_type(post, 'CAPTURE')
52
+ add_transaction_elements(post, 'CAPTURE', options)
53
53
  add_reference(post, authorization)
54
54
 
55
55
  commit('capture', post)
@@ -59,7 +59,7 @@ module ActiveMerchant #:nodoc:
59
59
  post = {}
60
60
 
61
61
  add_credentials(post, 'SUBMIT_TRANSACTION')
62
- add_transaction_type(post, 'VOID')
62
+ add_transaction_elements(post, 'VOID', options)
63
63
  add_reference(post, authorization)
64
64
 
65
65
  commit('void', post)
@@ -69,7 +69,7 @@ module ActiveMerchant #:nodoc:
69
69
  post = {}
70
70
 
71
71
  add_credentials(post, 'SUBMIT_TRANSACTION')
72
- add_transaction_type(post, 'REFUND')
72
+ add_transaction_elements(post, 'REFUND', options)
73
73
  add_reference(post, authorization)
74
74
 
75
75
  commit('refund', post)
@@ -116,7 +116,7 @@ module ActiveMerchant #:nodoc:
116
116
 
117
117
  def auth_or_sale(post, transaction_type, amount, payment_method, options)
118
118
  add_credentials(post, 'SUBMIT_TRANSACTION')
119
- add_transaction_type(post, transaction_type)
119
+ add_transaction_elements(post, transaction_type, options)
120
120
  add_order(post, options)
121
121
  add_buyer(post, options)
122
122
  add_invoice(post, amount, options)
@@ -136,9 +136,13 @@ module ActiveMerchant #:nodoc:
136
136
  post[:merchant] = merchant
137
137
  end
138
138
 
139
- def add_transaction_type(post, type)
139
+ def add_transaction_elements(post, type, options)
140
140
  transaction = {}
141
141
  transaction[:type] = type
142
+ transaction[:ipAddress] = options[:ip] if options[:ip]
143
+ transaction[:userAgent] = options[:user_agent] if options[:user_agent]
144
+ transaction[:cookie] = options[:cookie] if options[:cookie]
145
+ transaction[:deviceSessionId] = options[:device_session_id] if options[:device_session_id]
142
146
  post[:transaction] = transaction
143
147
  end
144
148
 
@@ -155,7 +159,10 @@ module ActiveMerchant #:nodoc:
155
159
  if address = options[:shipping_address]
156
160
  buyer = {}
157
161
  buyer[:fullName] = address[:name]
158
- buyer[:dniNumber] = options[:dni_number]
162
+ buyer[:dniNumber] = options[:dni_number] if options[:dni_number]
163
+ buyer[:dniType] = options[:dni_type] if options[:dni_type]
164
+ buyer[:emailAddress] = options[:email] if options[:email]
165
+ buyer[:contactPhone] = address[:phone]
159
166
  shipping_address = {}
160
167
  shipping_address[:street1] = address[:address1]
161
168
  shipping_address[:street2] = address[:address2]
@@ -174,8 +181,18 @@ module ActiveMerchant #:nodoc:
174
181
  tx_value[:value] = amount(money)
175
182
  tx_value[:currency] = options[:currency] || currency(money)
176
183
 
184
+ tx_tax = {}
185
+ tx_tax[:value] = options[:tax] || '0'
186
+ tx_tax[:currency] = options[:currency] || currency(money)
187
+
188
+ tx_tax_return_base = {}
189
+ tx_tax_return_base[:value] = options[:tax_return_base] || '0'
190
+ tx_tax_return_base[:currency] = options[:currency] || currency(money)
191
+
177
192
  additional_values = {}
178
193
  additional_values[:TX_VALUE] = tx_value
194
+ additional_values[:TX_TAX] = tx_tax
195
+ additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base
179
196
 
180
197
  post[:transaction][:order][:additionalValues] = additional_values
181
198
  end
@@ -235,7 +252,10 @@ module ActiveMerchant #:nodoc:
235
252
  post[:transaction][:paymentCountry] = address[:country]
236
253
  payer[:fullName] = address[:name]
237
254
  payer[:contactPhone] = address[:phone]
238
- payer[:dniNumber] = options[:dni_number]
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]
239
259
  billing_address = {}
240
260
  billing_address[:street1] = address[:address1]
241
261
  billing_address[:street2] = address[:address2]
@@ -303,7 +303,9 @@ module ActiveMerchant #:nodoc:
303
303
  add_creditcard(post, payment, options)
304
304
  end
305
305
 
306
- unless emv_payment?(payment)
306
+ if emv_payment?(payment)
307
+ add_statement_address(post, options)
308
+ else
307
309
  add_amount(post, money, options, true)
308
310
  add_customer_data(post, options)
309
311
  post[:description] = options[:description]
@@ -365,6 +367,18 @@ module ActiveMerchant #:nodoc:
365
367
  end
366
368
  end
367
369
 
370
+ def add_statement_address(post, options)
371
+ return unless statement_address = options[:statement_address]
372
+ return unless [:address1, :city, :zip, :state].all? { |key| statement_address[key].present? }
373
+
374
+ post[:statement_address] = {}
375
+ post[:statement_address][:line1] = statement_address[:address1]
376
+ post[:statement_address][:line2] = statement_address[:address2] if statement_address[:address2].present?
377
+ post[:statement_address][:city] = statement_address[:city]
378
+ post[:statement_address][:postal_code] = statement_address[:zip]
379
+ post[:statement_address][:state] = statement_address[:state]
380
+ end
381
+
368
382
  def add_creditcard(post, creditcard, options)
369
383
  card = {}
370
384
  if emv_payment?(creditcard)
@@ -1,4 +1,5 @@
1
1
  module ActiveMerchant #:nodoc:
2
+
2
3
  module Billing #:nodoc:
3
4
  class TransFirstGateway < Gateway
4
5
  self.test_url = 'https://ws.cert.transfirst.com'
@@ -16,7 +17,7 @@ module ActiveMerchant #:nodoc:
16
17
  ACTIONS = {
17
18
  purchase: "CCSale",
18
19
  purchase_echeck: "ACHDebit",
19
- refund: "CreditCardAutoRefundorVoid",
20
+ refund: "CreditCardCredit",
20
21
  refund_echeck: "ACHVoidTransaction",
21
22
  void: "CreditCardAutoRefundorVoid",
22
23
  }
@@ -52,6 +53,7 @@ module ActiveMerchant #:nodoc:
52
53
  transaction_id, payment_type = split_authorization(authorization)
53
54
  add_amount(post, money)
54
55
  add_pair(post, :TransID, transaction_id)
56
+ add_pair(post, :RefID, options[:order_id], required: true)
55
57
 
56
58
  commit((payment_type == "check" ? :refund_echeck : :refund), post)
57
59
  end
@@ -169,7 +171,6 @@ module ActiveMerchant #:nodoc:
169
171
 
170
172
  def commit(action, params)
171
173
  response = parse(ssl_post(url(action), post_data(action, params)))
172
-
173
174
  Response.new(
174
175
  success_from(response),
175
176
  message_from(response),
@@ -537,15 +537,17 @@ module ActiveMerchant #:nodoc:
537
537
  doc["v1"].title options[:title] if options[:title]
538
538
 
539
539
  if (billing_address = options[:billing_address])
540
- doc["v1"].phone do
541
- doc["v1"].type (options[:phone_number_type] || "4")
542
- doc["v1"].nr billing_address[:phone].gsub(/\D/, '') if billing_address[:phone]
540
+ if billing_address[:phone]
541
+ doc["v1"].phone do
542
+ doc["v1"].type (options[:phone_number_type] || "4")
543
+ doc["v1"].nr billing_address[:phone].gsub(/\D/, '')
544
+ end
543
545
  end
544
- doc["v1"].addrLn1 billing_address[:address1]
545
- doc["v1"].addrLn2 billing_address[:address2]
546
- doc["v1"].city billing_address[:city]
547
- doc["v1"].state billing_address[:state]
548
- doc["v1"].zipCode billing_address[:zip]
546
+ doc["v1"].addrLn1 billing_address[:address1] if billing_address[:address1]
547
+ doc["v1"].addrLn2 billing_address[:address2] if billing_address[:address2]
548
+ doc["v1"].city billing_address[:city] if billing_address[:city]
549
+ doc["v1"].state billing_address[:state] if billing_address[:state]
550
+ doc["v1"].zipCode billing_address[:zip] if billing_address[:zip]
549
551
  doc["v1"].ctry "US"
550
552
  end
551
553
 
@@ -556,11 +558,11 @@ module ActiveMerchant #:nodoc:
556
558
  if (shipping_address = options[:shipping_address])
557
559
  doc["v1"].ship do
558
560
  doc["v1"].fullName fullname
559
- doc["v1"].addrLn1 shipping_address[:address1]
561
+ doc["v1"].addrLn1 shipping_address[:address1] if shipping_address[:address1]
560
562
  doc["v1"].addrLn2 shipping_address[:address2] if shipping_address[:address2]
561
- doc["v1"].city shipping_address[:city]
562
- doc["v1"].state shipping_address[:state]
563
- doc["v1"].zipCode shipping_address[:zip]
563
+ doc["v1"].city shipping_address[:city] if shipping_address[:city]
564
+ doc["v1"].state shipping_address[:state] if shipping_address[:state]
565
+ doc["v1"].zipCode shipping_address[:zip] if shipping_address[:zip]
564
566
  doc["v1"].phone shipping_address[:phone].gsub(/\D/, '') if shipping_address[:phone]
565
567
  doc["v1"].email shipping_address[:email] if shipping_address[:email]
566
568
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveMerchant
2
- VERSION = "1.70.0"
2
+ VERSION = "1.71.0"
3
3
  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.70.0
4
+ version: 1.71.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-08-07 00:00:00.000000000 Z
11
+ date: 2017-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport