Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to integrate braintree payment gateway?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 837
    Comment on it

    Hello Readers,

    This blog show the integration of braintree.

    1. Braintree is a subsidiary of paypal.
    2. Braintree accepting most commonly used cards and it is secure payment system.

    When we use the braintree we require a barintree library first and create the account in braintree paypal and use the merchantId, publicKey, privateKey.

    For Example:

    First we include the braintree library.

    require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';

    Braintree_Configuration::environment('sandbox');
    Braintree_Configuration::merchantId('your_merchant_id');
    Braintree_Configuration::publicKey('your_public_key');
    Braintree_Configuration::privateKey('your_private_key');

    The above four is the main braintree configuration after implementing this configuration we normally use the braintree code which send the user information to braintree and get back the result if the user card information is correct else it gives the error messages.

    Code Braintree:

    1.First user make the HTML form including the userdetails and its carddetails.
    2.After that post the form and assign the variables in braintree sale transaction to send the user details to barintree.
    3.Lastly, user get the response in result variable.

    For Example:

    $result = Braintree_Transaction::sale(array(
    	    "amount" => (string) $amount,
    	    "creditCard" => array(
    	        "number" => $creditCardNumber,
    	        "cvv" => $cvv2Number,
    	        "expirationMonth" => $expirationMonth,
    	        "expirationYear" => $expirationYear
    	    ),
    		'customer' => array(
    	    'firstName' =>$cardholdername,
    	    'lastName' => $cardholderlastname
    	  	),
    	  	'billing' => array(
    		    'firstName' => $cardholdername,
    		    'lastName' => $cardholderlastname
    		  ),
    	  	'shipping' => array(
    		    'firstName' =>$cardholdername,
    		    'lastName' => $cardholderlastname
    	  	),
    		"options" => array(
    	        "submitForSettlement" => true
    	    )
    	    
    	));
    	
    	print_r($result);exit;
    

    Here, the above code we use creditcardnumber,cardholdername,cardholderlastname,cvvnumber,expirationmonth and year. This information send the braintree to process the request and get back the response.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: