【问题标题】:Stripe determining paid subscription statusesStripe 确定付费订阅状态
【发布时间】:2020-08-29 12:10:36
【问题描述】:

我的应用结构如下:

orders table
order_id   subscription_id 
1          sub_AXXXXX
2          sub_BXXXXX

payments table
pid order_id   payment_status  date           charge_id
1    1        complete        1 May 2020      ch_XXXXX
2    1        pending         2 June 2020   
3    1        pending         3 July 2019     
4    2        complete        1 April 2020    ch_XXXXX
5    2        complete        1 May 2020       
6    2        pending         1 June 2020 
  • 我知道你先创建条带客户(你得到 $customer->id)
  • 然后创建产品(你得到$product->id)
  • 然后制定计划

$plan = Plan::create(['currency' => 'usd', 'interval' => 'month', 'product' => $product->id,interval_count': 3, 'amount' = > 10 ]);

  • 然后我创建订阅

    "customer" => $customer->id,'plan' => $plan, 'metadata' => [ 'order_id' => $order_id, ],'prorate' => false

问题 1 我如何从条带中检查 order_id/subscription_id,在 order_id 1 的 3 次中成功支付了多少费用。

我是否需要查询订阅的所有发票才能执行此操作。但是,除了遍历日期之外,您如何确定付款的月份和失败的月份。 如果每个月的付款成功,是否会在任何地方更新计划的 interval_count。

问题 2 如何检查是否有任何付款失败案例:如果 pid 2 付款失败,我该如何显示。

出于各种原因,我真的不想使用/依赖网络震动事件。

【问题讨论】:

    标签: php stripe-payments


    【解决方案1】:

    我在完全理解您的表中订阅 ID 和费用 ID 之间的关系时遇到了一些麻烦,但我可以尝试从 API 的角度回答其中一个问题。如果您有一个支付失败的订阅 sub_AXXX,即订阅状态为incomplete(创建后失败)或past_due(重复计费后失败),您可以展开latest_invoice [1],从那里展开payment_intent [2] 并检查 last_payment_error [3]。这应该会给你关于发生了什么的信息。

    [1]https://stripe.com/docs/api/subscriptions/object#subscription_object-latest_invoice

    [2]https://stripe.com/docs/api/invoices/object#invoice_object-payment_intent

    [3]https://stripe.com/docs/api/payment_intents/object#payment_intent_object-last_payment_error

    【讨论】:

      猜你喜欢
      • 2018-12-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-20
      • 1970-01-01
      • 2018-09-19
      • 2017-10-16
      • 1970-01-01
      • 2018-06-21
      相关资源
      最近更新 更多