braintree 4.16.0 → 4.17.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/credit_card_verification_gateway.rb +28 -11
- data/lib/braintree/http.rb +4 -4
- data/lib/braintree/transaction/address_details.rb +1 -0
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification_gateway.rb +3 -3
- data/lib/braintree/xml/parser.rb +1 -1
- data/spec/integration/braintree/client_api/spec_helper.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +45 -0
- data/spec/unit/braintree/base_module_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +13 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02bb65b55ac949e73761f1a9ded2f1cf844bc81b7bbfc48d39e080387166e4d2
|
4
|
+
data.tar.gz: b3975e3c6a0d415544cc643aaa2471f3efe532537a0ad1a8175dcf42767b2684
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eb74dc8f70c828d8112b177bd9c424816626064fbfba2615d7246f9bae54513c5637b43be0c70a36e4dff5ac0b00aefbf208f66549829e64d37e30a37f0920a
|
7
|
+
data.tar.gz: d6af576d6a66816007de302db284e2bb456c1a37347eadac4df3ba483d5ab728e2a04dc26f2d98be91082c1a4b30790417e2d102bfd8b054b524c4b6d40174d5
|
@@ -47,22 +47,39 @@ module Braintree
|
|
47
47
|
def self._create_signature
|
48
48
|
[
|
49
49
|
{:credit_card => [
|
50
|
-
:
|
51
|
-
:
|
50
|
+
{:billing_address => AddressGateway._shared_signature},
|
51
|
+
:cardholder_name,
|
52
|
+
:cvv,
|
53
|
+
:expiration_date,
|
54
|
+
:expiration_month,
|
55
|
+
:expiration_year,
|
56
|
+
:number,
|
57
|
+
]},
|
58
|
+
{:external_vault => [
|
59
|
+
:previous_network_transaction_id,
|
60
|
+
:status,
|
52
61
|
]},
|
53
62
|
:intended_transaction_source,
|
54
|
-
{:options => [
|
63
|
+
{:options => [
|
64
|
+
:account_type,
|
65
|
+
:amount,
|
66
|
+
:merchant_account_id,
|
67
|
+
]},
|
55
68
|
:payment_method_nonce,
|
69
|
+
{:risk_data => [
|
70
|
+
:customer_browser,
|
71
|
+
:customer_ip,
|
72
|
+
]},
|
56
73
|
:three_d_secure_authentication_id,
|
57
74
|
{:three_d_secure_pass_thru => [
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
75
|
+
:authentication_response,
|
76
|
+
:cavv,
|
77
|
+
:cavv_algorithm,
|
78
|
+
:directory_response,
|
79
|
+
:ds_transaction_id,
|
80
|
+
:eci_flag,
|
81
|
+
:three_d_secure_version,
|
82
|
+
:xid,
|
66
83
|
]},
|
67
84
|
]
|
68
85
|
end
|
data/lib/braintree/http.rb
CHANGED
@@ -7,8 +7,8 @@ module Braintree
|
|
7
7
|
@config = config
|
8
8
|
end
|
9
9
|
|
10
|
-
def delete(
|
11
|
-
|
10
|
+
def delete(path, query_params = {})
|
11
|
+
full_path = path + _build_query_string(query_params)
|
12
12
|
response = _http_do Net::HTTP::Delete, path
|
13
13
|
if response.code.to_i == 200 || response.code.to_i == 204
|
14
14
|
true
|
@@ -19,8 +19,8 @@ module Braintree
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def get(
|
23
|
-
|
22
|
+
def get(path, query_params = {})
|
23
|
+
full_path = path + _build_query_string(query_params)
|
24
24
|
response = _http_do Net::HTTP::Get, path
|
25
25
|
if response.code.to_i == 200 || response.code.to_i == 422
|
26
26
|
Xml.hash_from_xml(_body(response))
|
data/lib/braintree/version.rb
CHANGED
@@ -27,7 +27,7 @@ module Braintree
|
|
27
27
|
signature_pairs = signature_string.split("&")
|
28
28
|
valid_pairs = signature_pairs.select { |pair| pair.include?("|") }.map { |pair| pair.split("|") }
|
29
29
|
|
30
|
-
valid_pairs.detect do |public_key,
|
30
|
+
valid_pairs.detect do |public_key, _signature|
|
31
31
|
public_key == @config.public_key
|
32
32
|
end
|
33
33
|
end
|
@@ -36,8 +36,8 @@ module Braintree
|
|
36
36
|
public_key, signature = _matching_signature_pair(signature_string)
|
37
37
|
raise InvalidSignature, "no matching public key" if public_key.nil?
|
38
38
|
|
39
|
-
signature_matches = [payload, payload + "\n"].any? do |
|
40
|
-
payload_signature = Braintree::Digest.hexdigest(@config.private_key,
|
39
|
+
signature_matches = [payload, payload + "\n"].any? do |p|
|
40
|
+
payload_signature = Braintree::Digest.hexdigest(@config.private_key, p)
|
41
41
|
Braintree::Digest.secure_compare(signature, payload_signature)
|
42
42
|
end
|
43
43
|
raise InvalidSignature, "signature does not match payload - one has been modified" unless signature_matches
|
data/lib/braintree/xml/parser.rb
CHANGED
@@ -32,7 +32,7 @@ module Braintree
|
|
32
32
|
case value.class.to_s
|
33
33
|
when "Hash"
|
34
34
|
if value["type"] == "array"
|
35
|
-
child_key, entries = value.detect { |k,
|
35
|
+
child_key, entries = value.detect { |k,_v| k != "type" } # child_key is throwaway
|
36
36
|
if entries.nil? || ((c = value[CONTENT_ROOT]) && c.strip.empty?)
|
37
37
|
[]
|
38
38
|
else
|
@@ -282,8 +282,8 @@ class ClientApiHttp
|
|
282
282
|
params = {:credit_card => params}
|
283
283
|
params.merge!(
|
284
284
|
:authorization_fingerprint => @options[:authorization_fingerprint],
|
285
|
-
:shared_customer_identifier =>
|
286
|
-
:shared_customer_identifier_type =>
|
285
|
+
:shared_customer_identifier => @options[:shared_customer_identifier],
|
286
|
+
:shared_customer_identifier_type => @options[:shared_customer_identifier_type],
|
287
287
|
)
|
288
288
|
|
289
289
|
post("/merchants/#{config.merchant_id}/client_api/v1/payment_methods/credit_cards", params)
|
@@ -48,6 +48,51 @@ describe Braintree::CreditCardVerification, "search" do
|
|
48
48
|
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
49
49
|
end
|
50
50
|
|
51
|
+
it "creates a new verification from external vault param" do
|
52
|
+
verification_params = {
|
53
|
+
:credit_card => {
|
54
|
+
:expiration_date => "05/2029",
|
55
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
56
|
+
},
|
57
|
+
:external_vault => {
|
58
|
+
:status => "will_vault"
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
63
|
+
|
64
|
+
expect(result).to be_success
|
65
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
66
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
67
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
68
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
69
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
70
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it "creates a new verification from risk data param" do
|
74
|
+
verification_params = {
|
75
|
+
:credit_card => {
|
76
|
+
:expiration_date => "05/2029",
|
77
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
78
|
+
},
|
79
|
+
:risk_data => {
|
80
|
+
:customer_browser => "IE7",
|
81
|
+
:customer_ip => "192.168.0.1"
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
86
|
+
|
87
|
+
expect(result).to be_success
|
88
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
89
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
90
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
91
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
92
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
93
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
94
|
+
end
|
95
|
+
|
51
96
|
it "returns processor response code and text as well as the additional processor response if declined" do
|
52
97
|
verification_params = {
|
53
98
|
:credit_card => {
|
@@ -8,11 +8,11 @@ describe Braintree::BaseModule do
|
|
8
8
|
klass = Class.new { include Braintree::BaseModule }
|
9
9
|
klass.return_object_or_raise(:obj) { result }
|
10
10
|
rescue Braintree::ValidationsFailed => ex
|
11
|
-
end
|
12
11
|
expect(ex).not_to eq(nil)
|
13
12
|
expect(ex.error_result).to eq(result)
|
14
13
|
expect(ex.inspect).to include(result.inspect)
|
15
14
|
expect(ex.to_s).to include(result.inspect)
|
15
|
+
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -22,30 +22,35 @@ describe Braintree::CreditCardVerificationGateway do
|
|
22
22
|
it "creates a credit card verification gateway signature" do
|
23
23
|
result = Braintree::CreditCardVerificationGateway._create_signature
|
24
24
|
expect(result.inspect).to include("credit_card")
|
25
|
-
expect(result.inspect).to include("
|
25
|
+
expect(result.inspect).to include("billing_address")
|
26
26
|
expect(result.inspect).to include("cardholder_name")
|
27
27
|
expect(result.inspect).to include("cvv")
|
28
28
|
expect(result.inspect).to include("expiration_date")
|
29
29
|
expect(result.inspect).to include("expiration_month")
|
30
30
|
expect(result.inspect).to include("expiration_year")
|
31
31
|
expect(result.inspect).to include("number")
|
32
|
-
expect(result.inspect).to include("
|
32
|
+
expect(result.inspect).to include("external_vault")
|
33
|
+
expect(result.inspect).to include("previous_network_transaction_id")
|
34
|
+
expect(result.inspect).to include("status")
|
33
35
|
expect(result.inspect).to include("intended_transaction_source")
|
34
36
|
expect(result.inspect).to include("options")
|
37
|
+
expect(result.inspect).to include("account_type")
|
35
38
|
expect(result.inspect).to include("amount")
|
36
39
|
expect(result.inspect).to include("merchant_account_id")
|
37
|
-
expect(result.inspect).to include("account_type")
|
38
40
|
expect(result.inspect).to include("payment_method_nonce")
|
41
|
+
expect(result.inspect).to include("risk_data")
|
42
|
+
expect(result.inspect).to include("customer_browser")
|
43
|
+
expect(result.inspect).to include("customer_ip")
|
39
44
|
expect(result.inspect).to include("three_d_secure_authentication_id")
|
40
45
|
expect(result.inspect).to include("three_d_secure_pass_thru")
|
41
|
-
expect(result.inspect).to include("eci_flag")
|
42
|
-
expect(result.inspect).to include("cavv")
|
43
|
-
expect(result.inspect).to include("xid")
|
44
|
-
expect(result.inspect).to include("three_d_secure_version")
|
45
46
|
expect(result.inspect).to include("authentication_response")
|
46
|
-
expect(result.inspect).to include("
|
47
|
+
expect(result.inspect).to include("cavv")
|
47
48
|
expect(result.inspect).to include("cavv_algorithm")
|
49
|
+
expect(result.inspect).to include("directory_response")
|
48
50
|
expect(result.inspect).to include("ds_transaction_id")
|
51
|
+
expect(result.inspect).to include("eci_flag")
|
52
|
+
expect(result.inspect).to include("three_d_secure_version")
|
53
|
+
expect(result.inspect).to include("xid")
|
49
54
|
end
|
50
55
|
end
|
51
56
|
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.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braintree
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|