Braintree\Customer::find PHP Method

find() public static method

public static find ( string $id ) : Customer
$id string customer id
return Customer
    public static function find($id)
    {
        return Configuration::gateway()->customer()->find($id);
    }

Usage Example

 /**
  * @param string $customer_id
  * @param string $plan_id
  * @param array $addOns
  * @param array $discounts
  * @param array $removeAddOns
  * @param array $removeDiscounts
  * @return bool | int
  * @throws Exception
  */
 public function createSubscription($customer_id, $plan_id, $addOns = [], $discounts = [], $removeAddOns = [], $removeDiscounts = [])
 {
     $customer = Braintree_Customer::find($customer_id);
     $the_token = null;
     if (!empty($customer)) {
         $the_token = $customer->paymentMethods[0]->token;
     } else {
         throw new Exception("Customer not found \n");
     }
     $formattedAddOns = [];
     foreach ($addOns as $addOn) {
         $formattedAddOns[] = ['inheritedFromId' => $addOn];
     }
     $formattedDiscounts = [];
     foreach ($discounts as $discount) {
         $formattedDiscounts[] = ['inheritedFromId' => $discount];
     }
     $result = Braintree_Subscription::create(['paymentMethodToken' => $the_token, 'planId' => $plan_id, 'addOns' => ['add' => $formattedAddOns, 'remove' => $removeAddOns], 'discounts' => ['add' => $formattedDiscounts, 'remove' => $removeDiscounts]]);
     if ($result->success) {
         return $result->subscription->id;
     } else {
         foreach ($result->errors->deepAll() as $error) {
             throw new Exception($error->code . ": " . $error->message . "\n");
         }
     }
     return false;
 }
All Usage Examples Of Braintree\Customer::find