【发布时间】:2021-03-26 15:56:46
【问题描述】:
如果这是该特定客户第一次为此特定订阅付费。 我必须根据选择的计划 ID 设置订阅的 cancel_at 字段。 (我不想在创建订阅时设置它)。为了解决这个第一次,我捕获了 invoice.payment_succeeded 事件并执行了以下操作:
$invoices = \Stripe\Invoice::all([
"limit" => 3, //no need to get all of the invoices just checking if their number is = 1.
"status" => 'paid',
"customer" => $customer_id,
"subscription" => $subscription_id,
"expand" => ["data.charge"],
]);
if ( count($invoices->data) == 1 ) {
//First time this user pays for this specific subscription;
你能告诉我它是否正确,或者我是否错过了任何东西,因为我是 php 和 stripe 的新手。我应该做 count($invoices) 而不是我所做的吗?
【问题讨论】:
标签: stripe-payments