Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Token generation in braintree

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 147
    Comment on it

    Welcome to FindNerd. Today we are going to discuss the client token generation on braintree. You can create a unique client tokens for different process. Please have a look.

    public function getBraintreeClientToken($customer_id = null)
    {
            if (!empty($customer_id) && is_int($customer_id))
                $client_token = Braintree_ClientToken::generate(array("customerId"=>$customer_id));
            else
                $client_token = Braintree_ClientToken::generate();
    
            if(isset($client_token)){
                echo json_encode(array('status' => 'success','message' => 'Token generated','client_token'=> $client_token)); die; 
            }else{
                echo json_encode(array('status' => 'fail','message' => 'Token not generated.please try again!')); die;
                    }
    }
    

    We created a function getBraintreeClientToken which is taking customer id as an argument. You can create token for specific customer or same token for all.

 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: