Skip to content

Commit 7f96e2a

Browse files
4.36.0
Co-authored-by: Kevin Laguerre <[email protected]>
1 parent fe3a6fe commit 7f96e2a

File tree

62 files changed

+1227
-184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1227
-184
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 4.36.0
4+
* Add `account_information_inquiry` to:
5+
* `CreditCardVerification.create`
6+
* `PaymentMethod.create` and `PaymentMethod.update`
7+
* `CreditCard.create` and `CreditCard.update`
8+
* Enhancements to PayPal customer recommendations
9+
* Create a session and get recommendations in one call
10+
* Hash customer email and phone number
11+
* Add business, consumer, corporate, purchase from bin data in credit card responses
12+
313
## 4.35.0
414
* Add support for capturing payment facilitator and sub-merchant details with transactions
515
* Remove marketplace features

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The Braintree Python SDK is tested against Python versions 3.5.3 and 3.12.0.
1414
_The Python core development community has released [End-of-Life branches](https://devguide.python.org/devcycle/#end-of-life-branches) for Python versions 2.7 - 3.4, and are no longer receiving [security updates](https://devguide.python.org/#branchstatus). As a result, Braintree no longer supports these versions of Python._
1515

1616
## Versions
17-
> :warning: **The SSL certificates for Python SDK versions older than 4.31.0 are set to expire by June 31, 2025. If you do not update your SDK to the latest version with the updated certificates by June 31, 2025, 100% of your impacted traffic will fail**
17+
> :warning: **The SSL certificates for Python SDK versions older than 3.40.0 are set to expire by March 30, 2026. If you do not update your SDK to the latest version with the updated certificates by March 30, 2026, 100% of your impacted traffic will fail**
1818
1919
Braintree employs a deprecation policy for our SDKs. For more information on the statuses of an SDK check our [developer docs](https://developer.paypal.com/braintree/docs/reference/general/server-sdk-deprecation-policy).
2020

braintree/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from braintree.liability_shift import LiabilityShift
4040
from braintree.local_payment_completed import LocalPaymentCompleted
4141
from braintree.local_payment_reversed import LocalPaymentReversed
42+
from braintree.monetary_amount import MonetaryAmount
4243
from braintree.merchant import Merchant
4344
from braintree.merchant_account import MerchantAccount
4445
from braintree.merchant_account_gateway import MerchantAccountGateway

braintree/credit_card.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class DebitNetwork(Enum):
128128
Star_Access = "STAR_ACCESS"
129129

130130
Commercial = CountryOfIssuance = Debit = DurbinRegulated = \
131+
Business = Consumer = Corporate = Purchase = \
131132
Healthcare = IssuingBank = Payroll = Prepaid = PrepaidReloadable = ProductId = CardTypeIndicator
132133

133134
@staticmethod
@@ -235,6 +236,7 @@ def signature(type):
235236
]
236237

237238
options = [
239+
"account_information_inquiry",
238240
"fail_on_duplicate_payment_method",
239241
"fail_on_duplicate_payment_method_for_customer",
240242
"make_default",

braintree/credit_card_verification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def create_signature():
8383
"status"
8484
]
8585
options_params = [
86-
"account_type", "amount", "merchant_account_id"
86+
"account_type", "amount", "merchant_account_id", "account_information_inquiry"
8787
]
8888
risk_data_params = [
8989
"customer_browser",

braintree/customer_session_gateway.py

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
CustomerRecommendations,
1111
CustomerRecommendationsInput,
1212
CustomerRecommendationsPayload,
13+
RecommendedPaymentOption,
1314
PaymentOptions,
1415
)
1516

16-
1717
class CustomerSessionGateway:
1818
"""
1919
Creates and manages PayPal customer sessions.
@@ -109,59 +109,60 @@ def update_customer_session(self, update_customer_session_input: UpdateCustomerS
109109
variables = dict({"input": update_customer_session_input.to_graphql_variables()})
110110
return self._execute_mutation(mutation, variables, "updateCustomerSession")
111111

112-
def get_customer_recommendations(self, customer_recommendations_input: CustomerRecommendationsInput):
112+
def get_customer_recommendations(self, get_customer_recommendations_input: CustomerRecommendationsInput):
113113
"""
114114
Retrieves customer recommendations associated with a customer session.
115115
116116
Example:
117117
118118
recommendations_input = (
119119
CustomerRecommendationsInput
120-
.builder(session_id, [Recommendations.PAYMENT_RECOMMENDATIONS])
120+
.builder()
121+
.session_id(session_id)
121122
.build()
122123
)
123124
124125
result = gateway.customer_session.get_customer_recommendations(recommendations_input)
125126
126127
if result.is_success:
127-
print(result.customer_recommendations)
128+
print(result.customer_recommendations.recommendations.payment_recommendations)
128129
129130
Args:
130-
CustomerRecommendationsInput: Input object for retrieving customer recommendations.
131+
GenerateCustomerRecommendationsInput: Input object for retrieving customer recommendations.
131132
132133
Returns:
133-
(Successful|Error)Result: A result object containing a CustomerRecommendationsPayload and a success flag if successful, or errors otherwise.
134+
(Successful|Error)Result: A result object containing a GenerateCustomerRecommendationsPayload and a success flag if successful, or errors otherwise.
134135
135136
Raises:
136137
UnexpectedError: If there is an unexpected error during the process.
137138
"""
138139
query = """
139-
query CustomerRecommendations($input: CustomerRecommendationsInput!) {
140-
customerRecommendations(input: $input) {
140+
mutation GenerateCustomerRecommendations($input: GenerateCustomerRecommendationsInput!) {
141+
generateCustomerRecommendations(input: $input) {
141142
isInPayPalNetwork
142-
recommendations {
143-
... on PaymentRecommendations {
144-
paymentOptions {
145-
paymentOption
146-
recommendedPriority
147-
}
148-
}
143+
paymentRecommendations{
144+
paymentOption
145+
recommendedPriority
149146
}
150147
}
151148
}
152149
"""
153-
variables = dict({"input": customer_recommendations_input.to_graphql_variables()})
154-
150+
variables = dict({"input": get_customer_recommendations_input.to_graphql_variables()})
155151
response = self.graphql_client.query(query, variables)
156152
errors = GraphQLClient.get_validation_errors(response)
153+
157154
if errors:
158155
return ErrorResult(self.gateway, {"errors": errors, "message": "Validation errors were found."})
159156
try:
160-
recommendations_payload = self._extract_customer_recommendations_payload(response)
161-
return SuccessfulResult({"customer_recommendations": recommendations_payload})
157+
recommendations_payload = response["data"]
158+
customer_recommendations = CustomerRecommendationsPayload(
159+
response = recommendations_payload
160+
)
161+
return SuccessfulResult({"customer_recommendations": customer_recommendations})
162162
except KeyError:
163163
raise UnexpectedError("Couldn't parse response")
164164

165+
165166
def _execute_mutation(self, mutation: str, variables: Dict, operation: str):
166167
response = self.graphql_client.query(mutation, variables)
167168
errors = GraphQLClient.get_validation_errors(response)
@@ -171,23 +172,4 @@ def _execute_mutation(self, mutation: str, variables: Dict, operation: str):
171172
session_id = response["data"][operation]["sessionId"]
172173
return SuccessfulResult({"session_id": session_id})
173174
except KeyError:
174-
raise UnexpectedError("Couldn't parse response")
175-
176-
def _extract_customer_recommendations_payload(self, response):
177-
customer_recommendations = response["data"]["customerRecommendations"]
178-
179-
is_in_paypal_network = customer_recommendations["isInPayPalNetwork"]
180-
recommendations = [] if customer_recommendations["recommendations"] is None else customer_recommendations["recommendations"]["paymentOptions"]
181-
payment_options = [
182-
PaymentOptions(
183-
recommendation_data["paymentOption"],
184-
recommendation_data["recommendedPriority"]
185-
)
186-
for recommendation_data in recommendations
187-
]
188-
189-
recommendations_union = CustomerRecommendations(payment_options)
190-
return CustomerRecommendationsPayload(is_in_paypal_network, recommendations_union)
191-
192-
193-
175+
raise UnexpectedError("Couldn't parse response")

braintree/exchange_rate_quote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from braintree.attribute_getter import AttributeGetter
2-
from braintree.montary_amount import MontaryAmount
2+
from braintree.monetary_amount import MonetaryAmount
33

44
class ExchangeRateQuote(AttributeGetter):
55
def __init__(self,attributes):

braintree/exchange_rate_quote_payload.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from braintree.exchange_rate_quote import ExchangeRateQuote
2-
from braintree.montary_amount import MontaryAmount
2+
from braintree.monetary_amount import MonetaryAmount
33

44
class ExchangeRateQuotePayload(object):
55
def __init__(self, data):
@@ -11,10 +11,10 @@ def __init__(self, data):
1111
quote_amount_obj = quote_obj.get("quoteAmount")
1212
base_attrs = {"value":base_amount_obj.get("value"),
1313
"currency_code":base_amount_obj.get("currencyCode")}
14-
base_amount = MontaryAmount(base_attrs)
14+
base_amount = MonetaryAmount(base_attrs)
1515
quote_attrs = {"value":quote_amount_obj.get("value"),
1616
"currency_code":quote_amount_obj.get("currencyCode")}
17-
quote_amount = MontaryAmount(quote_attrs)
17+
quote_amount = MonetaryAmount(quote_attrs)
1818
attributes = {"id":quote_obj.get("id"),
1919
"exchange_rate":quote_obj.get("exchangeRate"),
2020
"trade_rate":quote_obj.get("tradeRate"),

braintree/graphql/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
from braintree.graphql.enums import (
22
RecommendedPaymentOption,
3-
Recommendations
3+
Recommendations,
44
)
55
from braintree.graphql.inputs import (
66
PhoneInput,
77
CustomerSessionInput,
88
CreateCustomerSessionInput,
99
UpdateCustomerSessionInput,
1010
CustomerRecommendationsInput,
11+
MonetaryAmountInput,
12+
PayPalPayeeInput,
13+
PayPalPurchaseUnitInput,
1114
)
1215
from braintree.graphql.types import (
1316
CustomerRecommendationsPayload,
14-
PaymentOptions
17+
PaymentOptions,
18+
PaymentRecommendation
1519
)
1620
from braintree.graphql.unions import (
1721
CustomerRecommendations
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from braintree.graphql.enums.recommended_payment_option import RecommendedPaymentOption
2-
from braintree.graphql.enums.recommendations import Recommendations
2+
from braintree.graphql.enums.recommendations import Recommendations

0 commit comments

Comments
 (0)