braintree 4.3.0 → 4.4.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.rb +2 -0
- data/lib/braintree/http.rb +1 -0
- data/lib/braintree/local_payment_expired.rb +21 -0
- data/lib/braintree/local_payment_funded.rb +22 -0
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +6 -0
- data/lib/braintree/webhook_testing_gateway.rb +31 -2
- data/spec/unit/braintree/http_spec.rb +2 -0
- data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
- data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +34 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7279d06aef254f1954bf7b8801e4717aa258f7413f05f1c076fbb6f1e2258c5
|
4
|
+
data.tar.gz: 9b136fbc93fa3f251972a44b0728244f746ef1868507cb40385780cd2137ff22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d611127df5091cb248b434285a2cd2c5080749515d60beba2a00af28809106dca11a4b5607f8774ac111d8115e5bbc85965817ba8fb45e309bbb2ecb8b8e4382
|
7
|
+
data.tar.gz: c7f547f0a2b62aa36b94e2f410e3375d1b4a2d3d7e76c570f3c9d387c15299a8ed858237db461de7f1889b5552e4c85dd1cedd42ce741c2360eeb38b71ef87c3
|
data/lib/braintree.rb
CHANGED
@@ -73,6 +73,8 @@ require "braintree/graphql_client"
|
|
73
73
|
require "braintree/google_pay_card"
|
74
74
|
require "braintree/local_payment_completed"
|
75
75
|
require "braintree/local_payment_reversed"
|
76
|
+
require "braintree/local_payment_expired"
|
77
|
+
require "braintree/local_payment_funded"
|
76
78
|
require "braintree/transaction/local_payment_details"
|
77
79
|
require "braintree/merchant"
|
78
80
|
require "braintree/merchant_gateway"
|
data/lib/braintree/http.rb
CHANGED
@@ -188,6 +188,7 @@ module Braintree
|
|
188
188
|
formatted_xml = input_xml.gsub(/^/, "[Braintree] ")
|
189
189
|
formatted_xml = formatted_xml.gsub(/<number>(.{6}).+?(.{4})<\/number>/m, '<number>\1******\2</number>')
|
190
190
|
formatted_xml = formatted_xml.gsub(/<cvv>.+?<\/cvv>/m, "<cvv>***</cvv>")
|
191
|
+
formatted_xml = formatted_xml.gsub(/<encrypted-card-data>.+?<\/encrypted-card-data>/m, "<encrypted-card-data>***</encrypted-card-data>")
|
191
192
|
formatted_xml
|
192
193
|
end
|
193
194
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Braintree
|
2
|
+
class LocalPaymentExpired
|
3
|
+
include BaseModule
|
4
|
+
|
5
|
+
attr_reader :payment_id
|
6
|
+
attr_reader :payment_context_id
|
7
|
+
|
8
|
+
def initialize(attributes) # :nodoc:
|
9
|
+
set_instance_variables_from_hash(attributes)
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
protected :new
|
14
|
+
end
|
15
|
+
|
16
|
+
def self._new(*args) # :nodoc:
|
17
|
+
self.new(*args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Braintree
|
2
|
+
class LocalPaymentFunded
|
3
|
+
include BaseModule
|
4
|
+
|
5
|
+
attr_reader :payment_id
|
6
|
+
attr_reader :payment_context_id
|
7
|
+
attr_reader :transaction
|
8
|
+
|
9
|
+
def initialize(attributes) # :nodoc:
|
10
|
+
set_instance_variables_from_hash(attributes)
|
11
|
+
@transaction = Transaction._new(Configuration.gateway, transaction)
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
protected :new
|
16
|
+
end
|
17
|
+
|
18
|
+
def self._new(*args) # :nodoc:
|
19
|
+
self.new(*args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/braintree/version.rb
CHANGED
@@ -28,6 +28,8 @@ module Braintree
|
|
28
28
|
GrantedPaymentMethodRevoked = "granted_payment_method_revoked"
|
29
29
|
|
30
30
|
LocalPaymentCompleted = "local_payment_completed"
|
31
|
+
LocalPaymentExpired = "local_payment_expired"
|
32
|
+
LocalPaymentFunded = "local_payment_funded"
|
31
33
|
LocalPaymentReversed = "local_payment_reversed"
|
32
34
|
|
33
35
|
OAuthAccessRevoked = "oauth_access_revoked"
|
@@ -65,6 +67,8 @@ module Braintree
|
|
65
67
|
attr_reader :revoked_payment_method_metadata
|
66
68
|
attr_reader :kind
|
67
69
|
attr_reader :local_payment_completed
|
70
|
+
attr_reader :local_payment_expired
|
71
|
+
attr_reader :local_payment_funded
|
68
72
|
attr_reader :local_payment_reversed
|
69
73
|
attr_reader :oauth_access_revocation
|
70
74
|
attr_reader :partner_merchant
|
@@ -98,6 +102,8 @@ module Braintree
|
|
98
102
|
@granted_payment_instrument_update = GrantedPaymentInstrumentUpdate._new(@subject[:granted_payment_instrument_update]) if @subject.has_key?(:granted_payment_instrument_update)
|
99
103
|
@revoked_payment_method_metadata = RevokedPaymentMethodMetadata._new(gateway, @subject) if [Kind::GrantedPaymentInstrumentRevoked, Kind::PaymentMethodRevokedByCustomer, Kind::GrantedPaymentMethodRevoked].include?(@kind)
|
100
104
|
@local_payment_completed = LocalPaymentCompleted._new(@subject[:local_payment]) if @subject.has_key?(:local_payment) && Kind::LocalPaymentCompleted == @kind
|
105
|
+
@local_payment_expired = LocalPaymentExpired._new(@subject[:local_payment_expired]) if @subject.has_key?(:local_payment_expired) && Kind::LocalPaymentExpired == @kind
|
106
|
+
@local_payment_funded = LocalPaymentFunded._new(@subject[:local_payment_funded]) if @subject.has_key?(:local_payment_funded) && Kind::LocalPaymentFunded == @kind
|
101
107
|
@local_payment_reversed = LocalPaymentReversed._new(@subject[:local_payment_reversed]) if @subject.has_key?(:local_payment_reversed) && Kind::LocalPaymentReversed == @kind
|
102
108
|
end
|
103
109
|
|
@@ -88,8 +88,12 @@ module Braintree
|
|
88
88
|
_payment_method_revoked_by_customer_sample_xml(id)
|
89
89
|
when Braintree::WebhookNotification::Kind::LocalPaymentCompleted
|
90
90
|
_local_payment_completed_sample_xml(id)
|
91
|
+
when Braintree::WebhookNotification::Kind::LocalPaymentExpired
|
92
|
+
_local_payment_expired_sample_xml
|
93
|
+
when Braintree::WebhookNotification::Kind::LocalPaymentFunded
|
94
|
+
_local_payment_funded_sample_xml(id)
|
91
95
|
when Braintree::WebhookNotification::Kind::LocalPaymentReversed
|
92
|
-
_local_payment_reversed_sample_xml
|
96
|
+
_local_payment_reversed_sample_xml
|
93
97
|
else
|
94
98
|
_subscription_sample_xml(id)
|
95
99
|
end
|
@@ -935,10 +939,35 @@ module Braintree
|
|
935
939
|
XML
|
936
940
|
end
|
937
941
|
|
938
|
-
def
|
942
|
+
def _local_payment_expired_sample_xml
|
943
|
+
<<-XML
|
944
|
+
<local-payment-expired>
|
945
|
+
<payment-id>PAY-XYZ123</payment-id>
|
946
|
+
<payment-context-id>cG5b=</payment-context-id>
|
947
|
+
</local-payment-expired>
|
948
|
+
XML
|
949
|
+
end
|
950
|
+
|
951
|
+
def _local_payment_funded_sample_xml(id)
|
952
|
+
<<-XML
|
953
|
+
<local-payment-funded>
|
954
|
+
<payment-id>PAY-XYZ123</payment-id>
|
955
|
+
<payment-context-id>cG5b=</payment-context-id>
|
956
|
+
<transaction>
|
957
|
+
<id>#{id}</id>
|
958
|
+
<status>settled</status>
|
959
|
+
<amount>49.99</amount>
|
960
|
+
<order-id>order4567</order-id>
|
961
|
+
</transaction>
|
962
|
+
</local-payment-funded>
|
963
|
+
XML
|
964
|
+
end
|
965
|
+
|
966
|
+
def _local_payment_reversed_sample_xml
|
939
967
|
<<-XML
|
940
968
|
<local-payment-reversed>
|
941
969
|
<payment-id>PAY-XYZ123</payment-id>
|
970
|
+
<payment-context-id>cG5b=</payment-context-id>
|
942
971
|
</local-payment-reversed>
|
943
972
|
XML
|
944
973
|
end
|
@@ -25,6 +25,7 @@ END
|
|
25
25
|
<last-name>Doe</last-name>
|
26
26
|
<number>1234560000001234</number>
|
27
27
|
<cvv>123</cvv>
|
28
|
+
<encrypted-card-data>8F34DFB312DC79C24FD5320622F3E11682D79E6B0C0FD881</encrypted-card-data>
|
28
29
|
</customer>
|
29
30
|
END
|
30
31
|
|
@@ -34,6 +35,7 @@ END
|
|
34
35
|
[Braintree] <last-name>Doe</last-name>
|
35
36
|
[Braintree] <number>123456******1234</number>
|
36
37
|
[Braintree] <cvv>***</cvv>
|
38
|
+
[Braintree] <encrypted-card-data>***</encrypted-card-data>
|
37
39
|
[Braintree] </customer>
|
38
40
|
END
|
39
41
|
Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).should == expected_xml
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::LocalPaymentExpired do
|
4
|
+
describe "self.new" do
|
5
|
+
it "is protected" do
|
6
|
+
expect do
|
7
|
+
Braintree::LocalPaymentExpired.new
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "self._new" do
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
14
|
+
params = {
|
15
|
+
payment_id: "a-payment-id",
|
16
|
+
payment_context_id: "a-payment-context-id",
|
17
|
+
}
|
18
|
+
local_payment_expired = Braintree::LocalPaymentExpired._new(params)
|
19
|
+
|
20
|
+
local_payment_expired.payment_id.should eq("a-payment-id")
|
21
|
+
local_payment_expired.payment_context_id.should eq("a-payment-context-id")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::LocalPaymentFunded do
|
4
|
+
describe "self.new" do
|
5
|
+
it "is protected" do
|
6
|
+
expect do
|
7
|
+
Braintree::LocalPaymentFunded.new
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "self._new" do
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
14
|
+
params = {
|
15
|
+
payment_id: "a-payment-id",
|
16
|
+
payment_context_id: "a-payment-context-id",
|
17
|
+
transaction: {
|
18
|
+
id: "a-transaction-id",
|
19
|
+
amount: "31.00",
|
20
|
+
order_id: "an-order-id",
|
21
|
+
status: Braintree::Transaction::Status::Settled,
|
22
|
+
},
|
23
|
+
}
|
24
|
+
local_payment_funded = Braintree::LocalPaymentFunded._new(params)
|
25
|
+
|
26
|
+
local_payment_funded.payment_id.should eq("a-payment-id")
|
27
|
+
local_payment_funded.payment_context_id.should eq("a-payment-context-id")
|
28
|
+
local_payment_funded.transaction.id.should eq("a-transaction-id")
|
29
|
+
local_payment_funded.transaction.amount.should eq(31.0)
|
30
|
+
local_payment_funded.transaction.order_id.should eq("an-order-id")
|
31
|
+
local_payment_funded.transaction.status.should eq(Braintree::Transaction::Status::Settled)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -668,6 +668,40 @@ describe Braintree::WebhookNotification do
|
|
668
668
|
end
|
669
669
|
end
|
670
670
|
|
671
|
+
context "local_payment_expired" do
|
672
|
+
it "builds a sample notification for a local_payment_expired webhook" do
|
673
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
674
|
+
Braintree::WebhookNotification::Kind::LocalPaymentExpired,
|
675
|
+
"my_id",
|
676
|
+
)
|
677
|
+
|
678
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
679
|
+
notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentExpired
|
680
|
+
|
681
|
+
local_payment_expired = notification.local_payment_expired
|
682
|
+
local_payment_expired.payment_id.should == "PAY-XYZ123"
|
683
|
+
local_payment_expired.payment_context_id.should == "cG5b="
|
684
|
+
end
|
685
|
+
end
|
686
|
+
|
687
|
+
context "local_payment_funded" do
|
688
|
+
it "builds a sample notification for a local_payment_funded webhook" do
|
689
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
690
|
+
Braintree::WebhookNotification::Kind::LocalPaymentFunded,
|
691
|
+
"my_id",
|
692
|
+
)
|
693
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
694
|
+
notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentFunded
|
695
|
+
|
696
|
+
local_payment_funded = notification.local_payment_funded
|
697
|
+
local_payment_funded.payment_id.should == "PAY-XYZ123"
|
698
|
+
local_payment_funded.payment_context_id.should == "cG5b="
|
699
|
+
local_payment_funded.transaction.id.should == "my_id"
|
700
|
+
local_payment_funded.transaction.status.should == Braintree::Transaction::Status::Settled
|
701
|
+
local_payment_funded.transaction.amount.should == 49.99
|
702
|
+
local_payment_funded.transaction.order_id.should == "order4567"
|
703
|
+
end
|
704
|
+
end
|
671
705
|
|
672
706
|
context "local_payment_reversed" do
|
673
707
|
it "builds a sample notification for a local_payment webhook" do
|
@@ -675,7 +709,6 @@ describe Braintree::WebhookNotification do
|
|
675
709
|
Braintree::WebhookNotification::Kind::LocalPaymentReversed,
|
676
710
|
"my_id",
|
677
711
|
)
|
678
|
-
|
679
712
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
680
713
|
notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentReversed
|
681
714
|
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braintree
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -104,6 +104,8 @@ files:
|
|
104
104
|
- lib/braintree/graphql_client.rb
|
105
105
|
- lib/braintree/http.rb
|
106
106
|
- lib/braintree/local_payment_completed.rb
|
107
|
+
- lib/braintree/local_payment_expired.rb
|
108
|
+
- lib/braintree/local_payment_funded.rb
|
107
109
|
- lib/braintree/local_payment_reversed.rb
|
108
110
|
- lib/braintree/merchant.rb
|
109
111
|
- lib/braintree/merchant_account.rb
|
@@ -270,6 +272,8 @@ files:
|
|
270
272
|
- spec/unit/braintree/errors_spec.rb
|
271
273
|
- spec/unit/braintree/http_spec.rb
|
272
274
|
- spec/unit/braintree/local_payment_completed_spec.rb
|
275
|
+
- spec/unit/braintree/local_payment_expired_spec.rb
|
276
|
+
- spec/unit/braintree/local_payment_funded_spec.rb
|
273
277
|
- spec/unit/braintree/merchant_account_spec.rb
|
274
278
|
- spec/unit/braintree/modification_spec.rb
|
275
279
|
- spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb
|
@@ -329,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
329
333
|
- !ruby/object:Gem::Version
|
330
334
|
version: '0'
|
331
335
|
requirements: []
|
332
|
-
rubygems_version: 3.2.
|
336
|
+
rubygems_version: 3.2.25
|
333
337
|
signing_key:
|
334
338
|
specification_version: 4
|
335
339
|
summary: Braintree Ruby Server SDK
|