Skip to content

Commit

Permalink
4.27.0
Browse files Browse the repository at this point in the history
Co-authored-by: Dani Poplin <dpoplin@paypal.com>
Co-authored-by: Sara Vasquez <saravasquez@paypal.com>
  • Loading branch information
3 people committed Mar 6, 2024
1 parent 282cb0d commit a59bfd6
Show file tree
Hide file tree
Showing 14 changed files with 165 additions and 188 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.27.0
* Add `UnderReview` status to `Dispute`
* Add `DisputeUnderReview` to `WebhookNotification.Kind`

## 4.26.0
* Remove usage of standard library deprecated `cgi` module. _Note: this will break integrations on versions of Python below 3.2. However, this is NOT a breaking change to this library, due to our current support of Python 3.5+._
* Add `PackageDetails` class.
Expand Down
5 changes: 4 additions & 1 deletion braintree/credit_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,7 @@ def masked_number(self):
"""
Returns the masked number of the CreditCard.
"""
return self.bin + "******" + self.last_4
bin = self.bin_extended if hasattr(self, "bin_extended") else self.bin
mask_length = 16 - len(bin) - len(self.last_4)
mask = "*" * mask_length
return bin + mask + self.last_4
7 changes: 5 additions & 2 deletions braintree/dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ class Status(object):
* braintree.Dispute.Status.Accepted
* braintree.Dispute.Status.AutoAccepted
* braintree.Dispute.Status.Disputed
* braintree.Dispute.Status.Expired
* braintree.Dispute.Status.Lost
* braintree.Dispute.Status.Open
* braintree.Dispute.Status.UnderReview
* braintree.Dispute.Status.Won
* braintree.Dispute.Status.Lost
"""
Accepted = "accepted"
AutoAccepted = "auto_accepted"
Disputed = "disputed"
Expired = "expired"
Lost = "lost"
Open = "open"
UnderReview = "under_review"
Won = "won"
Lost = "lost"

# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class Reason(object):
Expand Down
2 changes: 1 addition & 1 deletion braintree/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Version = "4.26.0"
Version = "4.27.0"
1 change: 1 addition & 0 deletions braintree/webhook_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Kind(object):
DisputeExpired = "dispute_expired"
DisputeLost = "dispute_lost"
DisputeOpened = "dispute_opened"
DisputeUnderReview = "dispute_under_review"
DisputeWon = "dispute_won"
GrantedPaymentMethodRevoked = "granted_payment_method_revoked"
GrantorUpdatedGrantedPaymentMethod = "grantor_updated_granted_payment_method"
Expand Down
80 changes: 74 additions & 6 deletions braintree/webhook_testing_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ def __subject_sample_xml(self, kind, id):
return self.__disbursement_exception_sample_xml(id)
elif kind == WebhookNotification.Kind.Disbursement:
return self.__disbursement_sample_xml(id)
elif kind == WebhookNotification.Kind.DisputeOpened:
return self.__dispute_opened_sample_xml(id)
elif kind == WebhookNotification.Kind.DisputeLost:
return self.__dispute_lost_sample_xml(id)
elif kind == WebhookNotification.Kind.DisputeWon:
return self.__dispute_won_sample_xml(id)
elif kind == WebhookNotification.Kind.DisputeAccepted:
return self.__dispute_accepted_sample_xml(id)
elif kind == WebhookNotification.Kind.DisputeAutoAccepted:
Expand All @@ -77,6 +71,14 @@ def __subject_sample_xml(self, kind, id):
return self.__dispute_disputed_sample_xml(id)
elif kind == WebhookNotification.Kind.DisputeExpired:
return self.__dispute_expired_sample_xml(id)
elif kind == WebhookNotification.Kind.DisputeLost:
return self.__dispute_lost_sample_xml(id)
elif kind == WebhookNotification.Kind.DisputeOpened:
return self.__dispute_opened_sample_xml(id)
elif kind == WebhookNotification.Kind.DisputeUnderReview:
return self.__dispute_under_review_sample_xml(id)
elif kind == WebhookNotification.Kind.DisputeWon:
return self.__dispute_won_sample_xml(id)
elif kind == WebhookNotification.Kind.SubscriptionBillingSkipped:
return self.__subscription_billing_skipped_sample_xml(id)
elif kind == WebhookNotification.Kind.SubscriptionChargedSuccessfully:
Expand Down Expand Up @@ -224,6 +226,12 @@ def __disbursement_sample_xml(self, id):
</disbursement>
""" % id

def __dispute_under_review_sample_xml(self, id):
if id == "legacy_dispute_id":
return self.__old_dispute_under_review_sample_xml(id)
else:
return self.__new_dispute_under_review_sample_xml(id)

def __dispute_opened_sample_xml(self, id):
if id == "legacy_dispute_id":
return self.__old_dispute_opened_sample_xml(id)
Expand Down Expand Up @@ -266,6 +274,25 @@ def __dispute_expired_sample_xml(self, id):
else:
return self.__new_dispute_expired_sample_xml(id)

def __old_dispute_under_review_sample_xml(self, id):
return """
<dispute>
<amount>250.00</amount>
<currency-iso-code>USD</currency-iso-code>
<received-date type="date">2014-03-01</received-date>
<reply-by-date type="date">2014-03-21</reply-by-date>
<kind>chargeback</kind>
<status>under_review</status>
<reason>fraud</reason>
<id>%s</id>
<transaction>
<id>%s</id>
<amount>250.00</amount>
</transaction>
<date-opened type="date">2014-03-28</date-opened>
</dispute>
""" % (id, id)

def __old_dispute_opened_sample_xml(self, id):
return """
<dispute>
Expand Down Expand Up @@ -400,6 +427,47 @@ def __old_dispute_expired_sample_xml(self, id):
</dispute>
""" % (id, id)

def __new_dispute_under_review_sample_xml(self, id):
return """
<dispute>
<id>%s</id>
<amount>100.00</amount>
<amount-disputed>100.00</amount-disputed>
<amount-won>95.00</amount-won>
<case-number>CASE-12345</case-number>
<created-at type="datetime">2017-06-16T20:44:41Z</created-at>
<currency-iso-code>USD</currency-iso-code>
<forwarded-comments nil="true"/>
<kind>chargeback</kind>
<merchant-account-id>ytnlulaloidoqwvzxjrdqputg</merchant-account-id>
<reason>fraud</reason>
<reason-code nil="true"/>
<reason-description nil="true"/>
<received-date type="date">2016-02-15</received-date>
<reference-number>REF-9876</reference-number>
<reply-by-date type="date">2016-02-22</reply-by-date>
<status>under_review</status>
<updated-at type="datetime">2017-06-16T20:44:41Z</updated-at>
<original-dispute-id>9qde5qgp</original-dispute-id>
<status-history type="array">
<status-history>
<status>under_review</status>
<timestamp type="datetime">2017-06-15T20:44:41Z</timestamp>
</status-history>
</status-history>
<evidence type="array"/>
<transaction>
<id>%s</id>
<amount>100.00</amount>
<created-at>2017-06-21T20:44:41Z</created-at>
<order-id nil="true"/>
<purchase-order-number nil="true"/>
<payment-instrument-subtype>Visa</payment-instrument-subtype>
</transaction>
<date-opened type=\"date\">2014-03-28</date-opened>
</dispute>
""" % (id, id)

def __new_dispute_opened_sample_xml(self, id):
return """
<dispute>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="braintree",
version="4.26.0",
version="4.27.0",
description="Braintree Python Library",
long_description=long_description,
author="Braintree",
Expand Down
11 changes: 5 additions & 6 deletions tests/integration/test_credit_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ def test_create_with_three_d_secure_nonce(self):

three_d_secure_info = result.credit_card.verification.three_d_secure_info

self.assertEqual("Y", three_d_secure_info.enrolled)
self.assertEqual("authenticate_successful", three_d_secure_info.status)
self.assertEqual(True, three_d_secure_info.liability_shifted)
self.assertEqual(True, three_d_secure_info.liability_shift_possible)
self.assertEqual("cavv_value", three_d_secure_info.cavv)
self.assertEqual("xid_value", three_d_secure_info.xid)
self.assertEqual(None, three_d_secure_info.ds_transaction_id)
self.assertEqual("05", three_d_secure_info.eci_flag)
self.assertEqual("1.0.2", three_d_secure_info.three_d_secure_version)
self.assertIsInstance(three_d_secure_info.enrolled, str)
self.assertIsInstance(three_d_secure_info.cavv, str)
self.assertIsInstance(three_d_secure_info.xid, str)
self.assertIsInstance(three_d_secure_info.eci_flag, str)
self.assertIsInstance(three_d_secure_info.three_d_secure_version, str)

def test_create_with_three_d_secure_pass_thru(self):
customer_id = Customer.create().customer.id
Expand Down
11 changes: 5 additions & 6 deletions tests/integration/test_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,14 @@ def test_create_with_three_d_secure_nonce(self):

three_d_secure_info = result.customer.payment_methods[0].verification.three_d_secure_info

self.assertEqual("Y", three_d_secure_info.enrolled)
self.assertEqual("authenticate_successful", three_d_secure_info.status)
self.assertEqual(True, three_d_secure_info.liability_shifted)
self.assertEqual(True, three_d_secure_info.liability_shift_possible)
self.assertEqual("cavv_value", three_d_secure_info.cavv)
self.assertEqual("xid_value", three_d_secure_info.xid)
self.assertEqual(None, three_d_secure_info.ds_transaction_id)
self.assertEqual("05", three_d_secure_info.eci_flag)
self.assertEqual("1.0.2", three_d_secure_info.three_d_secure_version)
self.assertIsInstance(three_d_secure_info.enrolled, str)
self.assertIsInstance(three_d_secure_info.cavv, str)
self.assertIsInstance(three_d_secure_info.xid, str)
self.assertIsInstance(three_d_secure_info.eci_flag, str)
self.assertIsInstance(three_d_secure_info.three_d_secure_version, str)

def test_create_with_three_d_secure_pass_thru(self):
result = Customer.create({
Expand Down
11 changes: 5 additions & 6 deletions tests/integration/test_payment_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ def test_create_with_three_d_secure_nonce(self):

three_d_secure_info = result.payment_method.verification.three_d_secure_info

self.assertEqual("Y", three_d_secure_info.enrolled)
self.assertEqual("authenticate_successful", three_d_secure_info.status)
self.assertEqual(True, three_d_secure_info.liability_shifted)
self.assertEqual(True, three_d_secure_info.liability_shift_possible)
self.assertEqual("cavv_value", three_d_secure_info.cavv)
self.assertEqual("xid_value", three_d_secure_info.xid)
self.assertEqual(None, three_d_secure_info.ds_transaction_id)
self.assertEqual("05", three_d_secure_info.eci_flag)
self.assertEqual("1.0.2", three_d_secure_info.three_d_secure_version)
self.assertIsInstance(three_d_secure_info.enrolled, str)
self.assertIsInstance(three_d_secure_info.cavv, str)
self.assertIsInstance(three_d_secure_info.xid, str)
self.assertIsInstance(three_d_secure_info.eci_flag, str)
self.assertIsInstance(three_d_secure_info.three_d_secure_version, str)

def test_create_with_three_d_secure_pass_thru(self):
customer_id = Customer.create().customer.id
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/test_payment_method_nonce.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ def test_find_nonce_shows_3ds_details(self):

self.assertEqual("CreditCard", found_nonce.type)
self.assertEqual(nonce, found_nonce.nonce)
self.assertEqual("Y", three_d_secure_info.enrolled)
self.assertEqual("authenticate_successful", three_d_secure_info.status)
self.assertEqual(True, three_d_secure_info.liability_shifted)
self.assertEqual(True, three_d_secure_info.liability_shift_possible)
self.assertEqual("cavv_value", three_d_secure_info.cavv)
self.assertEqual("xid_value", three_d_secure_info.xid)
self.assertEqual("05", three_d_secure_info.eci_flag)
self.assertEqual("1.0.2", three_d_secure_info.three_d_secure_version)
self.assertIsNotNone(three_d_secure_info.three_d_secure_authentication_id)
self.assertIsInstance(three_d_secure_info.enrolled, str)
self.assertIsInstance(three_d_secure_info.cavv, str)
self.assertIsInstance(three_d_secure_info.xid, str)
self.assertIsInstance(three_d_secure_info.eci_flag, str)
self.assertIsInstance(three_d_secure_info.three_d_secure_version, str)
self.assertIsInstance(three_d_secure_info.three_d_secure_authentication_id, str)

def test_find_nonce_shows_paypal_details(self):
found_nonce = PaymentMethodNonce.find("fake-google-pay-paypal-nonce")
Expand Down
Loading

0 comments on commit a59bfd6

Please sign in to comment.