Giter Club home page Giter Club logo

braintree_flask_example's Introduction

Braintree Flask Example

An example Braintree integration for python in the Flask framework.

Setup Instructions

  1. Install requirements:
pip3 install -r requirements.txt
  1. Copy the contents of example.env into a new file named .env and fill in your Braintree API credentials. Credentials can be found by navigating to Account > My User > View Authorizations in the Braintree Control Panel. Full instructions can be found on our support site.

  2. Start server:

python3 app.py

By default, this runs the app on port 4567. You can configure the port by setting the environmental variable PORT.

Running tests

Unit tests do not make API calls to Braintree and do not require Braintree credentials. You can run this project's unit tests by calling python test_app.py on the command line.

Testing Transactions

Sandbox transactions must be made with sample credit card numbers, and the response of a Transaction.sale() call is dependent on the amount of the transaction.

Pro Tips

Help

Disclaimer

This code is provided as is and is only intended to be used for illustration purposes. This code is not production-ready and is not meant to be used in a production environment. This repository is to be used as a tool to help merchants learn how to integrate with Braintree. Any use of this repository or any of its code in a production environment is highly discouraged.

braintree_flask_example's People

Contributors

afolksetapart avatar braintreeps avatar crookedneighbor avatar danakatz avatar dev-viinz avatar epreuve avatar evanhahn avatar fionabronwen avatar hollabaq86 avatar intelliot avatar jackellenberger avatar jdlc avatar jferm avatar lilaconlee avatar mtmarsh3 avatar omgrr avatar pblesi avatar raymondberg avatar saralvasquez avatar sestevens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

braintree_flask_example's Issues

How to limit/control user entry of transaction amounts

General information

  • Environment: Sandbox
  • py3 on Ubuntu 16.04 LTS

Issue description

I'd like to have users enter only 1 of 3 amounts. For example 5.00, 10.00 or 20.00 & I though't I'd just use an if/else to do so inside the new checkout function (def new_checkout) of app.py (see line 31 of app.py). I was thinking if the amount entered is 5,10 or 20 proceed with the transaction, else display some error (ie Error: 81502: Amount is required.). Is there a way to get the transaction amount & check it before moving forward with the transaction OR should I be approaching this a different way? Thanks

Production .env config

General information

  • Environment: (moving toward) Production
  • Language, language version, and OS: py3 Ubuntu 16.04

Issue description

More of question than integration issue. Working fine with the example.env below

BT_ENVIRONMENT='sandbox'
BT_MERCHANT_ID='your braintree merchant id'
BT_PUBLIC_KEY='your braintree public key'
BT_PRIVATE_KEY='your braintree private key'
APP_SECRET_KEY='your unique secret key; a long, random set of characters'

now looking to move to production credentials & was going to update only top 4 lines of .env like so

BT_ENVIRONMENT='production'
BT_MERCHANT_ID='your PRODUCTION braintree merchant id'
BT_PUBLIC_KEY='your PRODUCTION braintree public key'
BT_PRIVATE_KEY='your PRODUCTION braintree private key'
APP_SECRET_KEY='your unique secret key; a long, random set of characters'

but before I move forward & try a few low-value test transactions just wanted to check if there's any additional updates/changes/recommendations needed to the .env file so it'll work properly with production credentials. Thanks

Braintree dep > 3.30 breaks the example

General information

  • Environment: Sandbox (but presumably prod too)
  • Language, language version, and OS: Python 2.7.x and Python 3.5.x both on Ubuntu 16.04 and in the provide docker-compose environment.

Issue description

In a nutshell:

The requirements.txt specifies a braintree dependency of >= 3.22 however the latest (3.36) will fail with the following error:

(venv3) dino braintree_flask_example $ python3.5 app.py 
Traceback (most recent call last):
  File "app.py", line 6, in <module>
    import braintree
  File "/home/steph/git/braintree_flask_example/venv3/lib/python3.5/site-packages/braintree/__init__.py", line 1, in <module>
    from braintree.ach_mandate import AchMandate
  File "/home/steph/git/braintree_flask_example/venv3/lib/python3.5/site-packages/braintree/ach_mandate.py", line 2, in <module>
    from braintree.util.datetime_parser import parse_datetime
ImportError: No module named 'braintree.util.datetime_parser'

This is reproduceable both in virtualenvs of Python 2 and Python 3 on Ubuntu 16.04 and also in the provided docker-compose yaml. I was able to get the example to run with the following change, but I haven't looked to see exactly which version of braintree breaks this:

diff --git a/requirements.txt b/requirements.txt
index 9c3fb46..034b247 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,5 @@
 Flask>=0.10.1
-braintree>=3.22.0
+braintree==3.30.0
 MarkupSafe>=0.23
 mock>=1.3.0
 Werkzeug>=0.7

ERROR: No value passed to payment issue

General information

  • Environment: Sandbox
  • Language, language version, and OS: Python 2.7 on Linux Mint Mate 18

Issue description

I cloned this project https://github.com/braintree/braintree_flask_example and applied braintree sandbox credentials in example.env file and after run the project i am getting below stack trace in chrome browser console :
{stack: "Error: No value passed to payment↵ at https://w…aypalobjects.com/api/checkout.4.0.166.js:2856:13)", errtype: "[object Error]", timestamp: 1512406360681, windowID: "99a6bf0489", pageID: "d6d9926518", …}country: "GB"env: "sandbox"errtype: "[object Error]"host: "www.sandbox.paypal.com"lang: "en"pageID: "d6d9926518"path: "/webapps/hermes/button"prev_corr_ids: ""referer: "http://localhost:4567"stack: "Error: No value passed to payment↵ at https://www.paypalobjects.com/api/checkout.4.0.166.min.js:14:187628↵ at https://www.paypalobjects.com/api/checkout.4.0.166.min.js:14:168195↵ at e.dispatch (https://www.paypalobjects.com/api/checkout.4.0.166.min.js:14:168649)↵ at e.resolve (https://www.paypalobjects.com/api/checkout.4.0.166.min.js:14:167373)↵ at https://www.paypalobjects.com/api/checkout.4.0.166.min.js:14:167026↵ at ↵ at Object._RECEIVE_MESSAGE_TYPE.(anonymous function) [as postrobot_message_response] (https://www.paypalobjects.com/api/checkout.4.0.166.js:2936:122)↵ at receiveMessage (https://www.paypalobjects.com/api/checkout.4.0.166.js:2835:77)↵ at messageListener (https://www.paypalobjects.com/api/checkout.4.0.166.js:2856:13)"timestamp: 1512406360681uid: "fc21281b3e_ge3dunjshizdo"ver: "4.0.166"windowID: "99a6bf0489"proto: Object ....

i stuck here last 5 days. Please help.

ImportError: cannot import name 'escape' from 'jinja2'

General information

  • Environment: Sandbox
  • Language, language version, and OS: Heroku Deployment, Windows 10

Issue description

Run the App from heroku cli from Windows 10

C:\Users\Pascal>heroku logs --tail -a testrainree
» Warning: heroku update available from 7.53.0 to 7.60.2.
2022-05-29T08:35:57.663943+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-05-29T08:35:57.663943+00:00 app[web.1]: File "", line 1050, in _gcd_import
2022-05-29T08:35:57.663944+00:00 app[web.1]: File "", line 1027, in _find_and_load
2022-05-29T08:35:57.663944+00:00 app[web.1]: File "", line 1006, in _find_and_load_unlocked2022-05-29T08:35:57.663945+00:00 app[web.1]: File "", line 688, in _load_unlocked
2022-05-29T08:35:57.663945+00:00 app[web.1]: File "", line 883, in exec_module
2022-05-29T08:35:57.663945+00:00 app[web.1]: File "", line 241, in _call_with_frames_removed
2022-05-29T08:35:57.663946+00:00 app[web.1]: File "/app/app.py", line 1, in
2022-05-29T08:35:57.663946+00:00 app[web.1]: from flask import Flask, redirect, url_for, render_template, request, flash2022-05-29T08:35:57.663947+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/flask/init.py", line 14, in
2022-05-29T08:35:57.663947+00:00 app[web.1]: from jinja2 import escape
2022-05-29T08:35:57.663947+00:00 app[web.1]: ImportError: cannot import name 'escape' from 'jinja2' (/app/.heroku/python/lib/python3.10/site-packages/jinja2/init.py)
2022-05-29T08:35:57.664146+00:00 app[web.1]: [2022-05-29 08:35:57 +0000] [9] [INFO] Worker exiting (pid: 9)
2022-05-29T08:35:57.674872+00:00 app[web.1]: [2022-05-29 08:35:57 +0000] [10] [ERROR] Exception in worker process
2022-05-29T08:35:57.674874+00:00 app[web.1]: Traceback (most recent call last):
2022-05-29T08:35:57.674874+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2022-05-29T08:35:57.674875+00:00 app[web.1]: worker.init_process()
2022-05-29T08:35:57.674875+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/workers/base.py", line 119, in init_process
2022-05-29T08:35:57.674876+00:00 app[web.1]: self.load_wsgi()
2022-05-29T08:35:57.674876+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2022-05-29T08:35:57.674876+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2022-05-29T08:35:57.674877+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/base.py", line 67, in wsgi
2022-05-29T08:35:57.674877+00:00 app[web.1]: self.callable = self.load()
2022-05-29T08:35:57.674877+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2022-05-29T08:35:57.674878+00:00 app[web.1]: return self.load_wsgiapp()
2022-05-29T08:35:57.674878+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2022-05-29T08:35:57.674878+00:00 app[web.1]: return util.import_app(self.app_uri)
2022-05-29T08:35:57.674879+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/util.py", line 358, in import_app
2022-05-29T08:35:57.674879+00:00 app[web.1]: mod = importlib.import_module(module)
2022-05-29T08:35:57.674880+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/importlib/init.py", line 126, in import_module
2022-05-29T08:35:57.674880+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-05-29T08:35:57.674881+00:00 app[web.1]: File "", line 1050, in _gcd_import
2022-05-29T08:35:57.674881+00:00 app[web.1]: File "", line 1027, in _find_and_load
2022-05-29T08:35:57.674882+00:00 app[web.1]: File "", line 1006, in _find_and_load_unlocked2022-05-29T08:35:57.674882+00:00 app[web.1]: File "", line 688, in _load_unlocked
2022-05-29T08:35:57.674882+00:00 app[web.1]: File "", line 883, in exec_module
2022-05-29T08:35:57.674883+00:00 app[web.1]: File "", line 241, in _call_with_frames_removed
2022-05-29T08:35:57.674883+00:00 app[web.1]: File "/app/app.py", line 1, in
2022-05-29T08:35:57.674884+00:00 app[web.1]: from flask import Flask, redirect, url_for, render_template, request, flash2022-05-29T08:35:57.674884+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/flask/init.py", line 14, in
2022-05-29T08:35:57.674884+00:00 app[web.1]: from jinja2 import escape
2022-05-29T08:35:57.674885+00:00 app[web.1]: ImportError: cannot import name 'escape' from 'jinja2' (/app/.heroku/python/lib/python3.10/site-packages/jinja2/init.py)
2022-05-29T08:35:57.675060+00:00 app[web.1]: [2022-05-29 08:35:57 +0000] [10] [INFO] Worker exiting (pid: 10)
2022-05-29T08:35:57.834025+00:00 app[web.1]: [2022-05-29 08:35:57 +0000] [4] [INFO] Shutting down: Master
2022-05-29T08:35:57.834541+00:00 app[web.1]: [2022-05-29 08:35:57 +0000] [4] [INFO] Reason: Worker failed to boot.
2022-05-29T08:35:58.037349+00:00 heroku[web.1]: Process exited with status 3
2022-05-29T08:35:58.099924+00:00 heroku[web.1]: State changed from starting to crashed
2022-05-29T08:35:58.103171+00:00 heroku[web.1]: State changed from crashed to starting
2022-05-29T08:36:00.000000+00:00 app[api]: Build succeeded
2022-05-29T08:36:01.329487+00:00 heroku[web.1]: Starting process with command gunicorn app:app --log-file -
2022-05-29T08:36:02.649146+00:00 app[web.1]: [2022-05-29 08:36:02 +0000] [4] [INFO] Starting gunicorn 20.0.4
2022-05-29T08:36:02.649498+00:00 app[web.1]: [2022-05-29 08:36:02 +0000] [4] [INFO] Listening at: http://0.0.0.0:29565 (4)
2022-05-29T08:36:02.649531+00:00 app[web.1]: [2022-05-29 08:36:02 +0000] [4] [INFO] Using worker: sync
2022-05-29T08:36:02.653018+00:00 app[web.1]: [2022-05-29 08:36:02 +0000] [9] [INFO] Booting worker with pid: 9
2022-05-29T08:36:02.682768+00:00 app[web.1]: [2022-05-29 08:36:02 +0000] [9] [ERROR] Exception in worker process
2022-05-29T08:36:02.682769+00:00 app[web.1]: Traceback (most recent call last):
2022-05-29T08:36:02.682780+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2022-05-29T08:36:02.682780+00:00 app[web.1]: worker.init_process()
2022-05-29T08:36:02.682780+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/workers/base.py", line 119, in init_process
2022-05-29T08:36:02.682781+00:00 app[web.1]: self.load_wsgi()
2022-05-29T08:36:02.682781+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2022-05-29T08:36:02.682781+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2022-05-29T08:36:02.682781+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/base.py", line 67, in wsgi
2022-05-29T08:36:02.682782+00:00 app[web.1]: self.callable = self.load()
2022-05-29T08:36:02.682782+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2022-05-29T08:36:02.682782+00:00 app[web.1]: return self.load_wsgiapp()
2022-05-29T08:36:02.682782+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2022-05-29T08:36:02.682782+00:00 app[web.1]: return util.import_app(self.app_uri)
2022-05-29T08:36:02.682783+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/util.py", line 358, in import_app
2022-05-29T08:36:02.682783+00:00 app[web.1]: mod = importlib.import_module(module)
2022-05-29T08:36:02.682786+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/importlib/init.py", line 126, in import_module
2022-05-29T08:36:02.682786+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-05-29T08:36:02.682786+00:00 app[web.1]: File "", line 1050, in _gcd_import
2022-05-29T08:36:02.682787+00:00 app[web.1]: File "", line 1027, in _find_and_load
2022-05-29T08:36:02.682787+00:00 app[web.1]: File "", line 1006, in _find_and_load_unlocked2022-05-29T08:36:02.682787+00:00 app[web.1]: File "", line 688, in _load_unlocked
2022-05-29T08:36:02.682787+00:00 app[web.1]: File "", line 883, in exec_module
2022-05-29T08:36:02.682788+00:00 app[web.1]: File "", line 241, in _call_with_frames_removed
2022-05-29T08:36:02.682788+00:00 app[web.1]: File "/app/app.py", line 1, in
2022-05-29T08:36:02.682788+00:00 app[web.1]: from flask import Flask, redirect, url_for, render_template, request, flash2022-05-29T08:36:02.682788+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/flask/init.py", line 14, in
2022-05-29T08:36:02.682789+00:00 app[web.1]: from jinja2 import escape
2022-05-29T08:36:02.682792+00:00 app[web.1]: ImportError: cannot import name 'escape' from 'jinja2' (/app/.heroku/python/lib/python3.10/site-packages/jinja2/init.py)
2022-05-29T08:36:02.682857+00:00 app[web.1]: [2022-05-29 08:36:02 +0000] [9] [INFO] Worker exiting (pid: 9)
2022-05-29T08:36:02.714150+00:00 app[web.1]: [2022-05-29 08:36:02 +0000] [4] [INFO] Shutting down: Master
2022-05-29T08:36:02.714177+00:00 app[web.1]: [2022-05-29 08:36:02 +0000] [4] [INFO] Reason: Worker failed to boot.
2022-05-29T08:36:02.859250+00:00 heroku[web.1]: Process exited with status 3
2022-05-29T08:36:02.953722+00:00 heroku[web.1]: State changed from starting to crashed
2022-05-29T08:36:09.657092+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testrainree.herokuapp.com request_id=fa51f27f-67df-4268-b955-ab9a39632656 fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T08:36:10.087238+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=testrainree.herokuapp.com request_id=2576853f-e0fe-41f9-b26a-c6f51bebf804 fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T08:40:14.487267+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testrainree.herokuapp.com request_id=a626f7c9-18a6-48ef-8637-ebe67810c84f fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T08:40:14.785163+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=testrainree.herokuapp.com request_id=77d2a02d-6952-44bc-9a1f-8292e973e90f fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T08:41:33.930199+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testrainree.herokuapp.com request_id=3731328f-ea49-4d43-a740-09a413d318d0 fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T08:41:34.360119+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=testrainree.herokuapp.com request_id=6d1a3875-138f-4a06-9892-617c42504ffb fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T08:59:56.262993+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testrainree.herokuapp.com request_id=72cdcb0f-b2e8-4638-a92a-0662e4284679 fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T08:59:56.529518+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=testrainree.herokuapp.com request_id=8e6b9661-d94d-4b10-a021-bfc87535f24c fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T09:06:56.015404+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testrainree.herokuapp.com request_id=90457398-fbc3-4f92-ad7e-0bcc8a064457 fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T09:06:56.295779+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=testrainree.herokuapp.com request_id=a599f062-5448-4139-8dd3-c163f1742009 fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T09:14:19.069757+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testrainree.herokuapp.com request_id=0cc4ea52-5042-45bf-a773-0fade4cec3cf fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-29T09:14:19.850844+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=testrainree.herokuapp.com request_id=32189bfb-1c1f-4d4f-8c33-6ea876a01cc2 fwd="62.216.204.45" dyno= connect= service= status=503 bytes= protocol=https

Can't convert 'NoneType' object to str implicitly - when using nginx

General information

  • Environment: Sandbox
  • Language, language version, and OS: Python 3.5.2 in venv on Ubuntu 16.04 LTS

Issue description

It runs just fine when following the setup instructions. However when trying to run it behind nginx I get the following output

[2019-02-07 18:53:07 -0500] [8877] [INFO] Starting gunicorn 19.4.5
[2019-02-07 18:53:07 -0500] [8877] [INFO] Listening at: http://127.0.0.1:8000 (8877)
[2019-02-07 18:53:07 -0500] [8877] [INFO] Using worker: sync
[2019-02-07 18:53:07 -0500] [8880] [INFO] Booting worker with pid: 8880
[2019-02-07 18:53:15,486] ERROR in app: Exception on /checkouts/new [GET]
Traceback (most recent call last):
File "/home/cartier/Documents/braintree_flask/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/home/cartier/Documents/braintree_flask/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/cartier/Documents/braintree_flask/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/cartier/Documents/braintree_flask/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/cartier/Documents/braintree_flask/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/home/cartier/Documents/braintree_flask/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/cartier/Documents/braintree_flask/app.py", line 32, in new_checkout
client_token = generate_client_token()
File "/home/cartier/Documents/braintree_flask/gateway/__init__.py", line 15, in generate_client_token
return gateway.client_token.generate()
File "/home/cartier/Documents/braintree_flask/lib/python3.5/site-packages/braintree/client_token_gateway.py", line 24, in generate
response = self.config.http().post(self.config.base_merchant_path() + "/client_token", params)
File "/home/cartier/Documents/braintree_flask/lib/python3.5/site-packages/braintree/configuration.py", line 113, in base_merchant_path
return "/merchants/" + self.merchant_id
TypeError: Can't convert 'NoneType' object to str implicitly

I've configured nginx with the following flask settings

server {
    location / {

	proxy_pass http://127.0.0.1:8000;		
	proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
    }
}

Originally I got this error in another flask app so initially I thought I'd just forgot to include or import something. In the other app it's the same behavior; it works without nginx but fails with nginx. So I came back to this standalone braintree_flask app & found the same issue. Any ideas???

README Clarification

Thanks so much for the great example flask project for integrating braintree in python!

I just wanted to mention a small opportunity for clarification in the README. It says "Copy the example.env file to .env", which doesn't indicate that .env is a file as well. I literally created my typical virtualenv named env and moved the .env file into it (and to various other places in the project) for several minutes. Something like "Rename the example.env file to .env" or something to indicate that .env is a file which is remaining in the same place might save another n00b from fumbling around in the future. ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.