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)