braintree 4.17.0 → 4.18.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/lib/braintree/error_codes.rb +4 -0
- data/lib/braintree/transaction/package_details.rb +16 -0
- data/lib/braintree/transaction.rb +10 -0
- data/lib/braintree/transaction_gateway.rb +21 -3
- data/lib/braintree/transaction_line_item.rb +11 -8
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree.rb +1 -0
- data/spec/integration/braintree/credit_card_spec.rb +4 -5
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
- data/spec/integration/braintree/customer_spec.rb +4 -4
- data/spec/integration/braintree/package_tracking_spec.rb +111 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +2 -2
- data/spec/integration/braintree/payment_method_spec.rb +2 -2
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -0
- data/spec/integration/braintree/transaction_spec.rb +111 -27
- data/spec/unit/braintree/package_tracking_spec.rb +74 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +3 -3
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8d5039746bfcbc33e3899cb43cf5a014084278543b5c83ea0b09146a0c0b63b
|
4
|
+
data.tar.gz: 688a569cbff984a1d6a0571095a7f990efda7ce717ee9393c93263f8b9007f80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df005acb10a67bdcf42ab131f49b93f595ad9431004922502b255c54d4222960e54a344a018abd0175c3b340d8474215a1f49b0a210b590fbe78fe020bf7daf1
|
7
|
+
data.tar.gz: 783676045da0d1240f5b9cd808149f04fd9a7005c99015ff5ec07ff0a0ffcf4093e1e0ab896334f2e7e0f953829a62b8532130a3057bef5c344d506c58064d67
|
@@ -561,6 +561,10 @@ module Braintree
|
|
561
561
|
UnitTaxAmountCannotBeNegative = "95826"
|
562
562
|
UnitTaxAmountFormatIsInvalid = "95824"
|
563
563
|
UnitTaxAmountIsTooLarge = "95825"
|
564
|
+
UPCCodeIsMissing = "95830"
|
565
|
+
UPCCodeIsTooLong = "95831"
|
566
|
+
UPCTypeIsMissing = "95832"
|
567
|
+
UPCTypeIsInvalid = "95833"
|
564
568
|
end
|
565
569
|
|
566
570
|
module Merchant
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Braintree
|
2
|
+
class Transaction
|
3
|
+
class PackageDetails
|
4
|
+
include BaseModule
|
5
|
+
|
6
|
+
attr_reader :carrier
|
7
|
+
attr_reader :id
|
8
|
+
attr_reader :paypal_tracking_id
|
9
|
+
attr_reader :tracking_number
|
10
|
+
|
11
|
+
def initialize(attributes)
|
12
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -138,6 +138,7 @@ module Braintree
|
|
138
138
|
attr_reader :network_token_details
|
139
139
|
attr_reader :network_transaction_id
|
140
140
|
attr_reader :order_id
|
141
|
+
attr_reader :packages
|
141
142
|
attr_reader :partial_settlement_transaction_ids
|
142
143
|
attr_reader :payment_instrument_type
|
143
144
|
attr_reader :payment_receipt
|
@@ -284,6 +285,14 @@ module Braintree
|
|
284
285
|
return_object_or_raise(:transaction) { update_details(*args) }
|
285
286
|
end
|
286
287
|
|
288
|
+
def self.package_tracking(*args)
|
289
|
+
Configuration.gateway.transaction.package_tracking(*args)
|
290
|
+
end
|
291
|
+
|
292
|
+
def self.package_tracking!(*args)
|
293
|
+
Configuration.gateway.transaction.package_tracking!(*args)
|
294
|
+
end
|
295
|
+
|
287
296
|
def self.submit_for_partial_settlement(*args)
|
288
297
|
Configuration.gateway.transaction.submit_for_partial_settlement(*args)
|
289
298
|
end
|
@@ -325,6 +334,7 @@ module Braintree
|
|
325
334
|
@sca_exemption_requested = attributes[:sca_exemption_requested]
|
326
335
|
@sepa_direct_debit_account_details = SepaDirectDebitAccountDetails.new(@sepa_debit_account_detail)
|
327
336
|
@service_fee_amount = Util.to_big_decimal(service_fee_amount)
|
337
|
+
@packages = attributes[:shipments] ? attributes[:shipments].map { |pd| PackageDetails.new(pd) } : []
|
328
338
|
@shipping_details = AddressDetails.new(@shipping)
|
329
339
|
@status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : []
|
330
340
|
@subscription_details = SubscriptionDetails.new(@subscription)
|
@@ -112,6 +112,16 @@ module Braintree
|
|
112
112
|
return_object_or_raise(:transaction) { sale(*args) }
|
113
113
|
end
|
114
114
|
|
115
|
+
def package_tracking(transaction_id, package_tracking_request)
|
116
|
+
raise ArgumentError, "transaction_id is invalid" unless transaction_id =~ /\A[0-9a-z]+\z/
|
117
|
+
Util.verify_keys(TransactionGateway._package_tracking_request_signature, package_tracking_request)
|
118
|
+
_do_create "/transactions/#{transaction_id}/shipments", :shipment => package_tracking_request
|
119
|
+
end
|
120
|
+
|
121
|
+
def package_tracking!(*args)
|
122
|
+
return_object_or_raise(:transaction) { package_tracking(*args) }
|
123
|
+
end
|
124
|
+
|
115
125
|
def search(&block)
|
116
126
|
search = TransactionSearch.new
|
117
127
|
block.call(search) if block
|
@@ -187,6 +197,14 @@ module Braintree
|
|
187
197
|
return_object_or_raise(:transaction) { void(*args) }
|
188
198
|
end
|
189
199
|
|
200
|
+
def self._package_tracking_request_signature
|
201
|
+
[
|
202
|
+
:carrier,
|
203
|
+
{:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
|
204
|
+
:notify_payer, :tracking_number,
|
205
|
+
]
|
206
|
+
end
|
207
|
+
|
190
208
|
def self._clone_signature
|
191
209
|
[:amount, :channel, {:options => [:submit_for_settlement]}]
|
192
210
|
end
|
@@ -204,7 +222,7 @@ module Braintree
|
|
204
222
|
:ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,:three_d_secure_token, #Deprecated
|
205
223
|
:transaction_source, :type, :venmo_sdk_payment_method_code, # Deprecated
|
206
224
|
:sca_exemption, :currency_iso_code, :exchange_rate_quote_id,
|
207
|
-
{:line_items => [:
|
225
|
+
{:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
|
208
226
|
{:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
|
209
227
|
{:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}, {:network_tokenization_attributes => [:cryptogram, :ecommerce_indicator, :token_requestor_id]}]},
|
210
228
|
{:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
|
@@ -244,7 +262,7 @@ module Braintree
|
|
244
262
|
{:three_d_secure => [:required]},
|
245
263
|
{:amex_rewards => [:request_id, :points, :currency_amount, :currency_iso_code]},
|
246
264
|
{:venmo => [:profile_id]},
|
247
|
-
{:credit_card => [:account_type]},
|
265
|
+
{:credit_card => [:account_type, :process_debit_as_credit]},
|
248
266
|
]
|
249
267
|
},
|
250
268
|
{:external_vault => [
|
@@ -300,7 +318,7 @@ module Braintree
|
|
300
318
|
:discount_amount,
|
301
319
|
:shipping_amount,
|
302
320
|
:ships_from_postal_code,
|
303
|
-
:line_items => [:commodity_code, :description, :discount_amount, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :
|
321
|
+
:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url],
|
304
322
|
]
|
305
323
|
end
|
306
324
|
|
@@ -1,18 +1,21 @@
|
|
1
1
|
module Braintree
|
2
2
|
class TransactionLineItem
|
3
3
|
include BaseModule
|
4
|
-
attr_reader :
|
5
|
-
attr_reader :name
|
4
|
+
attr_reader :commodity_code
|
6
5
|
attr_reader :description
|
7
|
-
attr_reader :kind
|
8
|
-
attr_reader :unit_amount
|
9
|
-
attr_reader :unit_tax_amount
|
10
|
-
attr_reader :unit_of_measure
|
11
6
|
attr_reader :discount_amount
|
7
|
+
attr_reader :image_url
|
8
|
+
attr_reader :kind
|
9
|
+
attr_reader :name
|
10
|
+
attr_reader :product_code
|
11
|
+
attr_reader :quantity
|
12
12
|
attr_reader :tax_amount
|
13
13
|
attr_reader :total_amount
|
14
|
-
attr_reader :
|
15
|
-
attr_reader :
|
14
|
+
attr_reader :unit_amount
|
15
|
+
attr_reader :unit_of_measure
|
16
|
+
attr_reader :unit_tax_amount
|
17
|
+
attr_reader :upc_code
|
18
|
+
attr_reader :upc_type
|
16
19
|
attr_reader :url
|
17
20
|
|
18
21
|
def initialize(gateway, attributes)
|
data/lib/braintree/version.rb
CHANGED
data/lib/braintree.rb
CHANGED
@@ -156,6 +156,7 @@ require "braintree/transaction/payment_receipt/card_present_data.rb"
|
|
156
156
|
require "braintree/transaction/payment_receipt/merchant_address.rb"
|
157
157
|
require "braintree/transaction/meta_checkout_card_details"
|
158
158
|
require "braintree/transaction/meta_checkout_token_details"
|
159
|
+
require "braintree/transaction/package_details"
|
159
160
|
require "braintree/transaction/paypal_details"
|
160
161
|
require "braintree/transaction/paypal_here_details"
|
161
162
|
require "braintree/transaction/samsung_pay_card_details"
|
@@ -276,7 +276,7 @@ describe Braintree::CreditCard do
|
|
276
276
|
:customer_id => customer.id,
|
277
277
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
278
278
|
:three_d_secure_pass_thru => {
|
279
|
-
:eci_flag => "
|
279
|
+
:eci_flag => "05",
|
280
280
|
:cavv => "some_cavv",
|
281
281
|
:xid => "some_xid",
|
282
282
|
:authentication_response => "Y",
|
@@ -298,7 +298,7 @@ describe Braintree::CreditCard do
|
|
298
298
|
:customer_id => customer.id,
|
299
299
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
300
300
|
:three_d_secure_pass_thru => {
|
301
|
-
:eci_flag => "
|
301
|
+
:eci_flag => "05",
|
302
302
|
:cavv => "some_cavv",
|
303
303
|
:xid => "some_xid",
|
304
304
|
:three_d_secure_version => "1.0.2",
|
@@ -310,7 +310,6 @@ describe Braintree::CreditCard do
|
|
310
310
|
:options => {:verify_card => true},
|
311
311
|
)
|
312
312
|
expect(result.success?).to eq(true)
|
313
|
-
|
314
313
|
end
|
315
314
|
|
316
315
|
it "returns 3DS info on cc verification" do
|
@@ -793,7 +792,7 @@ describe Braintree::CreditCard do
|
|
793
792
|
result = Braintree::CreditCard.update(credit_card.token,
|
794
793
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
795
794
|
:three_d_secure_pass_thru => {
|
796
|
-
:eci_flag => "
|
795
|
+
:eci_flag => "05",
|
797
796
|
:cavv => "some_cavv",
|
798
797
|
:xid => "some_xid",
|
799
798
|
:authentication_response => "Y",
|
@@ -821,7 +820,7 @@ describe Braintree::CreditCard do
|
|
821
820
|
result = Braintree::CreditCard.update(credit_card.token,
|
822
821
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
823
822
|
:three_d_secure_pass_thru => {
|
824
|
-
:eci_flag => "
|
823
|
+
:eci_flag => "05",
|
825
824
|
:cavv => "some_cavv",
|
826
825
|
:three_d_secure_version=> "2.1.0",
|
827
826
|
:xid => "some_xid",
|
@@ -405,7 +405,7 @@ describe Braintree::CreditCardVerification, "search" do
|
|
405
405
|
:amount => "10.00",
|
406
406
|
},
|
407
407
|
:three_d_secure_pass_thru => {
|
408
|
-
:eci_flag => "
|
408
|
+
:eci_flag => "05",
|
409
409
|
:cavv => "some_cavv",
|
410
410
|
:xid => "some_xid",
|
411
411
|
:three_d_secure_version => "1.0.2",
|
@@ -1132,7 +1132,7 @@ describe Braintree::Customer do
|
|
1132
1132
|
:number => 4111111111111111,
|
1133
1133
|
:expiration_date => "05/2060",
|
1134
1134
|
:three_d_secure_pass_thru => {
|
1135
|
-
:eci_flag => "
|
1135
|
+
:eci_flag => "05",
|
1136
1136
|
:cavv => "some_cavv",
|
1137
1137
|
:xid => "some_xid",
|
1138
1138
|
:three_d_secure_version => "1.0.2",
|
@@ -1167,7 +1167,7 @@ describe Braintree::Customer do
|
|
1167
1167
|
:number => 4111111111111111,
|
1168
1168
|
:expiration_date => "05/2060",
|
1169
1169
|
:three_d_secure_pass_thru => {
|
1170
|
-
:eci_flag => "
|
1170
|
+
:eci_flag => "05",
|
1171
1171
|
:cavv => "some_cavv",
|
1172
1172
|
:xid => "some_xid",
|
1173
1173
|
:authentication_response => "Y",
|
@@ -1451,7 +1451,7 @@ describe Braintree::Customer do
|
|
1451
1451
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1452
1452
|
:credit_card => {
|
1453
1453
|
:three_d_secure_pass_thru => {
|
1454
|
-
:eci_flag => "
|
1454
|
+
:eci_flag => "05",
|
1455
1455
|
:cavv => "some_cavv",
|
1456
1456
|
:xid => "some_xid",
|
1457
1457
|
:three_d_secure_version => "xx",
|
@@ -1475,7 +1475,7 @@ describe Braintree::Customer do
|
|
1475
1475
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1476
1476
|
:credit_card => {
|
1477
1477
|
:three_d_secure_pass_thru => {
|
1478
|
-
:eci_flag => "
|
1478
|
+
:eci_flag => "05",
|
1479
1479
|
:cavv => "some_cavv",
|
1480
1480
|
:xid => "some_xid",
|
1481
1481
|
:three_d_secure_version => "2.2.1",
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::Transaction do
|
4
|
+
describe "self.package_tracking" do
|
5
|
+
it "returns validation error message from gateway api" do
|
6
|
+
# Create Transaction
|
7
|
+
result = Braintree::Transaction.sale(
|
8
|
+
:amount => "100",
|
9
|
+
:options => {
|
10
|
+
:submit_for_settlement => true
|
11
|
+
},
|
12
|
+
:paypal_account => {
|
13
|
+
:payer_id => "fake-payer-id",
|
14
|
+
:payment_id => "fake-payment-id",
|
15
|
+
},
|
16
|
+
)
|
17
|
+
|
18
|
+
expect(result.success?).to eq(true)
|
19
|
+
|
20
|
+
# Carrier name is required
|
21
|
+
invalidResult = Braintree::Transaction.package_tracking(result.transaction.id, {tracking_number: "tracking_number_1"})
|
22
|
+
expect(invalidResult.message).to eq("Carrier name is required.")
|
23
|
+
|
24
|
+
# Tracking number is required
|
25
|
+
invalidResult = Braintree::Transaction.package_tracking(result.transaction.id, {carrier: "UPS"})
|
26
|
+
expect(invalidResult.message).to eq("Tracking number is required.")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "successfully calls gateway API and adds package tracking information" do
|
30
|
+
|
31
|
+
# Create Transaction
|
32
|
+
result = Braintree::Transaction.sale(
|
33
|
+
:amount => "100",
|
34
|
+
:options => {
|
35
|
+
:submit_for_settlement => true
|
36
|
+
},
|
37
|
+
:paypal_account => {
|
38
|
+
:payer_id => "fake-payer-id",
|
39
|
+
:payment_id => "fake-payment-id",
|
40
|
+
},
|
41
|
+
)
|
42
|
+
|
43
|
+
expect(result.success?).to eq(true)
|
44
|
+
|
45
|
+
# Create First Package with 2 products
|
46
|
+
firstPackageResult = Braintree::Transaction.package_tracking(
|
47
|
+
result.transaction.id,
|
48
|
+
{
|
49
|
+
carrier: "UPS",
|
50
|
+
notify_payer: true,
|
51
|
+
tracking_number: "tracking_number_1",
|
52
|
+
line_items: [
|
53
|
+
{
|
54
|
+
product_code: "ABC 01",
|
55
|
+
name: "Best Product Ever",
|
56
|
+
quantity: "1",
|
57
|
+
description: "Best Description Ever",
|
58
|
+
upc_code: "51234567890",
|
59
|
+
upc_type: "UPC-A",
|
60
|
+
image_url: "https://example.com/image.png",
|
61
|
+
},
|
62
|
+
{
|
63
|
+
product_code: "ABC 02",
|
64
|
+
name: "Best Product Ever",
|
65
|
+
quantity: "1",
|
66
|
+
description: "Best Description Ever",
|
67
|
+
upc_code: "51234567891",
|
68
|
+
upc_type: "UPC-A",
|
69
|
+
image_url: "https://example.com/image.png",
|
70
|
+
},
|
71
|
+
],
|
72
|
+
},
|
73
|
+
)
|
74
|
+
|
75
|
+
# First package is shipped by the merchant
|
76
|
+
expect(firstPackageResult.success?).to eq(true)
|
77
|
+
expect(firstPackageResult.transaction.packages[0].id).not_to be_nil
|
78
|
+
expect(firstPackageResult.transaction.packages[0].carrier).to eq("UPS")
|
79
|
+
expect(firstPackageResult.transaction.packages[0].tracking_number).to eq("tracking_number_1")
|
80
|
+
|
81
|
+
|
82
|
+
# Create second package with 1 product
|
83
|
+
secondPackageResult = Braintree::Transaction.package_tracking(
|
84
|
+
result.transaction.id,
|
85
|
+
{
|
86
|
+
carrier: "FEDEX",
|
87
|
+
notify_payer: true,
|
88
|
+
tracking_number: "tracking_number_2",
|
89
|
+
line_items: [
|
90
|
+
{
|
91
|
+
product_code: "ABC 03",
|
92
|
+
name: "Best Product Ever",
|
93
|
+
quantity: "1",
|
94
|
+
description: "Best Description Ever",
|
95
|
+
},
|
96
|
+
]
|
97
|
+
},
|
98
|
+
)
|
99
|
+
|
100
|
+
# Second package is shipped by the merchant
|
101
|
+
expect(secondPackageResult.success?).to eq(true)
|
102
|
+
expect(secondPackageResult.transaction.packages[1].id).not_to be_nil
|
103
|
+
expect(secondPackageResult.transaction.packages[1].carrier).to eq("FEDEX")
|
104
|
+
expect(secondPackageResult.transaction.packages[1].tracking_number).to eq("tracking_number_2")
|
105
|
+
|
106
|
+
# Find transaction gives both packages
|
107
|
+
findTransaction = Braintree::Transaction.find(result.transaction.id)
|
108
|
+
expect(findTransaction.packages.length).to eq(2)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -97,7 +97,7 @@ describe Braintree::PaymentMethodNonce do
|
|
97
97
|
nonce.details.bin.should == "401288"
|
98
98
|
nonce.details.last_two.should == "81"
|
99
99
|
nonce.details.card_type.should == "Visa"
|
100
|
-
nonce.details.expiration_year.should ==
|
100
|
+
nonce.details.expiration_year.should == Date.today().next_year().year.to_s
|
101
101
|
nonce.details.expiration_month.should == "12"
|
102
102
|
end
|
103
103
|
|
@@ -107,7 +107,7 @@ describe Braintree::PaymentMethodNonce do
|
|
107
107
|
nonce.details.bin.should == "401288"
|
108
108
|
nonce.details.last_two.should == "81"
|
109
109
|
nonce.details.card_type.should == "Visa"
|
110
|
-
nonce.details.expiration_year.should ==
|
110
|
+
nonce.details.expiration_year.should == Date.today().next_year().year.to_s
|
111
111
|
nonce.details.expiration_month.should == "12"
|
112
112
|
end
|
113
113
|
|
@@ -342,7 +342,7 @@ describe Braintree::PaymentMethod do
|
|
342
342
|
:customer_id => customer.id,
|
343
343
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
344
344
|
:three_d_secure_pass_thru => {
|
345
|
-
:eci_flag => "
|
345
|
+
:eci_flag => "05",
|
346
346
|
:cavv => "some_cavv",
|
347
347
|
:xid => "some_xid",
|
348
348
|
:three_d_secure_version => "xx",
|
@@ -365,7 +365,7 @@ describe Braintree::PaymentMethod do
|
|
365
365
|
:customer_id => customer.id,
|
366
366
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
367
367
|
:three_d_secure_pass_thru => {
|
368
|
-
:eci_flag => "
|
368
|
+
:eci_flag => "05",
|
369
369
|
:cavv => "some_cavv",
|
370
370
|
:xid => "some_xid",
|
371
371
|
:three_d_secure_version => "1.0.2",
|
@@ -18,6 +18,9 @@ describe Braintree::TransactionLineItem do
|
|
18
18
|
:kind => "debit",
|
19
19
|
:unit_amount => "45.1232",
|
20
20
|
:total_amount => "45.15",
|
21
|
+
:upc_code => "11223344556677889",
|
22
|
+
:upc_type => "UPC-A",
|
23
|
+
:image_url => "https://google.com/image.png",
|
21
24
|
},
|
22
25
|
],
|
23
26
|
)
|
@@ -32,6 +35,9 @@ describe Braintree::TransactionLineItem do
|
|
32
35
|
expect(line_item.kind).to eq("debit")
|
33
36
|
expect(line_item.unit_amount).to eq(BigDecimal("45.1232"))
|
34
37
|
expect(line_item.total_amount).to eq(BigDecimal("45.15"))
|
38
|
+
expect(line_item.upc_type).to eq("UPC-A")
|
39
|
+
expect(line_item.upc_code).to eq("11223344556677889")
|
40
|
+
expect(line_item.image_url).to eq("https://google.com/image.png")
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
@@ -2132,8 +2132,9 @@ describe Braintree::Transaction do
|
|
2132
2132
|
meta_checkout_card_details.cardholder_name.should == "Meta Checkout Card Cardholder"
|
2133
2133
|
meta_checkout_card_details.container_id.should == "container123"
|
2134
2134
|
meta_checkout_card_details.customer_location.should == "US"
|
2135
|
-
|
2136
|
-
meta_checkout_card_details.
|
2135
|
+
next_year = Date.today().next_year().year.to_s
|
2136
|
+
meta_checkout_card_details.expiration_date.should == "12/".concat(next_year)
|
2137
|
+
meta_checkout_card_details.expiration_year.should == next_year
|
2137
2138
|
meta_checkout_card_details.expiration_month.should == "12"
|
2138
2139
|
meta_checkout_card_details.image_url.should == "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=development"
|
2139
2140
|
meta_checkout_card_details.is_network_tokenized.should == false
|
@@ -2161,8 +2162,9 @@ describe Braintree::Transaction do
|
|
2161
2162
|
meta_checkout_token_details.cryptogram.should == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
|
2162
2163
|
meta_checkout_token_details.customer_location.should == "US"
|
2163
2164
|
meta_checkout_token_details.ecommerce_indicator.should == "07"
|
2164
|
-
|
2165
|
-
meta_checkout_token_details.
|
2165
|
+
next_year = Date.today().next_year().year.to_s
|
2166
|
+
meta_checkout_token_details.expiration_date.should == "12/".concat(next_year)
|
2167
|
+
meta_checkout_token_details.expiration_year.should == next_year
|
2166
2168
|
meta_checkout_token_details.expiration_month.should == "12"
|
2167
2169
|
meta_checkout_token_details.image_url.should == "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=development"
|
2168
2170
|
meta_checkout_token_details.is_network_tokenized.should == true
|
@@ -2748,7 +2750,7 @@ describe Braintree::Transaction do
|
|
2748
2750
|
},
|
2749
2751
|
:three_d_secure_authentication_id => three_d_secure_authentication_id,
|
2750
2752
|
:three_d_secure_pass_thru => {
|
2751
|
-
:eci_flag => "
|
2753
|
+
:eci_flag => "05",
|
2752
2754
|
:cavv => "some_cavv",
|
2753
2755
|
:xid => "some_xid",
|
2754
2756
|
:three_d_secure_version => "1.0.2",
|
@@ -2835,7 +2837,7 @@ describe Braintree::Transaction do
|
|
2835
2837
|
:expiration_date => "12/12",
|
2836
2838
|
},
|
2837
2839
|
:three_d_secure_pass_thru => {
|
2838
|
-
:eci_flag => "
|
2840
|
+
:eci_flag => "05",
|
2839
2841
|
:cavv => "some_cavv",
|
2840
2842
|
:xid => "some_xid",
|
2841
2843
|
:three_d_secure_version => "1.0.2",
|
@@ -2860,7 +2862,7 @@ describe Braintree::Transaction do
|
|
2860
2862
|
:expiration_date => "12/12",
|
2861
2863
|
},
|
2862
2864
|
:three_d_secure_pass_thru => {
|
2863
|
-
:eci_flag => "
|
2865
|
+
:eci_flag => "05",
|
2864
2866
|
:cavv => "some_cavv",
|
2865
2867
|
:xid => "some_xid",
|
2866
2868
|
:three_d_secure_version => "1.0.2",
|
@@ -2947,7 +2949,7 @@ describe Braintree::Transaction do
|
|
2947
2949
|
:expiration_date => "12/12",
|
2948
2950
|
},
|
2949
2951
|
:three_d_secure_pass_thru => {
|
2950
|
-
:eci_flag => "
|
2952
|
+
:eci_flag => "05",
|
2951
2953
|
:cavv => "some_cavv",
|
2952
2954
|
:xid => "some_xid",
|
2953
2955
|
:three_d_secure_version => "invalid",
|
@@ -2971,7 +2973,7 @@ describe Braintree::Transaction do
|
|
2971
2973
|
:expiration_date => "12/12",
|
2972
2974
|
},
|
2973
2975
|
:three_d_secure_pass_thru => {
|
2974
|
-
:eci_flag => "
|
2976
|
+
:eci_flag => "05",
|
2975
2977
|
:cavv => "some_cavv",
|
2976
2978
|
:xid => "some_xid",
|
2977
2979
|
:three_d_secure_version => "1.0.2",
|
@@ -2995,7 +2997,7 @@ describe Braintree::Transaction do
|
|
2995
2997
|
:expiration_date => "12/12",
|
2996
2998
|
},
|
2997
2999
|
:three_d_secure_pass_thru => {
|
2998
|
-
:eci_flag => "
|
3000
|
+
:eci_flag => "05",
|
2999
3001
|
:cavv => "some_cavv",
|
3000
3002
|
:xid => "some_xid",
|
3001
3003
|
:three_d_secure_version => "1.0.2",
|
@@ -3019,7 +3021,7 @@ describe Braintree::Transaction do
|
|
3019
3021
|
:expiration_date => "12/12",
|
3020
3022
|
},
|
3021
3023
|
:three_d_secure_pass_thru => {
|
3022
|
-
:eci_flag => "
|
3024
|
+
:eci_flag => "05",
|
3023
3025
|
:cavv => "some_cavv",
|
3024
3026
|
:xid => "some_xid",
|
3025
3027
|
:three_d_secure_version => "1.0.2",
|
@@ -4605,6 +4607,84 @@ describe Braintree::Transaction do
|
|
4605
4607
|
expect(result.success?).to eq(false)
|
4606
4608
|
expect(result.errors.for(:transaction).on(:line_items)[0].code).to eq(Braintree::ErrorCodes::Transaction::TooManyLineItems)
|
4607
4609
|
end
|
4610
|
+
|
4611
|
+
context "UPC code and type" do
|
4612
|
+
let(:line_item) do
|
4613
|
+
{
|
4614
|
+
:quantity => "1",
|
4615
|
+
:name => "Name #1",
|
4616
|
+
:description => "Description #1",
|
4617
|
+
:kind => "debit",
|
4618
|
+
:unit_amount => "45.12",
|
4619
|
+
:unit_tax_amount => "1.23",
|
4620
|
+
:unit_of_measure => "gallon",
|
4621
|
+
:discount_amount => "1.02",
|
4622
|
+
:tax_amount => "4.50",
|
4623
|
+
:total_amount => "45.15",
|
4624
|
+
:product_code => "23434",
|
4625
|
+
:commodity_code => "9SAASSD8724",
|
4626
|
+
:url => "https://example.com/products/23434",
|
4627
|
+
:upc_code => "042100005264",
|
4628
|
+
:upc_type => "UPC-A",
|
4629
|
+
:image_url => "https://google.com/image.png",
|
4630
|
+
}
|
4631
|
+
end
|
4632
|
+
|
4633
|
+
it "accepts valid values" do
|
4634
|
+
result = Braintree::Transaction.create(
|
4635
|
+
:type => "sale",
|
4636
|
+
:amount => "45.15",
|
4637
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
4638
|
+
:line_items => [line_item],
|
4639
|
+
)
|
4640
|
+
expect(result.success?).to eq(true)
|
4641
|
+
expect(result.transaction.line_items.length).to eq(1)
|
4642
|
+
line_item = result.transaction.line_items[0]
|
4643
|
+
expect(line_item.upc_code).to eq("042100005264")
|
4644
|
+
expect(line_item.upc_type).to eq("UPC-A")
|
4645
|
+
end
|
4646
|
+
|
4647
|
+
it "returns validation errors for invalid UPC code and type too long" do
|
4648
|
+
line_item[:upc_code] = "THISCODELONGERTHAN17CHARS"
|
4649
|
+
line_item[:upc_type] = "USB-C"
|
4650
|
+
result = Braintree::Transaction.create(
|
4651
|
+
:type => "sale",
|
4652
|
+
:amount => "45.15",
|
4653
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
4654
|
+
:line_items => [line_item],
|
4655
|
+
)
|
4656
|
+
|
4657
|
+
expect(result.success?).to eq(false)
|
4658
|
+
expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_code)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCCodeIsTooLong)
|
4659
|
+
expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_type)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCTypeIsInvalid)
|
4660
|
+
end
|
4661
|
+
|
4662
|
+
it "returns UPC code missing error when code is not present" do
|
4663
|
+
line_item.delete(:upc_code)
|
4664
|
+
result = Braintree::Transaction.create(
|
4665
|
+
:type => "sale",
|
4666
|
+
:amount => "45.15",
|
4667
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
4668
|
+
:line_items => [line_item],
|
4669
|
+
)
|
4670
|
+
|
4671
|
+
expect(result.success?).to eq(false)
|
4672
|
+
expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_code)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCCodeIsMissing)
|
4673
|
+
end
|
4674
|
+
|
4675
|
+
it "returns UPC type missing error when type is not present" do
|
4676
|
+
line_item.delete(:upc_type)
|
4677
|
+
result = Braintree::Transaction.create(
|
4678
|
+
:type => "sale",
|
4679
|
+
:amount => "45.15",
|
4680
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
4681
|
+
:line_items => [line_item],
|
4682
|
+
)
|
4683
|
+
|
4684
|
+
expect(result.success?).to eq(false)
|
4685
|
+
expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_type)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCTypeIsMissing)
|
4686
|
+
end
|
4687
|
+
end
|
4608
4688
|
end
|
4609
4689
|
|
4610
4690
|
context "level 3 summary data" do
|
@@ -5820,7 +5900,7 @@ describe Braintree::Transaction do
|
|
5820
5900
|
end
|
5821
5901
|
|
5822
5902
|
context "Pinless debit transaction" do
|
5823
|
-
|
5903
|
+
it "succesfully submits for settlement" do
|
5824
5904
|
result = Braintree::Transaction.sale(
|
5825
5905
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5826
5906
|
:merchant_account_id => SpecHelper::PinlessDebitMerchantAccountId,
|
@@ -5831,10 +5911,28 @@ describe Braintree::Transaction do
|
|
5831
5911
|
},
|
5832
5912
|
)
|
5833
5913
|
expect(result.success?).to be_truthy
|
5834
|
-
expect(result.transaction.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
|
5835
5914
|
expect(result.transaction.debit_network).not_to be_nil
|
5836
5915
|
end
|
5837
5916
|
end
|
5917
|
+
|
5918
|
+
context "Process debit as credit" do
|
5919
|
+
it "succesfully completed pinless eligible transaction in signature" do
|
5920
|
+
result = Braintree::Transaction.sale(
|
5921
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5922
|
+
:merchant_account_id => SpecHelper::PinlessDebitMerchantAccountId,
|
5923
|
+
:currency_iso_code => "USD",
|
5924
|
+
:payment_method_nonce => Braintree::Test::Nonce::TransactablePinlessDebitVisa,
|
5925
|
+
:options => {
|
5926
|
+
:submit_for_settlement => true,
|
5927
|
+
:credit_card => {
|
5928
|
+
:process_debit_as_credit => true
|
5929
|
+
}
|
5930
|
+
},
|
5931
|
+
)
|
5932
|
+
expect(result.success?).to be_truthy
|
5933
|
+
expect(result.transaction.debit_network).to be_nil
|
5934
|
+
end
|
5935
|
+
end
|
5838
5936
|
end
|
5839
5937
|
|
5840
5938
|
describe "self.sale!" do
|
@@ -7739,20 +7837,6 @@ describe Braintree::Transaction do
|
|
7739
7837
|
expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::NoNetAmountToPerformAuthAdjustment)
|
7740
7838
|
end
|
7741
7839
|
|
7742
|
-
it "returns failure, when transaction status is not authorized" do
|
7743
|
-
additional_params = {:options => {:submit_for_settlement => true}}
|
7744
|
-
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
|
7745
|
-
expect(initial_transaction.success?).to eq(true)
|
7746
|
-
|
7747
|
-
adjustment_transaction = Braintree::Transaction.adjust_authorization(
|
7748
|
-
initial_transaction.transaction.id, "85.50"
|
7749
|
-
)
|
7750
|
-
|
7751
|
-
expect(adjustment_transaction.success?).to eq(false)
|
7752
|
-
expect(adjustment_transaction.transaction.amount).to eq(BigDecimal("75.50"))
|
7753
|
-
expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionMustBeInStateAuthorized)
|
7754
|
-
end
|
7755
|
-
|
7756
7840
|
it "returns failure, when transaction authorization type final or undefined" do
|
7757
7841
|
additional_params = {:transaction_source => "recurring"}
|
7758
7842
|
initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe "Package Tracking Unit Tests" do
|
4
|
+
describe "creates and validates requests" do
|
5
|
+
let(:gateway) do
|
6
|
+
config = Braintree::Configuration.new(
|
7
|
+
:merchant_id => "merchant_id",
|
8
|
+
:public_key => "public_key",
|
9
|
+
:private_key => "private_key",
|
10
|
+
)
|
11
|
+
Braintree::Gateway.new(config)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "creates transaction gateway package tracking request signature" do
|
15
|
+
expect(Braintree::TransactionGateway._package_tracking_request_signature).to match(
|
16
|
+
[
|
17
|
+
:carrier,
|
18
|
+
{:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
|
19
|
+
:notify_payer, :tracking_number,
|
20
|
+
],
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "raises an ArgumentError if transaction_id is an invalid format" do
|
25
|
+
expect do
|
26
|
+
Braintree::Transaction.package_tracking("invalid-transaction-id", {})
|
27
|
+
end.to raise_error(ArgumentError, "transaction_id is invalid")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "raises an exception if attributes contain an invalid key" do
|
31
|
+
expect do
|
32
|
+
Braintree::Transaction.package_tracking("txn123", {:invalid_key => "random", :carrier => "UPS", :tracking_number => "123123"})
|
33
|
+
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "handles response" do
|
38
|
+
it "parses the packages response correctly" do
|
39
|
+
transaction = Braintree::Transaction._new(
|
40
|
+
:gateway,
|
41
|
+
:shipments => [
|
42
|
+
{:id => "id1", :carrier => "UPS", :tracking_number => "tracking_number_1", :paypal_tracking_id => "pp_tracking_number_1"},
|
43
|
+
{:id => "id2", :carrier => "FEDEX", :tracking_number => "tracking_number_2", :paypal_tracking_id => "pp_tracking_number_2"}
|
44
|
+
],
|
45
|
+
)
|
46
|
+
expect(transaction.packages.size).to eq(2)
|
47
|
+
expect(transaction.packages[0].id).to eq("id1")
|
48
|
+
expect(transaction.packages[0].carrier).to eq("UPS")
|
49
|
+
expect(transaction.packages[0].tracking_number).to eq("tracking_number_1")
|
50
|
+
expect(transaction.packages[0].paypal_tracking_id).to eq("pp_tracking_number_1")
|
51
|
+
|
52
|
+
expect(transaction.packages[1].id).to eq("id2")
|
53
|
+
expect(transaction.packages[1].carrier).to eq("FEDEX")
|
54
|
+
expect(transaction.packages[1].tracking_number).to eq("tracking_number_2")
|
55
|
+
expect(transaction.packages[1].paypal_tracking_id).to eq("pp_tracking_number_2")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "doesn't blow up if no shipments are present in the transaction response" do
|
59
|
+
transaction = Braintree::Transaction._new(
|
60
|
+
:gateway,
|
61
|
+
:shipments => [],
|
62
|
+
)
|
63
|
+
expect(transaction.packages.size).to eq(0)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "doesn't blow up if shipments tag is not present in the transaction response" do
|
67
|
+
transaction = Braintree::Transaction._new(
|
68
|
+
:gateway,
|
69
|
+
{},
|
70
|
+
)
|
71
|
+
expect(transaction.packages.size).to eq(0)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -41,7 +41,7 @@ describe Braintree::TransactionGateway do
|
|
41
41
|
:ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,:three_d_secure_token, #Deprecated
|
42
42
|
:transaction_source, :type, :venmo_sdk_payment_method_code, #Deprecated
|
43
43
|
:sca_exemption, :currency_iso_code, :exchange_rate_quote_id,
|
44
|
-
{:line_items => [:
|
44
|
+
{:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
|
45
45
|
{:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
|
46
46
|
{:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}, {:network_tokenization_attributes => [:cryptogram, :ecommerce_indicator, :token_requestor_id]}]},
|
47
47
|
{:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
|
@@ -81,7 +81,7 @@ describe Braintree::TransactionGateway do
|
|
81
81
|
{:three_d_secure => [:required]},
|
82
82
|
{:amex_rewards => [:request_id, :points, :currency_amount, :currency_iso_code]},
|
83
83
|
{:venmo => [:profile_id]},
|
84
|
-
{:credit_card => [:account_type]},
|
84
|
+
{:credit_card => [:account_type, :process_debit_as_credit]},
|
85
85
|
]
|
86
86
|
},
|
87
87
|
{:external_vault => [
|
@@ -137,7 +137,7 @@ describe Braintree::TransactionGateway do
|
|
137
137
|
:discount_amount,
|
138
138
|
:shipping_amount,
|
139
139
|
:ships_from_postal_code,
|
140
|
-
:line_items => [:commodity_code, :description, :discount_amount, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :
|
140
|
+
:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url],
|
141
141
|
])
|
142
142
|
end
|
143
143
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braintree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braintree
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- lib/braintree/transaction/local_payment_details.rb
|
182
182
|
- lib/braintree/transaction/meta_checkout_card_details.rb
|
183
183
|
- lib/braintree/transaction/meta_checkout_token_details.rb
|
184
|
+
- lib/braintree/transaction/package_details.rb
|
184
185
|
- lib/braintree/transaction/payment_receipt.rb
|
185
186
|
- lib/braintree/transaction/payment_receipt/card_present_data.rb
|
186
187
|
- lib/braintree/transaction/payment_receipt/merchant_address.rb
|
@@ -250,6 +251,7 @@ files:
|
|
250
251
|
- spec/integration/braintree/merchant_account_spec.rb
|
251
252
|
- spec/integration/braintree/merchant_spec.rb
|
252
253
|
- spec/integration/braintree/oauth_spec.rb
|
254
|
+
- spec/integration/braintree/package_tracking_spec.rb
|
253
255
|
- spec/integration/braintree/payment_method_nonce_spec.rb
|
254
256
|
- spec/integration/braintree/payment_method_spec.rb
|
255
257
|
- spec/integration/braintree/payment_method_us_bank_account_spec.rb
|
@@ -311,6 +313,7 @@ files:
|
|
311
313
|
- spec/unit/braintree/meta_checkout_token_details_spec.rb
|
312
314
|
- spec/unit/braintree/meta_checkout_token_spec.rb
|
313
315
|
- spec/unit/braintree/modification_spec.rb
|
316
|
+
- spec/unit/braintree/package_tracking_spec.rb
|
314
317
|
- spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb
|
315
318
|
- spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb
|
316
319
|
- spec/unit/braintree/payment_method_nonce_details_spec.rb
|