Code Monkey home page Code Monkey logo

braintree_fast's Introduction

Braintree-Stripe Fast App

Braintree-Stripe integration for python in the Flask framework.

Purpose of Braintree-Stripe Fast App

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.

App User Interface

  1. Create Customer
  2. View All Customers
  3. Update a customer
  4. Create a transaction for a customer

Setup Instructions

  1. Install requirements:
pip3 install -r requirements.txt
  1. 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.

  1. Provide Tariq Anees([email protected]) with your IP address. MongoAtlas Cluster needs to whitelist your IP address.

Running tests

Run python3 test_app.py

Testing Transactions

1.Sandbox transactions must be made with credit card number: 4111 1111 1111 1111

Table of Contents

  • API Endpoints

    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

    Customer

    Create Customer

    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 Customer

    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 Customer

    View a customer using Fast Customer ID

    URL /customer/{{customer_id}}
    Method GET
    URL Params customer_id
    Data Params None

    View All Customers

    View all Fast Customers

    URL /customers
    Method GET
    URL Params None
    Data Params None

    Transactions

    Create

    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]
    Example Request Form
    
    {
        ('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
    }
    
    

braintree_fast's People

Contributors

tariqanees avatar trqanees94 avatar

Watchers

James Cloos avatar  avatar

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.