Laravel Cashier + Stripe:没有这样的客户 [英] Laravel Cashier + Stripe: No Such Customer

查看:173
本文介绍了Laravel Cashier + Stripe:没有这样的客户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel Cashier和Stripe开发Web应用程序的订阅.

I am working on developing a subscription for a web application using Laravel Cashier and Stripe.

我正在使用Stripe v3 JavaScript API,并使用card元素生成Stripe令牌.正在生成Stripe令牌,如果您在Stripe仪表板中查看,则会创建一个客户.此外,在用户数据库中保存了一个带区ID.但是,当我尝试使用以下代码为用户订阅计划时:

I'm using Stripe v3 JavaScript API and using the card elements to generate the Stripe token. The Stripe token is being generated, and if you look in the Stripe dashboard a customer is created. Additionally, a stripe id is being saved in the user database. However, when I try and subscribe the user to a plan with the following code:

$user->newSubscription($planId, $planId)->create($stripeToken, [
            'email' => $user->email
]);

它失败,并显示错误:没有这样的客户:cus_xxxxxx". $ planId变量是Stripe中计划的ID.

It fails with the error: "No such customer: cus_xxxxxx". The $planId variable is the ID of the plan in Stripe.

就像我说过的那样,条纹令牌正在正确生成,在条纹控制台中创建了客户,并且在数据库中设置了条纹ID.我已经对Laravel Cashier代码进行了深入研究,当它尝试更新卡信息时似乎出现了错误.更具体地说,它在此功能上失败:

Like I said, the stripe token is being generated correctly, the customer is created in the Stripe dashboard, and the stripe id is being set in the database. I've done some digging into the Laravel Cashier code, and it seems to be getting the error when it tries to update the card info. More specifically, it fails at this function:

public function asStripeCustomer()

在可计费模型中找到哪个.

Which is found in the billable model.

我联系了Stripe支持,他们说在创建最初的客户之后,没有对其API的进一步请求.

I contacted Stripe support, and they said there are no further requests being made to their API after the initial customer is created.

我的laravel版本是5.5.34,我正在使用最新的Cashier版本.我尝试过重新安装Cashier,但仍然无法正常工作.我还刷新了缓存.

My laravel version is 5.5.34, and I'm using the latest Cashier release. I've tried reinstalling Cashier and it still doesn't work. I've also refreshed my cache.

非常感谢您的帮助.

推荐答案

以防万一将来其他人遇到此问题,我设法将其修复.

Just in case anyone else faces this issue in the future, I managed to get it fixed.

从本质上讲,问题出在您的数据库设置上.对我来说,我的数据库设置将所有内容都保存为小写. Stripe的客户密钥区分大小写.在将数据库更改为区分大小写之后,重新开始工作.

Essentially, the issue comes down to your database settings. For me, my database settings were saving everything lowercased. Stripe is case sensitive with its customer keys. After I changed my database to be case sensitive began to work again.

这篇关于Laravel Cashier + Stripe:没有这样的客户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆