Skip to content

Commit d2eaf7c

Browse files
committed
3.46.0
1 parent c2b73ee commit d2eaf7c

12 files changed

+174
-37
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.46.0
2+
* Allow payee ID to be passed in options params for transaction create
3+
* Add `merchant_id` alias to ConnectedMerchantStatusTransitioned and ConnectedMerchantPayPalStatusChanged Auth webhooks
4+
15
## 3.45.0
26
* Add support for US Bank Account verifications API
37

braintree/connected_merchant_paypal_status_changed.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ class ConnectedMerchantPayPalStatusChanged(Resource):
44

55
def __init__(self, gateway, attributes):
66
Resource.__init__(self, gateway, attributes)
7+
8+
@property
9+
def merchant_id(self):
10+
return self.merchant_public_id

braintree/connected_merchant_status_transitioned.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ class ConnectedMerchantStatusTransitioned(Resource):
44

55
def __init__(self, gateway, attributes):
66
Resource.__init__(self, gateway, attributes)
7+
8+
@property
9+
def merchant_id(self):
10+
return self.merchant_public_id

braintree/disbursement.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
from braintree.merchant_account import MerchantAccount
55

66
class Disbursement(Resource):
7+
class Type(object):
8+
"""
9+
"""
10+
11+
Credit = "credit"
12+
Debit = "debit"
13+
714
def __init__(self, gateway, attributes):
815
Resource.__init__(self, gateway, attributes)
916
self.amount = Decimal(self.amount)
@@ -16,4 +23,8 @@ def __repr__(self):
1623
def transactions(self):
1724
return self.gateway.transaction.search([TransactionSearch.ids.in_list(self.transaction_ids)])
1825

26+
def is_credit(self):
27+
return self.disbursement_type == Disbursement.Type.Credit
1928

29+
def is_debit(self):
30+
return self.disbursement_type == Disbursement.Type.Debit

braintree/error_codes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ class Transaction(object):
584584
UnsupportedVoiceAuthorization = "91539"
585585
UsBankAccountNonceMustBePlaidVerified = "915171"
586586
UsBankAccountNotVerified = "915172"
587+
TransactionSourceIsInvalid = "915133"
587588

588589
class Options(object):
589590
SubmitForSettlementIsRequiredForCloning = "91544"

braintree/transaction.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,14 @@ def create_signature():
553553
"store_shipping_address_in_vault",
554554
"submit_for_settlement",
555555
"venmo_sdk_session",
556+
"payee_id",
556557
"payee_email",
557558
"skip_advanced_fraud_checking",
558559
"skip_avs",
559560
"skip_cvv",
560561
{
561562
"paypal": [
563+
"payee_id",
562564
"payee_email",
563565
"custom_field",
564566
"description",
@@ -593,7 +595,7 @@ def create_signature():
593595
},
594596
{"custom_fields": ["__any_key__"]},
595597
{"descriptor": ["name", "phone", "url"]},
596-
{"paypal_account": ["payee_email"]},
598+
{"paypal_account": ["payee_id", "payee_email"]},
597599
{"industry":
598600
[
599601
"industry_type",

braintree/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Version = "3.45.0"
1+
Version = "3.46.0"

braintree/webhook_testing_gateway.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __subject_sample_xml(self, kind, id):
5959
elif kind == WebhookNotification.Kind.PartnerMerchantDeclined:
6060
return self.__partner_merchant_declined_sample_xml()
6161
elif kind == WebhookNotification.Kind.OAuthAccessRevoked:
62-
return self.__oauth_access_revocation_sample_xml()
62+
return self.__oauth_access_revocation_sample_xml(id)
6363
elif kind == WebhookNotification.Kind.DisbursementException:
6464
return self.__disbursement_exception_sample_xml(id)
6565
elif kind == WebhookNotification.Kind.Disbursement:
@@ -536,12 +536,13 @@ def __partner_merchant_declined_sample_xml(self):
536536
</partner-merchant>
537537
"""
538538

539-
def __oauth_access_revocation_sample_xml(self):
539+
def __oauth_access_revocation_sample_xml(self, id):
540540
return """
541541
<oauth-application-revocation>
542-
<merchant-id>abc123</merchant-id>
542+
<merchant-id>%s</merchant-id>
543+
<oauth-application-client-id>oauth_application_client_id</oauth-application-client-id>
543544
</oauth-application-revocation>
544-
"""
545+
""" % id
545546

546547
def __account_updater_daily_report_sample_xml(self):
547548
return """

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name="braintree",
15-
version="3.45.0",
15+
version="3.46.0",
1616
description="Braintree Python Library",
1717
long_description=long_description,
1818
author="Braintree",

tests/integration/test_transaction.py

Lines changed: 105 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,10 +2203,6 @@ def test_card_type_indicators(self):
22032203
def test_create_can_set_recurring_flag(self):
22042204
result = Transaction.sale({
22052205
"amount": "100",
2206-
"customer": {
2207-
"first_name": "Adam",
2208-
"last_name": "Williams"
2209-
},
22102206
"credit_card": {
22112207
"number": "4111111111111111",
22122208
"expiration_date": "05/2009"
@@ -2218,13 +2214,23 @@ def test_create_can_set_recurring_flag(self):
22182214
transaction = result.transaction
22192215
self.assertEqual(True, transaction.recurring)
22202216

2221-
def test_create_can_set_transaction_source_flag_recurring(self):
2217+
def test_create_can_set_transaction_source_flag_recurring_first(self):
22222218
result = Transaction.sale({
22232219
"amount": "100",
2224-
"customer": {
2225-
"first_name": "Adam",
2226-
"last_name": "Williams"
2220+
"credit_card": {
2221+
"number": "4111111111111111",
2222+
"expiration_date": "05/2009"
22272223
},
2224+
"transaction_source": "recurring_first"
2225+
})
2226+
2227+
self.assertTrue(result.is_success)
2228+
transaction = result.transaction
2229+
self.assertEqual(True, transaction.recurring)
2230+
2231+
def test_create_can_set_transaction_source_flag_recurring(self):
2232+
result = Transaction.sale({
2233+
"amount": "100",
22282234
"credit_card": {
22292235
"number": "4111111111111111",
22302236
"expiration_date": "05/2009"
@@ -2236,13 +2242,23 @@ def test_create_can_set_transaction_source_flag_recurring(self):
22362242
transaction = result.transaction
22372243
self.assertEqual(True, transaction.recurring)
22382244

2239-
def test_create_can_set_transaction_source_flag_moto(self):
2245+
def test_create_can_set_transaction_source_flag_merchant(self):
22402246
result = Transaction.sale({
22412247
"amount": "100",
2242-
"customer": {
2243-
"first_name": "Adam",
2244-
"last_name": "Williams"
2248+
"credit_card": {
2249+
"number": "4111111111111111",
2250+
"expiration_date": "05/2009"
22452251
},
2252+
"transaction_source": "merchant"
2253+
})
2254+
2255+
self.assertTrue(result.is_success)
2256+
transaction = result.transaction
2257+
self.assertEqual(False, transaction.recurring)
2258+
2259+
def test_create_can_set_transaction_source_flag_moto(self):
2260+
result = Transaction.sale({
2261+
"amount": "100",
22462262
"credit_card": {
22472263
"number": "4111111111111111",
22482264
"expiration_date": "05/2009"
@@ -2254,6 +2270,22 @@ def test_create_can_set_transaction_source_flag_moto(self):
22542270
transaction = result.transaction
22552271
self.assertEqual(False, transaction.recurring)
22562272

2273+
def test_create_can_set_transaction_source_flag_invalid(self):
2274+
result = Transaction.sale({
2275+
"amount": "100",
2276+
"credit_card": {
2277+
"number": "4111111111111111",
2278+
"expiration_date": "05/2009"
2279+
},
2280+
"transaction_source": "invalid_value"
2281+
})
2282+
2283+
self.assertFalse(result.is_success)
2284+
self.assertEqual(
2285+
ErrorCodes.Transaction.TransactionSourceIsInvalid,
2286+
result.errors.for_object("transaction").on("transaction_source")[0].code
2287+
)
2288+
22572289
def test_create_can_store_customer_and_credit_card_in_the_vault(self):
22582290
result = Transaction.sale({
22592291
"amount": "100",
@@ -4054,6 +4086,67 @@ def test_creating_paypal_transaction_with_one_time_use_nonce(self):
40544086
self.assertNotEqual(None, transaction.paypal_details.image_url)
40554087
self.assertNotEqual(None, transaction.paypal_details.debug_id)
40564088

4089+
def test_creating_paypal_transaction_with_payee_id(self):
4090+
result = Transaction.sale({
4091+
"amount": TransactionAmounts.Authorize,
4092+
"payment_method_nonce": Nonces.PayPalOneTimePayment,
4093+
"paypal_account": {
4094+
"payee_id": "fake-payee-id"
4095+
}
4096+
})
4097+
4098+
self.assertTrue(result.is_success)
4099+
transaction = result.transaction
4100+
4101+
self.assertEqual(transaction.paypal_details.payer_email, "payer@example.com")
4102+
self.assertNotEqual(None, re.search(r'PAY-\w+', transaction.paypal_details.payment_id))
4103+
self.assertNotEqual(None, re.search(r'AUTH-\w+', transaction.paypal_details.authorization_id))
4104+
self.assertNotEqual(None, transaction.paypal_details.image_url)
4105+
self.assertNotEqual(None, transaction.paypal_details.debug_id)
4106+
self.assertEqual(transaction.paypal_details.payee_id, "fake-payee-id")
4107+
4108+
def test_creating_paypal_transaction_with_payee_id_in_options_params(self):
4109+
result = Transaction.sale({
4110+
"amount": TransactionAmounts.Authorize,
4111+
"payment_method_nonce": Nonces.PayPalOneTimePayment,
4112+
"paypal_account": {},
4113+
"options": {
4114+
"payee_id": "fake-payee-id"
4115+
}
4116+
})
4117+
4118+
self.assertTrue(result.is_success)
4119+
transaction = result.transaction
4120+
4121+
self.assertEqual(transaction.paypal_details.payer_email, "payer@example.com")
4122+
self.assertNotEqual(None, re.search(r'PAY-\w+', transaction.paypal_details.payment_id))
4123+
self.assertNotEqual(None, re.search(r'AUTH-\w+', transaction.paypal_details.authorization_id))
4124+
self.assertNotEqual(None, transaction.paypal_details.image_url)
4125+
self.assertNotEqual(None, transaction.paypal_details.debug_id)
4126+
self.assertEqual(transaction.paypal_details.payee_id, "fake-payee-id")
4127+
4128+
def test_creating_paypal_transaction_with_payee_id_in_options_paypal_params(self):
4129+
result = Transaction.sale({
4130+
"amount": TransactionAmounts.Authorize,
4131+
"payment_method_nonce": Nonces.PayPalOneTimePayment,
4132+
"paypal_account": {},
4133+
"options": {
4134+
"paypal": {
4135+
"payee_id": "fake-payee-id"
4136+
}
4137+
}
4138+
})
4139+
4140+
self.assertTrue(result.is_success)
4141+
transaction = result.transaction
4142+
4143+
self.assertEqual(transaction.paypal_details.payer_email, "payer@example.com")
4144+
self.assertNotEqual(None, re.search(r'PAY-\w+', transaction.paypal_details.payment_id))
4145+
self.assertNotEqual(None, re.search(r'AUTH-\w+', transaction.paypal_details.authorization_id))
4146+
self.assertNotEqual(None, transaction.paypal_details.image_url)
4147+
self.assertNotEqual(None, transaction.paypal_details.debug_id)
4148+
self.assertEqual(transaction.paypal_details.payee_id, "fake-payee-id")
4149+
40574150
def test_creating_paypal_transaction_with_payee_email(self):
40584151
result = Transaction.sale({
40594152
"amount": TransactionAmounts.Authorize,

0 commit comments

Comments
 (0)