Skip to content

Commit

Permalink
4.30.0
Browse files Browse the repository at this point in the history
Co-authored-by: Rajaram Gurumurthi <rajaram.gurumurthi@paypal.com>
Co-authored-by: Sara Vasquez <saravasquez@paypal.com>
  • Loading branch information
3 people committed Sep 20, 2024
1 parent 9dc4bff commit ca488de
Show file tree
Hide file tree
Showing 15 changed files with 325 additions and 278 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 4.30.0
* Add `payer_name`, `bic` and `iban_last_chars` to LocalPaymentCompleted webhook
* Add `edit_paypal_vault_id` to PayPalAccount
* Add `ani_first_name_response_code` and `ani_last_name_response_code` to CreditCardVerification
* Add `shippingTaxAmount` to Transaction
* Add `network_tokenization_attributes` parameter to `Transaction.sale`
* Add validation error code `NetworkTokenizationAttributeCryptogramIsRequired` to `CreditCard`

## 4.29.0
* Add `foreign_retailer` to Transaction
* Add `international_phone` to `Address` and `Customer`
Expand Down
1 change: 1 addition & 0 deletions braintree/error_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class CreditCard(object):
ExpirationYearIsInvalid = "81713"
InvalidParamsForCreditCardUpdate = "91745"
InvalidVenmoSDKPaymentMethodCode = "91727" # NEXT_MJOR_VERSION remove this code
NetworkTokenizationAttributeCryptogramIsRequired = "81762"
NumberHasInvalidLength = NumberLengthIsInvalid = "81716"
NumberIsInvalid = "81715"
NumberIsProhibited = "81750"
Expand Down
289 changes: 155 additions & 134 deletions braintree/transaction.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion braintree/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Version = "4.29.0"
Version = "4.30.0"
5 changes: 4 additions & 1 deletion braintree/webhook_testing_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,8 +1023,11 @@ def __payment_method_revoked_by_customer(self, id):
def __local_payment_completed(self):
return """
<local-payment>
<payment-id>a-payment-id</payment-id>
<bic>a-bic</bic>
<iban-last-chars>1234</iban-last-chars>
<payer-id>a-payer-id</payer-id>
<payer-name>a-payer-name</payer-name>
<payment-id>a-payment-id</payment-id>
<payment-method-nonce>ee257d98-de40-47e8-96b3-a6954ea7a9a4</payment-method-nonce>
<transaction>
<id>1</id>
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.29.0",
version="4.30.0",
description="Braintree Python Library",
long_description=long_description,
author="Braintree",
Expand Down
14 changes: 14 additions & 0 deletions tests/integration/test_credit_card_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,17 @@ def test_verification_with_intended_transaction_source(self):
verification = result.verification
self.assertEqual("1000", verification.processor_response_code)
self.assertEqual(ProcessorResponseTypes.Approved, verification.processor_response_type)

def test_verification_with_ani_response_codes(self):
result = CreditCardVerification.create({
"credit_card": {
"number": CreditCardNumbers.Visa,
"expiration_date": "05/2029",
}
})

self.assertTrue(result.is_success)
verification = result.verification
self.assertEqual("1000", verification.processor_response_code)
self.assertEqual("I", verification.ani_first_name_response_code)
self.assertEqual("I", verification.ani_last_name_response_code)
162 changes: 34 additions & 128 deletions tests/integration/test_merchant.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
class TestMerchantGateway(unittest.TestCase):
def setUp(self):
self.gateway = BraintreeGateway(
client_id="client_id$development$signup_client_id",
client_secret="client_secret$development$signup_client_secret"
client_id="client_id$development$integration_client_id",
client_secret="client_secret$development$integration_client_secret"
)

def test_create_merchant(self):
Expand All @@ -16,18 +16,18 @@ def test_create_merchant(self):

result = gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"country_code_alpha3": "GBR",
"payment_methods": ["credit_card", "paypal"]
})

merchant = result.merchant
self.assertIsNotNone(merchant.id)
self.assertEqual(merchant.email, "name@email.com")
self.assertEqual(merchant.country_code_alpha3, "USA")
self.assertEqual(merchant.country_code_alpha2, "US")
self.assertEqual(merchant.country_code_numeric, "840")
self.assertEqual(merchant.country_name, "United States of America")
self.assertEqual(merchant.company_name, "name@email.com")
self.assertEqual(merchant.email, "name@email.com")
self.assertEqual(merchant.country_code_alpha3, "GBR")
self.assertEqual(merchant.country_code_alpha2, "GB")
self.assertEqual(merchant.country_code_numeric, "826")
self.assertEqual(merchant.country_name, "United Kingdom")
self.assertTrue(result.is_success)

credentials = result.credentials
Expand All @@ -43,7 +43,7 @@ def test_returns_error_with_invalid_payment_methods(self):

result = gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"country_code_alpha3": "GBR",
"payment_methods": ["fake_money"]
})

Expand All @@ -55,63 +55,30 @@ def test_returns_error_with_invalid_payment_methods(self):
self.assertEqual(payment_method_errors[0].code, ErrorCodes.Merchant.PaymentMethodsAreInvalid)

def test_create_paypal_only_merchant_that_accepts_multiple_currencies(self):
result = self.gateway.merchant.create({
gateway = BraintreeGateway(
client_id="client_id$development$integration_client_id",
client_secret="client_secret$development$integration_client_secret"
)

result = gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"country_code_alpha3": "GBR",
"payment_methods": ["paypal"],
"currencies": ["GBP", "USD"],
"paypal_account": {
"client_id": "paypal_client_id",
"client_secret": "paypal_client_secret"
"client_id": "fake_client_id",
"client_secret": "fake_client_secret"
}
})

merchant = result.merchant
self.assertIsNotNone(merchant.id)
self.assertEqual(merchant.email, "name@email.com")
self.assertEqual(merchant.country_code_alpha3, "USA")
self.assertEqual(merchant.country_code_alpha2, "US")
self.assertEqual(merchant.country_code_numeric, "840")
self.assertEqual(merchant.country_name, "United States of America")
self.assertEqual(merchant.company_name, "name@email.com")
self.assertTrue(result.is_success)

credentials = result.credentials
self.assertIsNotNone(credentials.access_token)
self.assertIsNotNone(credentials.expires_at)
self.assertEqual("bearer", credentials.token_type)

merchant_accounts = merchant.merchant_accounts
self.assertEqual(2, len(merchant_accounts))

usd_merchant_account = [ma for ma in merchant_accounts if ma.id == "USD"][0]
self.assertTrue(usd_merchant_account.default)
self.assertEqual(usd_merchant_account.currency_iso_code, "USD")

gbp_merchant_account = [ma for ma in merchant_accounts if ma.id == "GBP"][0]
self.assertFalse(gbp_merchant_account.default)
self.assertEqual(gbp_merchant_account.currency_iso_code, "GBP")

def test_create_us_merchant_that_accepts_multiple_currencies(self):
result = self.gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"payment_methods": ["credit_card", "paypal"],
"currencies": ["GBP", "USD"],
"paypal_account": {
"client_id": "paypal_client_id",
"client_secret": "paypal_client_secret"
}
})

merchant = result.merchant
self.assertIsNotNone(merchant.id)
self.assertEqual(merchant.email, "name@email.com")
self.assertEqual(merchant.country_code_alpha3, "USA")
self.assertEqual(merchant.country_code_alpha2, "US")
self.assertEqual(merchant.country_code_numeric, "840")
self.assertEqual(merchant.country_name, "United States of America")
self.assertEqual(merchant.company_name, "name@email.com")
self.assertEqual(merchant.country_code_alpha3, "GBR")
self.assertEqual(merchant.country_code_alpha2, "GB")
self.assertEqual(merchant.country_code_numeric, "826")
self.assertEqual(merchant.country_name, "United Kingdom")
self.assertTrue(result.is_success)

credentials = result.credentials
Expand All @@ -123,22 +90,27 @@ def test_create_us_merchant_that_accepts_multiple_currencies(self):
self.assertEqual(2, len(merchant_accounts))

usd_merchant_account = [ma for ma in merchant_accounts if ma.id == "USD"][0]
self.assertTrue(usd_merchant_account.default)
self.assertFalse(usd_merchant_account.default)
self.assertEqual(usd_merchant_account.currency_iso_code, "USD")

gbp_merchant_account = [ma for ma in merchant_accounts if ma.id == "GBP"][0]
self.assertFalse(gbp_merchant_account.default)
self.assertTrue(gbp_merchant_account.default)
self.assertEqual(gbp_merchant_account.currency_iso_code, "GBP")

def test_create_eu_merchant_that_accepts_multiple_currencies(self):
result = self.gateway.merchant.create({
gateway = BraintreeGateway(
client_id="client_id$development$integration_client_id",
client_secret="client_secret$development$integration_client_secret"
)

result = gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "GBR",
"payment_methods": ["credit_card", "paypal"],
"currencies": ["GBP", "USD"],
"paypal_account": {
"client_id": "paypal_client_id",
"client_secret": "paypal_client_secret"
"client_id": "fake_client_id",
"client_secret": "fake_client_secret"
}
})

Expand Down Expand Up @@ -168,78 +140,12 @@ def test_create_eu_merchant_that_accepts_multiple_currencies(self):
self.assertTrue(gbp_merchant_account.default)
self.assertEqual(gbp_merchant_account.currency_iso_code, "GBP")

def test_allows_creation_of_non_US_merchant_if_onboarding_application_is_internal(self):
result = self.gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "JPN",
"payment_methods": ["paypal"],
"paypal_account": {
"client_id": "paypal_client_id",
"client_secret": "paypal_client_secret"
}
})

merchant = result.merchant
self.assertIsNotNone(merchant.id)
self.assertEqual(merchant.email, "name@email.com")
self.assertEqual(merchant.country_code_alpha3, "JPN")
self.assertEqual(merchant.country_code_alpha2, "JP")
self.assertEqual(merchant.country_code_numeric, "392")
self.assertEqual(merchant.country_name, "Japan")
self.assertEqual(merchant.company_name, "name@email.com")
self.assertTrue(result.is_success)

credentials = result.credentials
self.assertIsNotNone(credentials.access_token)
self.assertIsNotNone(credentials.expires_at)
self.assertEqual("bearer", credentials.token_type)

merchant_accounts = merchant.merchant_accounts
self.assertEqual(1, len(merchant_accounts))

usd_merchant_account = merchant_accounts[0]
self.assertTrue(usd_merchant_account.default)
self.assertEqual(usd_merchant_account.currency_iso_code, "JPY")

def test_defaults_to_USD_for_non_US_merchant_if_onboarding_application_is_internal_and_country_currency_not_supported(self):
result = self.gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "YEM",
"payment_methods": ["paypal"],
"paypal_account": {
"client_id": "paypal_client_id",
"client_secret": "paypal_client_secret"
}
})

merchant = result.merchant
self.assertIsNotNone(merchant.id)
self.assertEqual(merchant.email, "name@email.com")
self.assertEqual(merchant.country_code_alpha3, "YEM")
self.assertEqual(merchant.country_code_alpha2, "YE")
self.assertEqual(merchant.country_code_numeric, "887")
self.assertEqual(merchant.country_name, "Yemen")
self.assertEqual(merchant.company_name, "name@email.com")
self.assertTrue(result.is_success)

credentials = result.credentials
self.assertIsNotNone(credentials.access_token)
self.assertIsNotNone(credentials.expires_at)
self.assertEqual("bearer", credentials.token_type)

merchant_accounts = merchant.merchant_accounts
self.assertEqual(1, len(merchant_accounts))

usd_merchant_account = merchant_accounts[0]
self.assertTrue(usd_merchant_account.default)
self.assertEqual(usd_merchant_account.currency_iso_code, "USD")

def test_returns_error_if_invalid_currency_is_passed(self):
result = self.gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"country_code_alpha3": "GBR",
"payment_methods": ["credit_card"],
"currencies": ["GBP", "FAKE"],
"currencies": ["USD", "FAKE"],
"paypal_account": {
"client_id": "paypal_client_id",
"client_secret": "paypal_client_secret"
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/test_merchant_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def test_returns_merchant_account_with_correct_attributes(self):

result = gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"country_code_alpha3": "GBR",
"payment_methods": ["credit_card", "paypal"]
})

Expand All @@ -391,7 +391,7 @@ def test_returns_merchant_account_with_correct_attributes(self):
self.assertEqual(len(merchant_accounts), 1)

merchant_account = merchant_accounts[0]
self.assertEqual(merchant_account.currency_iso_code, "USD")
self.assertEqual(merchant_account.currency_iso_code, "GBP")
self.assertEqual(merchant_account.status, MerchantAccount.Status.Active)
self.assertTrue(merchant_account.default)

Expand All @@ -407,7 +407,7 @@ def test_merchant_account_create_for_currency(self):

result = self.gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"country_code_alpha3": "GBR",
"payment_methods": ["credit_card", "paypal"]
})

Expand All @@ -416,12 +416,12 @@ def test_merchant_account_create_for_currency(self):
)

result = gateway.merchant_account.create_for_currency({
"currency": "GBP",
"currency": "USD",
"id": "custom_id"
})

self.assertTrue(result.is_success)
self.assertEqual(result.merchant_account.currency_iso_code, "GBP")
self.assertEqual(result.merchant_account.currency_iso_code, "USD")
self.assertEqual(result.merchant_account.id, "custom_id")

def test_merchant_account_create_for_currency_handles_invalid_currency(self):
Expand All @@ -432,7 +432,7 @@ def test_merchant_account_create_for_currency_handles_invalid_currency(self):

result = self.gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"country_code_alpha3": "GBR",
"payment_methods": ["credit_card", "paypal"]
})

Expand All @@ -455,7 +455,7 @@ def test_merchant_account_create_for_currency_handles_currency_requirement(self)

result = self.gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"country_code_alpha3": "GBR",
"payment_methods": ["credit_card", "paypal"]
})

Expand All @@ -476,7 +476,7 @@ def test_merchant_account_create_for_currency_merchant_account_already_existing_

result = self.gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"country_code_alpha3": "GBR",
"payment_methods": ["credit_card", "paypal"]
})

Expand All @@ -485,7 +485,7 @@ def test_merchant_account_create_for_currency_merchant_account_already_existing_
)

result = gateway.merchant_account.create_for_currency({
"currency": "USD",
"currency": "GBP",
})

self.assertFalse(result.is_success)
Expand All @@ -499,7 +499,7 @@ def test_merchant_account_create_for_currency_merchant_account_already_existing_

result = self.gateway.merchant.create({
"email": "name@email.com",
"country_code_alpha3": "USA",
"country_code_alpha3": "GBR",
"payment_methods": ["credit_card", "paypal"]
})

Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_paypal_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def test_find_returns_paypal_account(self):
self.assertNotEqual(None, found_account.image_url)
self.assertNotEqual(None, found_account.created_at)
self.assertNotEqual(None, found_account.updated_at)
self.assertIsNone(found_account.funding_source_description)
self.assertIsNone(found_account.funding_source_description)
self.assertFalse(hasattr(found_account, "edit_paypal_vault_id"))
self.assertIsNone(found_account.revoked_at)

def test_find_raises_on_not_found_token(self):
Expand Down
Loading

0 comments on commit ca488de

Please sign in to comment.