Simple Braintree (PayPal) Payment gateway integration in PHP with DEMO Examples

ilovephp.net

Are you looking for Payment gateway which suites for your website as well as mobile app platform?

Then braintree makes your work much easier. It’s very simple, easier and quick to integrate using Braintree SDK.

Few important point need to consider while proceed to start on Braintree integration-

  1. PHP version of your server
  2. Braintree offer 2 ways API integration
    • Drop-in UI
    • Custom Integration

1. Depending on you server PHP version you can choise Braintree SDK –

Currently availble latest braintree SDK is (braintree-php-3.9.0) which requires PHP version >= 5.4.0 (https://developers.braintreepayments.com/client_libraries/php/braintree-php-3.9.0.tgz)
If your server runs on PHP version which is < 5.4.0?, don’t worry we have work arround for this issue, you can use (braintree_php-2.40.0) Braintree SDK. (https://codeload.github.com/braintree/braintree_php/zip/2.40.0)

2.a Drop-in UI
– Braintree’s Drop-in UI offers a complete, ready-made payment UI for a quick and easy way to accept payments. It’s equally as easy to maintain PCI compliance with Drop-in; it is eligible for SAQ A since Braintree hosts the form that captures customer payment information.

The UI includes a card entry form and, if enabled, PayPal/Venmo buttons (Venmo only on mobile). When a user completes the UI, your client code obtains a payment method nonce for use on your server.

The Drop-in UI is the quickest way to start accepting payments.    Considering security of customer credit card data handing at server end, the Drop-in UI is best choise. In drop in UI you will deal with only a single token (payment_method_nonce) which communicate from website client to website server and then website server to Brintree server.

2.b Custom Integration
In Custom integration, you can create your own payment form with custom colors and layout and collect the customer information before submit to payment gateway. If you need payment form with  multilingual support then you can use custom Brintree API integration. In custom Braintree integration you need more developer efferts compare to Drop in UI.

Ref. Link : https://developers.braintreepayments.com/guides/drop-in/javascript/v2

Before proceed for Braintree API integration, we need to sign up for Braintree SDK. Which is free of cost for everyone.
Follow the below link to Sign up to Braintree SDK.
https://www.braintreepayments.com/get-started

After successfull signup we will get –

Merchant ID: xxxxxxx
Public Key: xxxxxxxx
Private Key: xxxxxxxxxxxxxxx

Below are the 3 demo script of Drop-in UI, Hosted field and custom integration of Braintree Gateway API’s –

  1. Braintree – Payment Gateway integration (Drop-in UI) example :

 

2.  Braintree – Payment Gateway integration (Hosted Fields) example :

 

3.  Braintree – Payment Gateway Custom integration example :

 

Braintree Payment Gateway integration with 3D secure in Drop in-UI Example (Demo) :

 

Braintree – Payment Gateway integration with 3D secure (Hosted Fields) example

 

You can download all above demos from below link :
Download Source Code

Or

Browse source code in github : https://github.com/sagarsdeshmukh/Braintree_gateway_integration_demo_with_PHP

If you have any additional questions Or queries, don’t hesitate to let me know!, Just put comment below or contact @ my mail id sagarsdeshmukh@gmail.com

Hope you enjoy my post 🙂

) )
( (
……..
[|      |
\      /
`—-‘

Happy coding!

6 comments:

  1. Scott

    I have a Sandbox Account, add the merchant id, public key, and private key using the drop in demo. On text, the Card Fails, and I have more than enough to test with on that card. Am I missing something here?

  2. unknown

    hi im just wondering if i can use ur codings for commercial use? is there anything i need to do to avoid violating?

  3. Andrei García Cuadra

    Thank you. I was really confused about it.
    Now I guess things are going to be much easier.
    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *