Stripe: 如何在没有计划的情况下设置定期付款?

我第一次合作 Stripe API. 实现它 WordPress 使用 PHP 和 JS.
我致力于捐赠的形式。 捐助者应该能够选择这个建议 /开关-25.50,75,100./ 或以智慧支付 /选择后的文本字段 'other'/. 我能够做到它。

有一个复选框可以将金额设置为重复付款。 我为固定选项创建了经常性付款计划,例如 25, 50, 100 等等。

如果捐赠者选择自定义金额,如何配置重新付款? 我找不到相应的 API. 请帮忙。
已邀请:

龙天

赞同来自:

另一种提供的方法 Stripe, 它是以重复金额建立一个计划 $1 /或者 $0.01 更大的灵活性/, 然后根据需要改变金额。

例如,使用计划的方法 $0.01, 如果我想收费 12.50/month, 我可以调整以下金额:


$customer->subscriptions->create/array/"plan" => "basic", "quantity" => "1250"//;


条带支持

https://support.stripe.com/que ... price
https://stripe.com/blog/new-re ... tures

诸葛浮云

赞同来自:

首先,你需要
https://stripe.com/docs/api/php#create_customer
.

发送时,可以使用自定义
https://stripe.com/docs/api/php#create_plan
:


$current_time = time//;
$plan_name = strval/ $current_time /;

Stripe_Plan::create/array/
"amount" => $_POST['custom-amount'],
"interval" => "month",
"name" => "Some Plan Name " . $_POST['customer-name'],
"currency" => "usd",
"id" => $plan_name
/
/;


想到这一点
'id'

必须是独一无二的。 您可以使用客户端名称,时间标记或任何其他随机方法来确保它始终如一。

然后你很简单
https://stripe.com/docs/api/ph ... ption
:


$customer = Stripe_Customer::retrieve/$customer_just_created/;
$customer->subscriptions->create/array/"plan" => $plan_name//;


您可能能够省略上面的第一个字符串,因为您已经有变量 customer, 自实行客户创建以来分配。

詹大官人

赞同来自:

它是低技术,但我发现的最简单 - 它尽可能少地使用 Stripe API. 你很简单,而不是创建订阅计划,产品等,而不是创建订阅计划,而且

创建客户端客户端。

向他们留言 cron.

如果您已经知道如何为某人收取费用,您只需要了解如何创建客户端,然后 rest 好的。

这意味着你携带了一部分的心灵 Stripe 在我们自己的基础设施上,但事实上我更容易考虑它/维护而不是想想所有文件和功能 Stripe API.

要回复问题请先登录注册