我使用 laravel 5 和收银员。除了向客户添加卡片外,一切都在工作。所以我错过了一些东西,我只是不知道是什么。
我得到这两个错误:
1. Stripe Notice: Undefined property of Stripe_Customer instance: cards
2. PHP Fatal error: Call to a member function create() on null in /app/Repositories/Billing/StripeGateway.php on line 56
正在引用的创建:
public function createCard($customer_id, $token) {
$cu = Customer::retrieve($customer_id);
//1 $card = $cu->card->create(["source" => $token]);
//2 $card = $cu->source->create(["source" => $token]);
$card = $cu->source->create(["card" => $token]);
return $card;
}
基本上看起来我的客户对象没有正确引用我的卡/源对象......但我不知道我需要做什么。
任何帮助都非常感谢
好的,
所以它有助于读取 API。 正确的实现是
$card = $cu->sources->create(["source" => $token]);
注意来源是复数的。我使用的是源而不是源。我花了很多时间无缘无故地修补东西。