0

Im using laravel 5 and cashier. Everything is working except for adding cards to a customer. So I'm missing something, i just don't know what.

I get these 2 errrors:

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

The create that is being referenced:

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;
}

Basically it looks like my customer object isn't properly referencing my card/source object... but i don't know what i need to do.

Any help is greatly appreciated

brandenwagner
  • 138
  • 1
  • 5
  • 20
  • I think it's due to a recent change in the Stripe API where card/cards have been replaced with source/sources. If Cashier hasn't been updated you might need to do it yourself: https://stripe.com/docs/upgrades#2015-02-18 – koopajah Apr 26 '15 at 14:06
  • So i don't think thats the issue. but i could be wrong. I'm trying to figure it out... How would i go about testing that manually? – brandenwagner Apr 27 '15 at 01:21
  • So i found an error, but after some tinkering I'm back at square one. My stripe library was for the wrong version of cashier.. so now I've made sure everything is upgraded and my library is also upgraded... but still the same error – brandenwagner Apr 27 '15 at 01:32

1 Answers1

0

Ok so it helps to READ the API. correct implementation is

$card = $cu->sources->create(["source" => $token]);

NOTICE sources is plural.. I was using source NOT source. I spent way to much time tinkering with things for no reason.

brandenwagner
  • 138
  • 1
  • 5
  • 20