3

I'm trying to get list of invoices for specific customer from Stripe using PHP.

Following is the code I'm using.

 \Stripe\Stripe::setApiKey('STRIPE_SECRET_KEY');
 $response = \Stripe\Invoice::all(array('customer' => 'CUSTOMER_TOKEN'));

But this returns empty array.

Instead, CURL command returns result

 curl https://api.stripe.com/v1/invoices?customer=CUSTOMER_TOKEN  -u STRIPE_SECRET_KEY

Any idea?

I'm using Stripe PHP library available from Github.

https://github.com/stripe/stripe-php

adeltahir
  • 1,087
  • 2
  • 15
  • 31
  • you either pasted the wrong customer id in the code or the wrong secret key if it works with curl and not PHP. – koopajah May 23 '15 at 13:00
  • @koopajah, If I put wrong API secret Key or invalid customer id, I get exception, not empty response. – adeltahir May 23 '15 at 13:53
  • Is the array really empty or are you getting a PHP error here? If it's empty you'd need to contact support and give them the customer id you're trying to retrieve so that they can help you. Otherwise it must mean that something is wrong in your PHP script and seeing the full script (without the keys) would help – koopajah May 23 '15 at 18:53

1 Answers1

2
$response = \Stripe\Invoice::all(array('customer' => 'cus_id'));

You need to add customer id for specific customer.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129