dou29106 2017-04-07 16:02
浏览 17

无法在订阅计划中获取交易ID

I am working with Stripe payment option for my project. I have a recurring option and that's why I have created plans in subscription page.

After creating plans I have defined my plan when a new stripe customer register.

try {
    $customer = \Stripe\Customer::create([
    'source' => $token,
    'email' => $email,
    'plan' => '20-39-R',
    'metadata' => [
        "First Name" => $first_name,
        "Last Name" => $last_name
    ]
    ]);
} catch (\Stripe\Error\Card $e) {
    return redirect()->route('order')
        ->withErrors($e->getMessage())
        ->withInput();
}

When I have dump($customer) variable I am not getting transaction id.

Any idea why I am not getting transaction id during customer creation?Here is my <code>dump($customer)</code> response

  • 写回答

1条回答 默认 最新

  • duanbing8817 2017-04-07 18:32
    关注

    The customer object doesn't store a list of transaction ids which I think is what you'd call the id of the charge made on that customer's card right? The customer holds information about the sources (used to pay) and subscriptions that are created after a customer is subscribed to a plan.

    Here you can see a sub_XXXXX in subscriptions[data][0][id] which corresponds to the id of the subscription that was created on that customer for your plan 20-39-R.

    If you want the charge id, ch_XXXXX you would use the List ChargesAPI and pass the customer id, cus_XXXXX, in the `customer parameter to limit the charges to the ones created on that customer. The first one in the list would be the latest charge and likely the one corresponding to your subscription. You could confirm this by checking the invoice associated with the charge and confirming that it's for your subscription.

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向