Hugo-dev
Hugo-dev

Reputation: 189

Stripe connect: List subscription plans for a connected account

I am developing a SAAS that allows subscribers to sell files to their customers. I would also like them to be able to offer subscriptions to their customers and recover the funds from their account connected to my platform.

I found how to make the users of my service can offer subscriptions to their customers with this page: https://stripe.com/docs/connect/subscriptions

$subscription = \Stripe\Subscription::create([
  "customer" => "cus_4fdAW5ftNQow1a",
  "items" => [
    ["plan" => "pro-monthly"],
  ],
], ["stripe_account" => "{CONNECTED_STRIPE_ACCOUNT_ID}"]);

Nevertheless in the example the doc shows how to subscribe a customer from:

Everything is ok for me except a point, how to recover the name of the plans of the connected account?

in the doc example we see "pro-monthly" as the plan name. this plan exists on my platform, but probably not on the connected account ...

however, it is stated that both the plan and the customer must be created on the connected account.

I know how to list the plans of my platform easily with return \ Stripe \ Plan :: all (); for example but how to do the same thing with a connected account?

Because it's good to be able to subscribe customers to connected accounts, but if I do not have the parameter with the name of the plan, I can not guess!

Yours truly Hugo

Upvotes: 0

Views: 660

Answers (1)

duck
duck

Reputation: 5470

To list plans on a Connected Account you'd do:

\Stripe\Plan::all(["limit" => 10],["stripe_account" => "acct_xxxyyyyzzz"]);

You can conduct virtually any operation on a Connected Account, including listing Plans. To do this you need the connected account's id (typically it will look like acct_xxxyyyyyyz), then pass this in the Stripe-Account header.

https://stripe.com/docs/connect/authentication#stripe-account-header

As you are interested in remitting a percentage of the subscription to your platform, you want to pass a application_fee_percent on your subscription creation request, https://stripe.com/docs/connect/subscriptions#collecting-fees-on-subscriptions

$subscription = \Stripe\Subscription::create([
  "customer" => "cus_4fdAW5ftNQow1a",
  "items" => [
    ["plan" => "pro-monthly"],
  ],
  application_fee_percent => 10
], ["stripe_account" => "{CONNECTED_STRIPE_ACCOUNT_ID}"]);

Upvotes: 2

Related Questions