Braintree-Stripe integration for python in the Flask framework.
This app is meant to limit customers spending online. As people move away from Brick and Mortar stores and shift towards E-commerce, parents can limit their children's spending through this interface.
- Create Customer
- View All Customers
- Update a customer
- Create a transaction for a customer
- Install requirements:
pip3 install -r requirements.txt
- 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
.
- Provide Tariq Anees([email protected]) with your IP address. MongoAtlas Cluster needs to whitelist your IP address.
Run python3 test_app.py
1.Sandbox transactions must be made with credit card number: 4111 1111 1111 1111
- API Endpoints
Method Path Description Create Customer POST
/customer
Generate Fast customer details (e.g. spendinglimit, firstname, lastname). View All Customers GET
/customers
View all Fast customers. View A Single Customer GET
/customer/{{customer_id}}
View a single Fast customer. Update Customer GET
/update-stripe-braintree-customer?first_name={{first_name}}&customer_id={{customer_id}}&last_name={{last_name}}&spending_limit={{spending_limit}}&customer_method_nonce={{}}'
Send an update to the Braintree/Stripe API and Fast Customer database. Create Transaction POST
/checkouts/{{payment_method_nonce}}
Create the Braintree transaction with supplied payment_method_nonce Create a customer on Braintree and Stripe, store both records in MongoDB
URL /customer
Method POST
URL Params None Data Params request.form: ([('first_name', ''), ('last_name', ''), ('spending_limit', ''), ('customer_method_nonce', '')]) Success Response { 'fast_customer_id': '5f027d475c0f0faf6c863793', 'braintree_id': '290457393', 'stripe_id': 'cus_HauucCq1RPCyXB', 'error': {}, 'success': True }
Error Response See Error Codes for a complete list of errors. { 'fast_customer_id': None, 'braintree_id': {}, 'stripe_id': {}, 'error': { "error_message": "", "error_code": 302 }, 'success': False }
Update a customer on Braintree and Stripe, store both records in MongoDB
URL /update-stripe-braintree-customer?first_name={{first_name}}&customer_id={{customer_id}}&last_name={{last_name}}&spending_limit={{spending_limit}}&customer_method_nonce={{}}
Method GET
URL Params request.args: [('first_name'), ('last_name'), ('spending_limit'), ('customer_method_nonce')] Data Params None Success Response { 'fast_customer_id': '5f026a6342b689f3294745a4', 'braintree_id': '853421331', 'stripe_id': 'cus_Hatbs5pT0jqfrI', 'error': {}, 'success': True }
Error Response See Error Codes for a complete list of errors. { 'fast_customer_id': None, 'braintree_id': {}, 'stripe_id': {}, 'error': { "error_message": "", "error_code": 302 }, 'success': False }
View a customer using Fast Customer ID
URL /customer/{{customer_id}}
Method GET
URL Params customer_id Data Params None View all Fast Customers
URL /customers
Method GET
URL Params None Data Params None Create a transaction for a customer on Braintree and store record in MongoDB
****URL /checkouts/{{payment_method_nonce}}
Method POST
URL Params payment_method_nonce [Required] | payment_method_nonce assigned to the bt-drop-in-wrapper. Data Params - customer_id (string)
- Fast customer ID.
- amount (string)
- Amount inserted in form
- payment_method_nonce (string)
- payment_method_nonce issued from bt-drop-in-wrapper docs]
{ ('customer_id', '5f026a6342b689f3294745a4'), ('amount', '10'), ('payment_method_nonce', 'tokencc_bf_yqz6gt_3spr4t_ddk2hr_8cr7qb_my8') }
Success Response { 'fast_transaction_id': '5f02874560e0ee8612916cb2', 'braintree_transaction_id': 'caqapryb', 'error': {}, 'success': True }
Error Response { 'fast_transaction_id': None, 'braintree_transaction_id': {}, 'error': { 'error_message': 'Transaction Amount: 1000000 Exceeds Limit: 100', 'error_code': '415' }, 'success': False }