Coder Social home page Coder Social logo

aviatoryona / braintree_php_example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from quyetdc/braintree_php_example

0.0 1.0 0.0 980 KB

An example Braintree integration for PHP

License: MIT License

Dockerfile 0.43% PHP 27.40% Hack 0.47% CSS 68.25% JavaScript 3.44%

braintree_php_example's Introduction

Braintree PHP Example

An example Braintree integration for PHP. In this project I added a new simple page to get payment-method-nonce key, which is just generated, not used, for API testing purpose

Demo link

https://colin-braintree-php-nonce.herokuapp.com/

Create your own Braintree App

Deploy

Setup Instructions

  1. Install composer within the example directory. You can find instructions on how to install composer on composer's site.

  2. Run composer:

composer install
  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 the internal PHP server on port 3000:

php -S localhost:8888 -t public_html

Then on your localhost:8888 you will have this

  1. Enter a sandbox braintree creditcard, ex: 4111 1111 1111 1111 and expired date in future, ex: 02/20, the page will redirect you to a new page to have Braintree payment_method_nonce. Please note that the nonce can be used only once.

Like in this image

  1. In case you want to demonstrate how transaction success, not to get payment method nonce, please look at the file public_html/index.php and change this line
<form method="post" id="payment-form" action="/get_nonce.php">

to this

<form method="post" id="payment-form" action="/checkout.php">

Then after entering card detail, you will see the transaction detail, like in this image

Braintree

  1. First, you need to understand how Braintree works, what is client token, what is payment method nonce, and how it works on this url https://developers.braintreepayments.com/start/overview

  2. You will need to register a Braintree sandbox account via https://www.braintreepayments.com/sandbox

  3. You will need to gain your Braintree API credentials, including public_key, private_key, merchant_id. These credentials are needed for your .env file, or somewhere in your config/env/configs.php in a my current Laravel project

  4. If your API configure different Merchant Account ID for different Currency, you will need access to your Braintree sandbox Settings (most top left navigation option) and then Processing. In this page you will see a place to setup new Merchant Account ID. Please make sure that the Merchant Account Id is correct to what you have on sandbox if you set it to Braintree\Transaction::sale

Good luck

braintree_php_example's People

Contributors

braintreeps avatar quyetdc avatar danakatz avatar omgrr avatar kexline4710 avatar raymondberg avatar crookedneighbor avatar evanhahn avatar jdlc avatar pblesi avatar mtmarsh3 avatar phannam1412 avatar

Watchers

James Cloos 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.