braintree 4.20.0 → 4.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/braintree/address.rb +1 -0
- data/lib/braintree/address_gateway.rb +3 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card_verification.rb +16 -12
- data/lib/braintree/customer.rb +3 -2
- data/lib/braintree/customer_gateway.rb +6 -2
- data/lib/braintree/error_codes.rb +4 -0
- data/lib/braintree/local_payment_completed.rb +4 -1
- data/lib/braintree/paypal_account.rb +2 -0
- data/lib/braintree/transaction/address_details.rb +1 -0
- data/lib/braintree/transaction/customer_details.rb +2 -1
- data/lib/braintree/transaction/package_details.rb +4 -1
- data/lib/braintree/transaction.rb +2 -0
- data/lib/braintree/transaction_gateway.rb +55 -47
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +2 -0
- data/lib/braintree/webhook_testing_gateway.rb +22 -1
- data/spec/integration/braintree/address_spec.rb +6 -0
- data/spec/integration/braintree/apple_pay_spec.rb +1 -1
- data/spec/integration/braintree/credit_card_verification_spec.rb +19 -0
- data/spec/integration/braintree/customer_spec.rb +6 -0
- data/spec/integration/braintree/merchant_account_spec.rb +2 -2
- data/spec/integration/braintree/merchant_spec.rb +17 -138
- data/spec/integration/braintree/package_tracking_spec.rb +34 -15
- data/spec/integration/braintree/payment_method_spec.rb +7 -1
- data/spec/integration/braintree/paypal_account_spec.rb +2 -0
- data/spec/integration/braintree/transaction_spec.rb +140 -1
- data/spec/unit/braintree/configuration_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_spec.rb +2 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +13 -2
- data/spec/unit/braintree/customer_spec.rb +8 -0
- data/spec/unit/braintree/error_result_spec.rb +1 -1
- data/spec/unit/braintree/local_payment_completed_spec.rb +17 -5
- data/spec/unit/braintree/package_tracking_spec.rb +5 -2
- data/spec/unit/braintree/paypal_account_spec.rb +9 -0
- data/spec/unit/braintree/transaction/customer_details_spec.rb +2 -1
- data/spec/unit/braintree/transaction_gateway_spec.rb +54 -48
- data/spec/unit/braintree/webhook_notification_spec.rb +12 -0
- metadata +2 -2
@@ -16,6 +16,7 @@ describe Braintree::Customer do
|
|
16
16
|
:first_name => "Patrick",
|
17
17
|
:last_name => "Smith",
|
18
18
|
:phone => "802-483-5932",
|
19
|
+
:international_phone => {:country_code => "1", :national_number => "3121234567"},
|
19
20
|
:website => "patrick.smith.com",
|
20
21
|
:created_at => Time.now,
|
21
22
|
:updated_at => Time.now,
|
@@ -27,6 +28,7 @@ describe Braintree::Customer do
|
|
27
28
|
expect(output).to include(%q(first_name: "Patrick"))
|
28
29
|
expect(output).to include(%q(last_name: "Smith"))
|
29
30
|
expect(output).to include(%q(phone: "802-483-5932"))
|
31
|
+
expect(output).to include(%q(international_phone: {:country_code=>"1", :national_number=>"3121234567"}))
|
30
32
|
expect(output).to include(%q(website: "patrick.smith.com"))
|
31
33
|
expect(output).to include(%q(addresses: []))
|
32
34
|
expect(output).to include(%q(credit_cards: []))
|
@@ -82,6 +84,7 @@ describe Braintree::Customer do
|
|
82
84
|
:fax,
|
83
85
|
:first_name,
|
84
86
|
:id,
|
87
|
+
{:international_phone=>[:country_code, :national_number]},
|
85
88
|
:last_name,
|
86
89
|
:phone,
|
87
90
|
:website,
|
@@ -111,6 +114,7 @@ describe Braintree::Customer do
|
|
111
114
|
:country_name,
|
112
115
|
:extended_address,
|
113
116
|
:first_name,
|
117
|
+
{:international_phone=>[:country_code, :national_number]},
|
114
118
|
:last_name,
|
115
119
|
:locality,
|
116
120
|
:phone_number,
|
@@ -154,6 +158,7 @@ describe Braintree::Customer do
|
|
154
158
|
:country_name,
|
155
159
|
:extended_address,
|
156
160
|
:first_name,
|
161
|
+
{:international_phone=>[:country_code, :national_number]},
|
157
162
|
:last_name,
|
158
163
|
:locality,
|
159
164
|
:phone_number,
|
@@ -176,6 +181,7 @@ describe Braintree::Customer do
|
|
176
181
|
:fax,
|
177
182
|
:first_name,
|
178
183
|
:id,
|
184
|
+
{:international_phone=>[:country_code, :national_number]},
|
179
185
|
:last_name,
|
180
186
|
:phone,
|
181
187
|
:website,
|
@@ -215,6 +221,7 @@ describe Braintree::Customer do
|
|
215
221
|
:country_name,
|
216
222
|
:extended_address,
|
217
223
|
:first_name,
|
224
|
+
{:international_phone=>[:country_code, :national_number]},
|
218
225
|
:last_name,
|
219
226
|
:locality,
|
220
227
|
:phone_number,
|
@@ -253,6 +260,7 @@ describe Braintree::Customer do
|
|
253
260
|
:country_name,
|
254
261
|
:extended_address,
|
255
262
|
:first_name,
|
263
|
+
{:international_phone=>[:country_code, :national_number]},
|
256
264
|
:last_name,
|
257
265
|
:locality,
|
258
266
|
:phone_number,
|
@@ -38,7 +38,7 @@ describe Braintree::ErrorResult do
|
|
38
38
|
:verification => {},
|
39
39
|
:transaction => nil,
|
40
40
|
)
|
41
|
-
expect(result.inspect).to include("credit_card_verification: #<Braintree::CreditCardVerification
|
41
|
+
expect(result.inspect).to include("credit_card_verification: #<Braintree::CreditCardVerification amount: ")
|
42
42
|
end
|
43
43
|
|
44
44
|
it "does not include the credit_card_verification if there isn't one" do
|
@@ -12,8 +12,11 @@ describe Braintree::LocalPaymentCompleted do
|
|
12
12
|
describe "self._new" do
|
13
13
|
it "initializes the object with the appropriate attributes set" do
|
14
14
|
params = {
|
15
|
-
|
15
|
+
bic: "a-bic",
|
16
|
+
iban_last_chars: "1234",
|
16
17
|
payer_id: "a-payer-id",
|
18
|
+
payer_name: "John Doe",
|
19
|
+
payment_id: "a-payment-id",
|
17
20
|
payment_method_nonce: "a-nonce",
|
18
21
|
transaction: {
|
19
22
|
id: "a-transaction-id",
|
@@ -24,25 +27,34 @@ describe Braintree::LocalPaymentCompleted do
|
|
24
27
|
}
|
25
28
|
local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
|
26
29
|
|
27
|
-
expect(local_payment_completed.
|
30
|
+
expect(local_payment_completed.bic).to eq("a-bic")
|
31
|
+
expect(local_payment_completed.iban_last_chars).to eq("1234")
|
28
32
|
expect(local_payment_completed.payer_id).to eq("a-payer-id")
|
33
|
+
expect(local_payment_completed.payer_name).to eq("John Doe")
|
34
|
+
expect(local_payment_completed.payment_id).to eq("a-payment-id")
|
29
35
|
expect(local_payment_completed.payment_method_nonce).to eq("a-nonce")
|
30
|
-
expect(local_payment_completed.transaction.id).to eq("a-transaction-id")
|
31
36
|
expect(local_payment_completed.transaction.amount).to eq(31.0)
|
37
|
+
expect(local_payment_completed.transaction.id).to eq("a-transaction-id")
|
32
38
|
expect(local_payment_completed.transaction.order_id).to eq("an-order-id")
|
33
39
|
expect(local_payment_completed.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
|
34
40
|
end
|
35
41
|
|
36
42
|
it "initializes the object with the appropriate attributes set if no transaction is provided" do
|
37
43
|
params = {
|
38
|
-
|
44
|
+
bic: "a-bic",
|
45
|
+
iban_last_chars: "1234",
|
39
46
|
payer_id: "a-payer-id",
|
47
|
+
payer_name: "John Doe",
|
48
|
+
payment_id: "a-payment-id",
|
40
49
|
payment_method_nonce: "a-nonce",
|
41
50
|
}
|
42
51
|
local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
|
43
52
|
|
44
|
-
expect(local_payment_completed.
|
53
|
+
expect(local_payment_completed.bic).to eq("a-bic")
|
54
|
+
expect(local_payment_completed.iban_last_chars).to eq("1234")
|
45
55
|
expect(local_payment_completed.payer_id).to eq("a-payer-id")
|
56
|
+
expect(local_payment_completed.payer_name).to eq("John Doe")
|
57
|
+
expect(local_payment_completed.payment_id).to eq("a-payment-id")
|
46
58
|
expect(local_payment_completed.payment_method_nonce).to eq("a-nonce")
|
47
59
|
expect(local_payment_completed.transaction).to be_nil
|
48
60
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
|
3
|
+
# NEXT_MAJOR_VERSION Remove paypal_tracking_id assertions, use paypal_tracker_id going forward
|
3
4
|
describe "Package Tracking Unit Tests" do
|
4
5
|
describe "creates and validates requests" do
|
5
6
|
let(:gateway) do
|
@@ -39,8 +40,8 @@ describe "Package Tracking Unit Tests" do
|
|
39
40
|
transaction = Braintree::Transaction._new(
|
40
41
|
:gateway,
|
41
42
|
: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"}
|
43
|
+
{:id => "id1", :carrier => "UPS", :tracking_number => "tracking_number_1", :paypal_tracking_id => "pp_tracking_number_1", :paypal_tracker_id => "pp_tracking_number_1"},
|
44
|
+
{:id => "id2", :carrier => "FEDEX", :tracking_number => "tracking_number_2", :paypal_tracking_id => "pp_tracking_number_2", :paypal_tracker_id => "pp_tracking_number_2"}
|
44
45
|
],
|
45
46
|
)
|
46
47
|
expect(transaction.packages.size).to eq(2)
|
@@ -48,11 +49,13 @@ describe "Package Tracking Unit Tests" do
|
|
48
49
|
expect(transaction.packages[0].carrier).to eq("UPS")
|
49
50
|
expect(transaction.packages[0].tracking_number).to eq("tracking_number_1")
|
50
51
|
expect(transaction.packages[0].paypal_tracking_id).to eq("pp_tracking_number_1")
|
52
|
+
expect(transaction.packages[0].paypal_tracker_id).to eq("pp_tracking_number_1")
|
51
53
|
|
52
54
|
expect(transaction.packages[1].id).to eq("id2")
|
53
55
|
expect(transaction.packages[1].carrier).to eq("FEDEX")
|
54
56
|
expect(transaction.packages[1].tracking_number).to eq("tracking_number_2")
|
55
57
|
expect(transaction.packages[1].paypal_tracking_id).to eq("pp_tracking_number_2")
|
58
|
+
expect(transaction.packages[1].paypal_tracker_id).to eq("pp_tracking_number_2")
|
56
59
|
end
|
57
60
|
|
58
61
|
it "doesn't blow up if no shipments are present in the transaction response" do
|
@@ -41,4 +41,13 @@ describe Braintree::PayPalAccount do
|
|
41
41
|
expect(paypal_account.updated_at).to eq(now)
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
describe "edit_paypal_vault_id" do
|
46
|
+
it "exposes edit_paypal_vault_id" do
|
47
|
+
mock_edit_paypal_vault_id = "ENCR-BA-ID1"
|
48
|
+
paypal_account = Braintree::PayPalAccount._new(:gateway, :edit_paypal_vault_id => mock_edit_paypal_vault_id)
|
49
|
+
|
50
|
+
expect(paypal_account.edit_paypal_vault_id).to eq(mock_edit_paypal_vault_id)
|
51
|
+
end
|
52
|
+
end
|
44
53
|
end
|
@@ -11,9 +11,10 @@ describe Braintree::Transaction::CustomerDetails do
|
|
11
11
|
:company => "Smith Co.",
|
12
12
|
:website => "http://www.example.com",
|
13
13
|
:phone => "6145551234",
|
14
|
+
:international_phone => {:country_code=>"1", :national_number=>"3121234567"},
|
14
15
|
:fax => "3125551234",
|
15
16
|
)
|
16
|
-
expect(details.inspect).to eq(%(#<id: "id", first_name: "Amy", last_name: "Smith", email: "amy.smith@example.com", company: "Smith Co.", website: "http://www.example.com", phone: "6145551234", fax: "3125551234">))
|
17
|
+
expect(details.inspect).to eq(%(#<id: "id", first_name: "Amy", last_name: "Smith", email: "amy.smith@example.com", company: "Smith Co.", website: "http://www.example.com", phone: "6145551234", international_phone: {:country_code=>\"1\", :national_number=>\"3121234567\"}, fax: "3125551234">))
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -33,36 +33,45 @@ describe Braintree::TransactionGateway do
|
|
33
33
|
# three_d_secure_token has been deprecated in favor of three_d_secure_authentication_id
|
34
34
|
it "creates a transaction gateway signature" do
|
35
35
|
expect(Braintree::TransactionGateway._create_signature).to match([
|
36
|
-
:amount, :billing_address_id, :channel, :
|
36
|
+
:amount, :billing_address_id, :channel, :currency_iso_code, :customer_id, :device_data,
|
37
|
+
:discount_amount, :exchange_rate_quote_id, :foreign_retailer,
|
37
38
|
:merchant_account_id, :order_id, :payment_method_nonce, :payment_method_token,
|
38
39
|
:product_sku, :purchase_order_number, :service_fee_amount, :shared_billing_address_id,
|
39
40
|
:shared_customer_id, :shared_payment_method_nonce, :shared_payment_method_token,
|
40
|
-
:shared_shipping_address_id, :shipping_address_id, :shipping_amount,
|
41
|
+
:shared_shipping_address_id, :shipping_address_id, :shipping_amount, :shipping_tax_amount,
|
41
42
|
:ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,:three_d_secure_token, #Deprecated
|
42
|
-
:transaction_source, :type, :venmo_sdk_payment_method_code, #Deprecated
|
43
|
-
:sca_exemption,
|
44
|
-
{:
|
45
|
-
{:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
|
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
|
-
{:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
|
43
|
+
:transaction_source, :type, :venmo_sdk_payment_method_code, # Deprecated
|
44
|
+
:sca_exemption,
|
45
|
+
{:apple_pay_card => [:number, :cardholder_name, :cryptogram, :expiration_month, :expiration_year, :eci_indicator]},
|
48
46
|
{
|
49
47
|
:billing => Braintree::AddressGateway._shared_signature
|
50
48
|
},
|
51
|
-
{
|
52
|
-
|
53
|
-
},
|
54
|
-
{
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
:
|
64
|
-
|
65
|
-
|
49
|
+
{: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]}]},
|
50
|
+
{:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
|
51
|
+
{:custom_fields => :_any_key_},
|
52
|
+
{:descriptor => [:name, :phone, :url]},
|
53
|
+
{:external_vault => [
|
54
|
+
:status,
|
55
|
+
:previous_network_transaction_id,
|
56
|
+
]},
|
57
|
+
{:google_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]},
|
58
|
+
{:industry => [
|
59
|
+
:industry_type,
|
60
|
+
{:data => [
|
61
|
+
:country_code, :date_of_birth, :folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax,
|
62
|
+
:passenger_first_name, :passenger_last_name, :passenger_middle_initial, :passenger_title, :issued_date, :travel_agency_name, :travel_agency_code, :ticket_number,
|
63
|
+
:issuing_carrier_code, :customer_code, :fare_amount, :fee_amount, :tax_amount, :restricted_ticket, :no_show, :advanced_deposit, :fire_safe, :property_phone, :ticket_issuer_address, :arrival_date,
|
64
|
+
{:legs => [
|
65
|
+
:conjunction_ticket, :exchange_ticket, :coupon_number, :service_class, :carrier_code, :fare_basis_code, :flight_number, :departure_date, :departure_airport_code, :departure_time,
|
66
|
+
:arrival_airport_code, :arrival_time, :stopover_permitted, :fare_amount, :fee_amount, :tax_amount, :endorsement_or_restrictions,
|
67
|
+
]},
|
68
|
+
{:additional_charges => [
|
69
|
+
:kind, :amount,
|
70
|
+
]},
|
71
|
+
]},
|
72
|
+
]},
|
73
|
+
{:installments => [:count]},
|
74
|
+
{: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]},
|
66
75
|
{:options => [
|
67
76
|
:hold_in_escrow,
|
68
77
|
:store_in_vault,
|
@@ -70,7 +79,7 @@ describe Braintree::TransactionGateway do
|
|
70
79
|
:submit_for_settlement,
|
71
80
|
:add_billing_address_to_payment_method,
|
72
81
|
:store_shipping_address_in_vault,
|
73
|
-
:venmo_sdk_session, #Deprecated
|
82
|
+
:venmo_sdk_session, # Deprecated
|
74
83
|
:payee_id,
|
75
84
|
:payee_email,
|
76
85
|
:skip_advanced_fraud_checking,
|
@@ -84,31 +93,23 @@ describe Braintree::TransactionGateway do
|
|
84
93
|
{:credit_card => [:account_type, :process_debit_as_credit]},
|
85
94
|
]
|
86
95
|
},
|
87
|
-
{:external_vault => [
|
88
|
-
:status,
|
89
|
-
:previous_network_transaction_id,
|
90
|
-
]},
|
91
|
-
{:custom_fields => :_any_key_},
|
92
|
-
{:descriptor => [:name, :phone, :url]},
|
93
96
|
{:paypal_account => [:email, :token, :paypal_data, :payee_id, :payee_email, :payer_id, :payment_id]},
|
94
|
-
{:
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
{:google_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]},
|
111
|
-
{:installments => [:count]},
|
97
|
+
{:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
|
98
|
+
{
|
99
|
+
:shipping => Braintree::AddressGateway._shared_signature + [:shipping_method],
|
100
|
+
},
|
101
|
+
{
|
102
|
+
:three_d_secure_pass_thru => [
|
103
|
+
:eci_flag,
|
104
|
+
:cavv,
|
105
|
+
:xid,
|
106
|
+
:three_d_secure_version,
|
107
|
+
:authentication_response,
|
108
|
+
:directory_response,
|
109
|
+
:cavv_algorithm,
|
110
|
+
:ds_transaction_id,
|
111
|
+
]
|
112
|
+
},
|
112
113
|
])
|
113
114
|
end
|
114
115
|
|
@@ -136,9 +137,14 @@ describe Braintree::TransactionGateway do
|
|
136
137
|
:tax_exempt,
|
137
138
|
:discount_amount,
|
138
139
|
:shipping_amount,
|
140
|
+
:shipping_tax_amount,
|
139
141
|
:ships_from_postal_code,
|
140
142
|
: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
143
|
])
|
142
144
|
end
|
145
|
+
|
146
|
+
it "creates transaction gateway submit for partial settlement signature" do
|
147
|
+
expect(Braintree::TransactionGateway._submit_for_partial_settlement_signature).to include(:final_capture)
|
148
|
+
end
|
143
149
|
end
|
144
150
|
end
|
@@ -941,4 +941,16 @@ describe Braintree::WebhookNotification do
|
|
941
941
|
end.to raise_error(Braintree::InvalidChallenge, /challenge contains non-hex characters/)
|
942
942
|
end
|
943
943
|
end
|
944
|
+
|
945
|
+
describe "refund failed" do
|
946
|
+
it "builds a sample notification for refund failed" do
|
947
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
948
|
+
Braintree::WebhookNotification::Kind::RefundFailed,
|
949
|
+
"my_id",
|
950
|
+
)
|
951
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
952
|
+
expect(notification.kind.should).to eq(Braintree::WebhookNotification::Kind::RefundFailed)
|
953
|
+
expect(notification.transaction.id).to eq("my_id")
|
954
|
+
end
|
955
|
+
end
|
944
956
|
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.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braintree
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|