Create plan on stripe through laravel
Asked Answered
C

2

11

I want to create a plan from my application on stripe. The scenario is that users are charged with different prices as recurring payments. So, that is why I want to create plan for each user.

I am using laravel 5 and using "laravel/cashier": "~5.0"

Certifiable answered 13/6, 2015 at 9:45 Comment(0)
D
16

laravel/cashier just doesn't have this functionality baked in. You aren't out of luck though as it is easy to just use Stripe's API which should be downloaded as a dependency in your vendor folder. If not you can just download it with composer.

composer require stripe/stripe-php 2.*

You can use it with

use \Stripe\Plan;

Plan::create(array(
  "amount" => 2000,
  "interval" => "month",
  "name" => "Amazing Gold Plan",
  "currency" => "usd",
  "id" => "gold")
);

You can read more here - https://stripe.com/docs/api#create_plan

Destination answered 21/7, 2015 at 5:26 Comment(1)
may I ask you to take a look at a l Stripe rekated question here : #62239051 ?Heise
B
7

For latest cashier and stripe-php versions few thing need to be changed.

My cashier version is 7.0 ("laravel/cashier": "~7.0") and it automatically installs stripe-php 5. But some parameters has changed from stripe api. So this code will be working,

\Stripe\Stripe::setApiKey("sk_test_your_key");

\Stripe\Plan::create(array(
  "amount" => 5000,
  "interval" => "month",
  "product" => array(
    "name" => "Bronze standard"
  ),
  "currency" => "eur",
  "id" => "bronze-standard"
));

And you can read more in PHP section of stripe api docs... (https://stripe.com/docs/api/php#create_plan)

Ballesteros answered 9/4, 2018 at 11:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.