10

我想从我的应用程序中创建一个计划。这种情况是用户被收取不同的价格作为经常性付款。所以,这就是为什么我要为每个用户创建计划。

我正在使用laravel 5并使用"laravel/cashier": "~5.0"

4

2 回答 2

15

laravel/cashier 只是没有内置此功能。不过,您并没有不走运,因为只需使用 Stripe 的 API 很容易,该 API 应该作为依赖项下载到您的供应商文件夹中。如果没有,您可以使用 Composer 下载它。

composer require stripe/stripe-php 2.*

你可以使用它

use \Stripe\Plan;

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

您可以在此处阅读更多信息 - https://stripe.com/docs/api#create_plan

于 2015-07-21T05:26:56.997 回答
7

对于最新的收银员和 stripe-php 版本,几乎不需要更改。

我的收银员版本是 7.0 ( "laravel/cashier": "~7.0"),它会自动安装 stripe-php 5。但是一些参数已经从条带 api 改变了。所以这段代码将起作用,

\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"
));

您可以在 Stripe api 文档的 PHP 部分阅读更多内容......(https://stripe.com/docs/api/php#create_plan

于 2018-04-09T11:02:48.210 回答