Skip to content

Commit 97fa543

Browse files
braintreepsrgurumurthiklaguerrePay
committed
4.34.0
Co-authored-by: Rajaram Gurumurthi <[email protected]> Co-authored-by: Kevin Laguerre <[email protected]>
1 parent 7997061 commit 97fa543

26 files changed

+582
-93
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
## 4.34.0
3+
* Add prepaid_reloadable from bin data in credit card responses
4+
* Add support for `PayPalPaymentResource` requests
25

36
## 4.33.1
47
* Fixes issue related to missing folders in package paths

Jenkinsfile

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!groovy
2+
23
def FAILED_STAGE
34

45
pipeline {
@@ -12,9 +13,8 @@ pipeline {
1213
stages {
1314
stage("Audit") {
1415
parallel {
15-
1616
// Runs a static code analysis scan and posts results to the PayPal Polaris server
17-
stage("Polaris") {
17+
stage("CodeQL") {
1818
agent {
1919
node {
2020
label ""
@@ -23,7 +23,7 @@ pipeline {
2323
}
2424

2525
steps {
26-
polarisAudit()
26+
codeQLv2(python: true)
2727
}
2828

2929
post {
@@ -34,31 +34,7 @@ pipeline {
3434
}
3535
}
3636
}
37-
38-
39-
// Runs a software composition analysis scan and posts results to the PayPal Black Duck server
40-
stage("Black Duck") {
41-
agent {
42-
node {
43-
label ""
44-
customWorkspace "workspace/${REPO_NAME}"
45-
}
46-
}
47-
48-
steps {
49-
blackduckAudit(debug: "true")
50-
}
51-
52-
post {
53-
failure {
54-
script {
55-
FAILED_STAGE = env.STAGE_NAME
56-
}
57-
}
58-
}
59-
}
6037
}
61-
}
38+
}
6239
}
6340
}
64-

braintree/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from braintree.payment_method_nonce import PaymentMethodNonce
5151
from braintree.payment_method_parser import parse_payment_method
5252
from braintree.paypal_account import PayPalAccount
53+
from braintree.paypal_payment_resource import PayPalPaymentResource
5354
from braintree.plan import Plan
5455
from braintree.plan_gateway import PlanGateway
5556
from braintree.processor_response_types import ProcessorResponseTypes

braintree/braintree_gateway.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from braintree.payment_method_gateway import PaymentMethodGateway
1818
from braintree.payment_method_nonce_gateway import PaymentMethodNonceGateway
1919
from braintree.paypal_account_gateway import PayPalAccountGateway
20+
from braintree.paypal_payment_resource_gateway import PayPalPaymentResourceGateway
2021
from braintree.sepa_direct_debit_account_gateway import SepaDirectDebitAccountGateway
2122
from braintree.plan_gateway import PlanGateway
2223
from braintree.settlement_batch_summary_gateway import SettlementBatchSummaryGateway
@@ -60,6 +61,7 @@ def __init__(self, config=None, **kwargs):
6061
self.payment_method = PaymentMethodGateway(self)
6162
self.payment_method_nonce = PaymentMethodNonceGateway(self)
6263
self.paypal_account = PayPalAccountGateway(self)
64+
self.paypal_payment_resource = PayPalPaymentResourceGateway(self)
6365
self.plan = PlanGateway(self)
6466
self.sepa_direct_debit_account = SepaDirectDebitAccountGateway(self)
6567
self.settlement_batch_summary = SettlementBatchSummaryGateway(self)

braintree/credit_card.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ class DebitNetwork(Enum):
127127
Star = "STAR"
128128
Star_Access = "STAR_ACCESS"
129129

130-
Commercial = DurbinRegulated = Debit = Healthcare = \
131-
CountryOfIssuance = IssuingBank = Payroll = Prepaid = ProductId = CardTypeIndicator
130+
Commercial = CountryOfIssuance = Debit = DurbinRegulated = \
131+
Healthcare = IssuingBank = Payroll = Prepaid = PrepaidReloadable = ProductId = CardTypeIndicator
132132

133133
@staticmethod
134134
def create(params=None):

braintree/error_codes.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,46 @@ class PayPalAccount(object):
412412
PaymentMethodNonceUnknown = "92908"
413413
TokenIsInUse = "92906"
414414

415+
class PayPalPaymentResource(object):
416+
NonceExpired = "97301"
417+
IdNotSupported = "97302"
418+
NonceRequired = "97303"
419+
InvalidEmail = "97304"
420+
EmailTooLong = "97305"
421+
ExpectedLineItemCollection = "97306"
422+
ExpectedLineItemHash = "97307"
423+
ExpectedLineItemDebit = "97308"
424+
InvalidUnitAmount = "97309"
425+
InvalidUnitTaxAmount = "97310"
426+
IsoCodeRequired = "97311"
427+
IsoCodeUnsupported = "97312"
428+
ShippingFieldsMissing = "97313"
429+
InvalidAmountBreakdown = "97314"
430+
ExpectedShippingOptionCollection = "97315"
431+
ShippingOptionsRequired = "97316"
432+
ShippingOptionFieldsMissing = "97317"
433+
InvalidShippingOptionType = "97318"
434+
ShippingOptionIdReused = "97319"
435+
TooManyShippingOptionsSelected = "97320"
436+
ShippingOptionMustMatchBreakdown = "97321"
437+
LineItemsShouldMatchTotal = "97322"
438+
LineItemsTaxShouldMatchTotal = "97323"
439+
PatchCallFailed = "97324"
440+
InvalidAmount = "97325"
441+
ShippingIdTooLong = "97326"
442+
ShippingLabelTooLong = "97327"
443+
ShippingFullNameTooLong = "97328"
444+
ShippingAddressTooLong = "97329"
445+
ShippingExtendedAddressTooLong = "97330"
446+
ShippingLocalityTooLong = "97331"
447+
ShippingRegionTooLong = "97332"
448+
CountryCodeTooLong = "97333"
449+
NationalNumberTooLong = "97334"
450+
PostalCodeTooLong = "97335"
451+
DescriptionTooLong = "97336"
452+
CustomFieldTooLong = "97337"
453+
OrderIdTooLong = "97338"
454+
415455
class SettlementBatchSummary(object):
416456
CustomFieldIsInvalid = "82303"
417457
SettlementDateIsInvalid = "82302"
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import braintree
2+
from braintree.resource import Resource
3+
from braintree.configuration import Configuration
4+
5+
class PayPalPaymentResource(Resource):
6+
@staticmethod
7+
def update(request):
8+
return Configuration.gateway().paypal_payment_resource.update(request)
9+
10+
@staticmethod
11+
def update_signature():
12+
amount_breakdown = [
13+
"discount",
14+
"handling",
15+
"insurance",
16+
"item_total",
17+
"shipping",
18+
"shipping_discount",
19+
"tax_total"
20+
]
21+
22+
line_item = [
23+
"commodity_code",
24+
"description",
25+
"discount_amount",
26+
"image_url",
27+
"kind",
28+
"name",
29+
"product_code",
30+
"quantity",
31+
"tax_amount",
32+
"total_amount",
33+
"unit_amount",
34+
"unit_of_measure",
35+
"unit_tax_amount",
36+
"upc_code",
37+
"upc_type",
38+
"url",
39+
]
40+
41+
shipping_request = [
42+
"company",
43+
"country_name",
44+
"country_code_alpha2",
45+
"country_code_alpha3",
46+
"country_code_numeric",
47+
"extended_address",
48+
"first_name",
49+
{
50+
"international_phone": [
51+
"country_code",
52+
"national_number"
53+
]
54+
},
55+
"last_name",
56+
"locality",
57+
"postal_code",
58+
"region",
59+
"street_address"
60+
]
61+
62+
shipping_option = [
63+
"amount",
64+
"id",
65+
"label",
66+
"selected",
67+
"type"
68+
]
69+
70+
signature = [
71+
{
72+
"paypal_payment_resource": [
73+
"amount",
74+
{
75+
"amount_breakdown": amount_breakdown
76+
},
77+
"currency_iso_code",
78+
"custom_field",
79+
"description",
80+
{
81+
"line_items": line_item
82+
},
83+
"order_id",
84+
"payee_email",
85+
"payment_method_nonce",
86+
{
87+
"shipping": shipping_request
88+
},
89+
{
90+
"shipping_options": shipping_option
91+
}
92+
]
93+
}
94+
]
95+
return signature
96+
97+
def __init__(self, gateway, attributes):
98+
Resource.__init__(self, gateway, attributes)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from braintree.resource import Resource
2+
from braintree.paypal_payment_resource import PayPalPaymentResource
3+
from braintree.payment_method_nonce import PaymentMethodNonce
4+
from braintree.util.xml_util import XmlUtil
5+
from braintree.error_result import ErrorResult
6+
from braintree.successful_result import SuccessfulResult
7+
from braintree.exceptions.unexpected_error import UnexpectedError
8+
9+
class PayPalPaymentResourceGateway(object):
10+
def __init__(self, gateway):
11+
self.gateway = gateway
12+
self.config = gateway.config
13+
14+
def update(self, params):
15+
Resource.verify_keys(params, PayPalPaymentResource.update_signature())
16+
17+
response = self.config.http().put(
18+
self.config.base_merchant_path() + "/paypal/payment_resource",
19+
params
20+
)
21+
22+
if "payment_method_nonce" in response:
23+
return SuccessfulResult({"payment_method_nonce": PaymentMethodNonce(self.gateway, response["payment_method_nonce"])})
24+
elif "api_error_response" in response:
25+
return ErrorResult(self.gateway, response["api_error_response"])
26+
else:
27+
raise UnexpectedError("Couldn't parse response")
28+
29+

braintree/test/credit_card_numbers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class CardTypeIndicators(object):
66
Healthcare = "4111111510101010"
77
Payroll = "4111111114101010"
88
Prepaid = "4111111111111210"
9+
PrepaidReloadable = "4229989900000002"
910
IssuingBank = "4111111141010101"
1011
CountryOfIssuance = "4111111111121102"
1112

braintree/test/nonces.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class Nonces(object):
7979
TransactablePayroll = "fake-valid-payroll-nonce"
8080
TransactablePinlessDebitVisa = "fake-pinless-debit-visa-nonce"
8181
TransactablePrepaid = "fake-valid-prepaid-nonce"
82+
TransactablePrepaidReloadable = "fake-valid-prepaid-reloadable-nonce"
8283
TransactableUnknownIndicators = "fake-valid-unknown-indicators-nonce"
8384
TransactableVisa = "fake-valid-visa-nonce"
8485
VenmoAccount = "fake-venmo-account-nonce"
@@ -87,4 +88,4 @@ class Nonces(object):
8788
VisaCheckoutDiscover = "fake-visa-checkout-discover-nonce"
8889
VisaCheckoutMasterCard = "fake-visa-checkout-mastercard-nonce"
8990
VisaCheckoutVisa = "fake-visa-checkout-visa-nonce"
90-
UsBankAccount = "fake-us-bank-account-nonce"
91+
UsBankAccount = "fake-us-bank-account-nonce"

0 commit comments

Comments
 (0)