Update customer using Stripe-php v1.18.0

100 views
Skip to first unread message

Xia

unread,
Jul 17, 2019, 12:50:26 PM7/17/19
to Stripe API Discussion
Hello, we're using String-php v1.18.0, and I'm trying to update customer information through Stripe API, and according to the documentation, this can be done like this:
\Stripe\Stripe::setApiKey("sk_test_IQJ1661sgZIUesKzSzUxnVRr");
\Stripe\Customer::update(
'cus_9gpuhuCtsI9GAK',
[
'metadata' => ['order_id' => '6735'],
]
);

But when I added this in my code, it does not work. No errors but it's just doing nothing. So I looked into the code of Customer.php, there's no function called "update", would this be the reason?  Is updating customer a newer feature? Is there a way to update customer information with stripe-php v1.18.0? 

Thank you!

Remi J.

unread,
Jul 17, 2019, 12:56:14 PM7/17/19
to api-d...@lists.stripe.com
Hello Xia,

The version 1.18.0 for stripe-php was released in January 2015. At the time, we supported PHP 5.2 which did not support namespaces which is why this code does not work on your version. We dropped support for PHP 5.2 in 2.0.0 in February 2015 and added namespace support at the time.

I would highly recommend upgrading your codebase to use the latest version of stripe-php (6.40.0) though the library changed completely since then. You can read more about all the changes in our changelog: https://github.com/stripe/stripe-php/blob/master/CHANGELOG.md

If you can't upgrade, you would have to use the API the way it worked at the time this version of the library was created. You would have to fetch the Customer and then update it like this:

$customer = Stripe_Customer::retrieve('cus_123');
$customer->metadata['order_id'] = '6735';
$customer->save();

Hope this helps!
Remi

--
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.

Xia Dong

unread,
Jul 17, 2019, 1:06:40 PM7/17/19
to api-d...@lists.stripe.com
Hi Remi,

thank you so much for the reply. We would consider upgrading to a newer version.

Best regards,
Xia
Reply all
Reply to author
Forward
0 new messages