Stripe Subscription with Initial setup fee

4.1k views Asked by At

I'm building a relatively simple subscription based app using Stripe.

My only real hangup at the moment is that the subscription requires an initial setup fee, and I'm really having a hard time with it.

Example:
A new user signs-up for Subscription-A; Subscription-A has a monthly interval price of $10. Upon signing up the new user gets charged a one-time fee of $1 and $10 for subscription, then the following months gets charged only $10.

Currently my code is:

// Stripe New customer
  $customer = \Stripe\Customer::create(array(
    "email" => $customer_email,
    "source" => $token,
  ),
  array("stripe_account" => $connected_account)
  );

// Stripe Subscription
  $sub = \Stripe\Subscription::create(array(
    "customer" => $customer['id'],
    "items" => array(
      array(
        "plan" => $plan_id,
      ),
    ),
  ),
  array("stripe_account" => $connected_account)
  );

Any idea? thx

1

There are 1 answers

2
Ywain On BEST ANSWER

After creating the customer, but before creating the subscription, create an invoice item for the setup fee.

When you create the subscription, a first invoice will be immediately created, and this invoice will include all pending invoice items for the customer.

For more information about invoice items, see https://stripe.com/docs/subscriptions/invoices#adding-invoice-items.