Laravel\Cashier\BraintreeService::findPlan PHP Method

findPlan() public static method

Get the Braintree plan that has the given ID.
public static findPlan ( string $id ) : Braintree\Plan
$id string
return Braintree\Plan
    public static function findPlan($id)
    {
        $plans = BraintreePlan::all();
        foreach ($plans as $plan) {
            if ($plan->id === $id) {
                return $plan;
            }
        }
        throw new Exception("Unable to find Braintree plan with ID [{$id}].");
    }

Usage Example

コード例 #1
0
 /**
  * Handle the event.
  *
  * @param  mixed  $event
  * @return void
  */
 public function handle($event)
 {
     $subscription = $event->billable->subscription();
     if (!$subscription || !$subscription->valid()) {
         return;
     }
     $plan = BraintreeService::findPlan($subscription->braintree_plan);
     BraintreeSubscription::update($subscription->braintree_id, ['price' => $plan->price * (1 + $event->billable->taxPercentage() / 100), 'options' => ['prorateCharges' => false]]);
 }
All Usage Examples Of Laravel\Cashier\BraintreeService::findPlan
BraintreeService