[Chicago] Braintree Environment, Configuration, and Thread Safety

Raymond W Berg raymondwberg at gmail.com
Mon Jul 18 17:21:27 EDT 2016


Mark,

I hope this helps. They're almost identical, but because you're accessing
an attribute on the gateway instance you just downcase the attribute:

##########################################
import braintree

#Global
braintree.Configuration.configure(
    braintree.Environment.Sandbox,
    "some_bad_public_id",
    "some_bad_public_key",
    "some_bad_private_key"
)

#Instance
working_gateway = braintree.BraintreeGateway(braintree.Configuration(
    braintree.Environment.Sandbox,
    "some_good_public_id",
    "some_good_public_key",
    "some_good_private_key"
))

sale_params = {
    "amount": "1000.00",
    "payment_method_nonce": "fake-valid-nonce",
    "options": {
        "submit_for_settlement": True
    }
}

result_1 = braintree.Transaction.sale(sale_params)
## Will fail, because the keys ar bad

result_2 = braintree.transaction.sale(sale_params)
## Will succeed, because the instance keys are good

result_3 = braintree.Transaction.sale(sale_params)
## Will fail, because the static keys are still bad!
##########################################


Respectfully,
Ray Berg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20160718/8d0dcb52/attachment.html>


More information about the Chicago mailing list