Skip to content

Commit

Permalink
4.29.0
Browse files Browse the repository at this point in the history
Co-authored-by: Sara Vasquez <[email protected]>
  • Loading branch information
braintreeps and saralvasquez committed Jul 23, 2024
1 parent 81f2b2b commit 9dc4bff
Show file tree
Hide file tree
Showing 23 changed files with 382 additions and 64 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 4.29.0
* Add `foreign_retailer` to Transaction
* Add `international_phone` to `Address` and `Customer`
* Add `funding_source_description` to PayPalAccount
* Add missing `AndroidPayCard` error code
* Add `REFUND_FAILED` to `WebhookNotification.Kind`
* Add `final_capture` to Transaction `submit_for_partial_settlement_signature`
* Deprecate `paypal_tracking_id` in favor of `paypal_tracker_id` in `package_details`

## 4.28.0
* Add `domains` parameter support to `ClientToken.generate`

Expand Down
64 changes: 64 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!groovy
def FAILED_STAGE

pipeline {
agent none

environment {
REPO_NAME = "braintree-python"
SLACK_CHANNEL = "#auto-team-sdk-builds"
}

stages {
stage("Audit") {
parallel {

// Runs a static code analysis scan and posts results to the PayPal Polaris server
stage("Polaris") {
agent {
node {
label ""
customWorkspace "workspace/${REPO_NAME}"
}
}

steps {
polarisAudit()
}

post {
failure {
script {
FAILED_STAGE = env.STAGE_NAME
}
}
}
}


// Runs a software composition analysis scan and posts results to the PayPal Black Duck server
stage("Black Duck") {
agent {
node {
label ""
customWorkspace "workspace/${REPO_NAME}"
}
}

steps {
blackduckAudit(debug: "true")
}

post {
failure {
script {
FAILED_STAGE = env.STAGE_NAME
}
}
}
}
}
}
}
}

22 changes: 14 additions & 8 deletions braintree/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ class Address(Resource):
customer = braintree.Customer.create().customer
result = braintree.Address.create({
"company": "Braintree",
"country_name": "United States of America",
"customer_id": customer.id,
"extended_address": "Apartment 1",
"first_name": "John",
"international_phone": { "country_code": "1", "national_number": "3121234567" },
"last_name": "Doe",
"company": "Braintree",
"street_address": "111 First Street",
"extended_address": "Apartment 1",
"locality": "Chicago",
"region": "IL",
"phone_number": "312-123-4567",
"postal_code": "60606",
"country_name": "United States of America"
"region": "IL",
"street_address": "111 First Street"
})
print(result.customer.first_name)
Expand All @@ -29,20 +31,22 @@ class Address(Resource):

def __repr__(self):
detail_list = [
"customer_id",
"company",
"country_code_alpha2",
"country_code_alpha3",
"country_code_numeric",
"country_name",
"customer_id",
"extended_address",
"first_name",
"international_phone",
"last_name",
"locality",
"phone_number",
"postal_code",
"region",
"street_address",
"shipping_method",
"street_address"
]
return super(Address, self).__repr__(detail_list)

Expand Down Expand Up @@ -130,7 +134,9 @@ def update(customer_id, address_id, params=None):
def create_signature():
return ["company", "country_code_alpha2", "country_code_alpha3", "country_code_numeric",
"country_name", "customer_id", "extended_address", "first_name",
"last_name", "locality", "phone_number", "postal_code", "region", "street_address"]
{"international_phone": ["country_code", "national_number"]},
"last_name", "locality", "phone_number",
"postal_code", "region", "street_address"]

@staticmethod
def update_signature():
Expand Down
60 changes: 34 additions & 26 deletions braintree/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,42 @@ class Customer(Resource):
An example of creating an customer with all available fields::
result = braintree.Customer.create({
"id": "my_customer_id",
"company": "Some company",
"email": "[email protected]",
"fax": "123-555-1212",
"first_name": "John",
"last_name": "Doe",
"phone": "123-555-1221",
"website": "http://www.example.com",
"credit_card": {
"cardholder_name": "John Doe",
"cvv": "123",
"expiration_date": "12/2012",
"number": "4111111111111111",
"token": "my_token",
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"company": "Braintree",
"street_address": "111 First Street",
"country_name": "United States of America",
"extended_address": "Unit 1",
"first_name": "John",
"international_phone": { "country_code": "1", "national_number": "3121234567" },
"last_name": "Doe",
"locality": "Chicago",
"phone_number": "312-123-4567",
"postal_code": "60606",
"region": "IL",
"country_name": "United States of America"
"phone_number": "312-123-4567"
"street_address": "111 First Street"
},
"cardholder_name": "John Doe",
"cvv": "123",
"expiration_date": "12/2012",
"number": "4111111111111111",
"options": {
"verify_card": True,
"verification_amount": "2.00"
}
"verification_amount": "2.00",
"verify_card": True
},
"token": "my_token"
},
"custom_fields": {
"my_key": "some value"
}
},
"email": "[email protected]",
"fax": "123-555-1212",
"first_name": "John",
"id": "my_customer_id",
"international_phone": { "country_code": "1", "national_number": "3121234567" },
"last_name": "Doe",
"phone": "123-555-1221",
"website": "http://www.example.com"
})
print(result.customer.id)
Expand All @@ -74,18 +76,19 @@ class Customer(Resource):

def __repr__(self):
detail_list = [
"id",
"graphql_id",
"company",
"created_at",
"email",
"fax",
"first_name",
"graphql_id",
"id",
"international_phone",
"last_name",
"merchant_id",
"phone",
"updated_at",
"website",
"website"
]

return super(Customer, self).__repr__(detail_list)
Expand Down Expand Up @@ -160,7 +163,9 @@ def update(customer_id, params=None):
@staticmethod
def create_signature():
return [
"company", "email", "fax", "first_name", "id", "last_name", "phone", "website", "device_data", "payment_method_nonce",
"company", "email", "fax", "first_name", "id",
{"international_phone": ["country_code", "national_number"]},
"last_name", "phone", "website", "device_data", "payment_method_nonce",
"device_session_id", "fraud_merchant_id", # NEXT_MAJOR_VERSION remove device_session_id and fraud_merchant_id
{"risk_data": ["customer_browser", "customer_device_id", "customer_ip", "customer_location_zip", "customer_tenure"]},
{"credit_card": CreditCard.create_signature()},
Expand Down Expand Up @@ -189,7 +194,10 @@ def create_signature():
@staticmethod
def update_signature():
return [
"company", "email", "fax", "first_name", "id", "last_name", "phone", "website", "device_data", "device_session_id", "fraud_merchant_id", "payment_method_nonce", "default_payment_method_token",
"company", "email", "fax", "first_name", "id",
{"international_phone": ["country_code", "national_number"]},
"last_name", "phone", "website", "device_data", "device_session_id",
"fraud_merchant_id", "payment_method_nonce", "default_payment_method_token",
{"credit_card": CreditCard.signature("update_via_customer")},
{"apple_pay_card": ApplePayCard.signature()},
{"android_pay_card": AndroidPayCard.card_signature()},
Expand Down
3 changes: 3 additions & 0 deletions braintree/error_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Address(object):
StreetAddressIsTooLong = "81812"
TooManyAddressesPerCustomer = "91818"

class AndroidPay(object):
AndroidPayCardsAreNotAccepted = "83708"

class ApplePay(object):
ApplePayCardsAreNotAccepted = "83501"
CustomerIdIsRequiredForVaulting = "83502"
Expand Down
4 changes: 4 additions & 0 deletions braintree/package_details.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from braintree.attribute_getter import AttributeGetter
from warnings import warn

class PackageDetails(AttributeGetter):
"""
Expand All @@ -11,14 +12,17 @@ class PackageDetails(AttributeGetter):
"carrier": "a_carrier",
"tracking_number": "my_tracking_number",
"paypal_tracking_id": "my_paypal_tracking_id",
"paypal_tracker_id": "my_paypal_tracker_id",
})
"""
detail_list = [
"id",
"carrier",
"tracking_number",
# NEXT_MAJOR_VERSION remove paypal_tracking_id
"paypal_tracking_id",
"paypal_tracker_id",
]

def __init__(self, attributes):
Expand Down
51 changes: 32 additions & 19 deletions braintree/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,30 @@ class Transaction(Resource):
"website": "https://www.braintreepayments.com"
},
"billing": {
"first_name": "Carl",
"last_name": "Jones",
"company": "Braintree",
"street_address": "123 E Main St",
"country_name": "United States of America",
"extended_address": "Suite 403",
"first_name": "Carl",
"international_phone": { "country_code": "1", "national_number": "3121234567" },
"last_name": "Jones",
"locality": "Chicago",
"region": "IL",
"phone_number": "312-123-4567",
"postal_code": "60622",
"country_name": "United States of America"
"phone_number": "312-123-4567"
"region": "IL",
"street_address": "123 E Main St"
},
"shipping": {
"first_name": "Andrew",
"last_name": "Mason",
"company": "Braintree",
"street_address": "456 W Main St",
"country_name": "United States of America",
"extended_address": "Apt 2F",
"first_name": "Andrew",
"international_phone": { "country_code": "1", "national_number": "3121234567" },
"last_name": "Mason",
"locality": "Bartlett",
"region": "IL",
"phone_number": "312-123-4567",
"postal_code": "60103",
"country_name": "United States of America"
"phone_number": "312-123-4567"
"region": "IL",
"street_address": "456 W Main St"
}
})
Expand Down Expand Up @@ -122,6 +124,7 @@ def __repr__(self):
"discount_amount",
"disputes",
"escrow_status",
"foreign_retailer",
"gateway_rejection_reason",
"installments",
"liability_shift",
Expand Down Expand Up @@ -533,7 +536,7 @@ def create_signature():
"discount_amount", "shipping_amount", "ships_from_postal_code",
"tax_exempt", "three_d_secure_authentication_id", "three_d_secure_token", # NEXT_MAJOR_VERSION Remove three_d_secure_token
"type", "venmo_sdk_payment_method_code", # NEXT_MJOR_VERSION remove venmo_sdk_payment_method_code
"service_fee_amount", "sca_exemption","exchange_rate_quote_id",
"service_fee_amount", "sca_exemption","exchange_rate_quote_id", "foreign_retailer",
"device_session_id", "fraud_merchant_id", # NEXT_MAJOR_VERSION remove device_session_id and fraud_merchant_id
{
"risk_data": [
Expand All @@ -553,16 +556,20 @@ def create_signature():
},
{
"billing": [
"first_name", "last_name", "company", "country_code_alpha2", "country_code_alpha3",
"country_code_numeric", "country_name", "extended_address", "locality",
"phone_number", "postal_code", "region", "street_address"
"company", "country_code_alpha2", "country_code_alpha3",
"country_code_numeric", "country_name", "extended_address", "first_name",
{"international_phone": ["country_code", "national_number"]},
"last_name", "locality", "phone_number",
"postal_code", "region", "street_address"
]
},
{
"shipping": [
"first_name", "last_name", "company", "country_code_alpha2", "country_code_alpha3",
"country_code_numeric", "country_name", "extended_address", "locality",
"phone_number", "postal_code", "region", "shipping_method", "street_address"
"company", "country_code_alpha2", "country_code_alpha3",
"country_code_numeric", "country_name", "extended_address", "first_name",
{"international_phone": ["country_code", "national_number"]},
"last_name", "locality", "phone_number",
"postal_code", "region", "shipping_method", "street_address"
]
},
{
Expand Down Expand Up @@ -747,6 +754,12 @@ def submit_for_settlement_signature():
},
]

@staticmethod
def submit_for_partial_settlement_signature():
return Transaction.submit_for_settlement_signature() + [
"final_capture"
]

@staticmethod
def package_tracking_signature():
return [ "carrier", "notify_payer", "tracking_number",
Expand Down
2 changes: 1 addition & 1 deletion braintree/transaction_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def update_details(self, transaction_id, params=None):
def submit_for_partial_settlement(self, transaction_id, amount, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Transaction.submit_for_settlement_signature())
Resource.verify_keys(params, Transaction.submit_for_partial_settlement_signature())
transaction_params = {"amount": amount}
transaction_params.update(params)
response = self.config.http().post(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/submit_for_partial_settlement",
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.28.0"
Version = "4.29.0"
Loading

0 comments on commit 9dc4bff

Please sign in to comment.