Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Integration Braintree payment getway with php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.20k
    Comment on it

    Hello friends,

    In this blog we will learn, How to made payment with Braintree getway. First go throw https://github.com/braintree/braintree_php and download the library after you will need to register with Braintree and get merchant ID and Public key,Private key. Use these are in your code Like this

      <?php   Braintree_Configuration::merchantId(BRAINTREE_MERCHANT_ID);
            Braintree_Configuration::publicKey(BRAINTREE_PUBLIC_KEY);
            Braintree_Configuration::privateKey(BRAINTREE_PRIVATE_KEY);  ?>

    1) Create customer with Braintree

    For create customer you need to basic details like and also you can take a reference this link https://developers.braintreepayments.com/reference/request/customer/create/php

    <?php $result = Braintree_Customer::create([
        'firstName' => 'Mike',
        'lastName' => 'Jones',
        'company' => 'Jones Co.',
        'email' => 'mike.jones@example.com',
        'phone' => '281.330.8004',
        'fax' => '419.555.1235',
        'website' => 'http://example.com'
    ]);
    
    $result->success;
    # true
    
    $result->customer->id;
    # Generated customer id
    ?>

    2) Make payment with Braintree

    A) Existing customer with new payment method (Customer_ID)

    $result = Braintree_Transaction::sale([
      'amount' => '10.00',
      'paymentMethodNonce' => nonceFromTheClient,
      'customerId' => 'the_customer_id'
    ]);

    B) New customer with new payment method

    $result = Braintree_Transaction::sale([
      'amount' => '10.00',
      'paymentMethodNonce' => nonceFromTheClient,
      'customer' => [
        'id' => 'a_customer_id'
      ],
      'options' => [
        'storeInVaultOnSuccess' => true,
      ]
    ]);

    C) Existing customer with existing payment method

     $result = Braintree_Transaction::sale([
    					'amount' => 10.00,
    					'paymentMethodToken' => $paymentMethodToken,
    					'options' => [
    						'submitForSettlement' => true
    					]
    				       ]);

     

 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: