original_string: public function subscribeCustomerToPlan($planId, $paymentToken, $customerEmail, $couponId = null)
      {
          $customer = Customer::create([
              'source'    => $paymentToken,
              'email'     => $customerEmail
          ]);
  
          $data = [
              'customer'  => $customer->id,
              'plan'      => $planId,
          ];
  
          if ($couponId) {
              $data['coupon'] = $couponId;
          }
  
          $subscription = Subscription::create($data);
  
          return $customer;
      }
code: public function subscribeCustomerToPlan($planId, $paymentToken, $customerEmail, $couponId = null)
      {
          $customer = Customer::create([
              'source'    => $paymentToken,
              'email'     => $customerEmail
          ]);
  
          $data = [
              'customer'  => $customer->id,
              'plan'      => $planId,
          ];
  
          if ($couponId) {
              $data['coupon'] = $couponId;
          }
  
          $subscription = Subscription::create($data);
  
          return $customer;
      }
code_tokens: public function subscribeCustomerToPlan ( $ planId , $ paymentToken , $ customerEmail , $ couponId = null ) { $ customer = Customer :: create ( [ 'source' => $ paymentToken , 'email' => $ customerEmail ] ) ; $ data = [ 'customer' => $ customer -> id , 'plan' => $ planId , ] ; if ( $ couponId ) { $ data [ 'coupon' ] = $ couponId ; } $ subscription = Subscription :: create ( $ data ) ; return $ customer ; }
docstring: Associate a new Customer object to an existing Plan.
  
  @throws HttpException:
  - If the planId is invalid (the plan does not exists...)
  - If the payment token is invalid (payment failed)
  
  @see https://stripe.com/docs/subscriptions/tutorial#create-subscription
  
  @param string $planId: The plan ID as defined in your Stripe dashboard
  @param string $paymentToken: The payment token returned by the payment form (Stripe.js)
  @param string $customerEmail: The customer email
  @param string|null $couponId: An optional coupon ID
  
  @return Customer
docstring_tokens: Associate a new Customer object to an existing Plan .