Showing results for 
Search instead for 
Did you mean: 

List Payments only retrieving 1 payment using the PHP SDK


List Payments only retrieving 1 payment using the PHP SDK

Hey there guys!


I'm pretty new to this stuff I hope I can get some help. I'm using the REST API to issue payments through my website and everything works fine, I'm using the following JS code to issue the order:



 // Render the PayPal button


 // Set your environment

 env: 'production', // sandbox | production

 // Specify the style of the button

 style: {
 label: 'paypal',
 size: 'small', // small | medium | large | responsive
 shape: 'rect', // pill | rect
 color: 'blue', // gold | blue | silver | black
 tagline: false 

 // PayPal Client IDs - replace with your own
 // Create a PayPal app:

 client: {
 //sandbox: 'sandbox client id',
 production: 'production client id'

 payment: function(data, actions) {
 return actions.payment.create({
 payment: {
 transactions: [
 amount: { total: '14.99', currency: 'USD' }
 redirect_urls: {
 return_url: '/index.php',
 cancel_url: '/index.php'
 experience: {
 input_fields: {
 no_shipping: 1

 // onAuthorize() is called when the buyer approves the payment
 onAuthorize: function(data, actions) {

 // Make a call to the REST API to execute the payment
 return actions.payment.execute().then(function() {

 onCancel: function(data, actions) {

 }, '#paypal-button-container');


Everything works fine I get the payment and the order ID, the problem comes when I try to use the PHP SDK to retrieve the List Payments, it's not working ok since it does not retrieve all the payments I've received through the REST API on my website, it is only retrieving 1 payment and I've received 6 using the REST API, I'm using the following PHP code to retrieve the List Payments:


	require __DIR__  . '/PayPal-PHP-SDK/autoload.php';
	require __DIR__  . '/PayPal-PHP-SDK/resultprinter.php';
// # GetPaymentSample
// This sample code demonstrate how you can
// retrieve a list of all Payment resources
// you've created using the Payments API.
// Note various query parameters that you can
// use to filter, and paginate through the
// payments list.
// API used: GET /v1/payments/payments
/** @var Payment $createdPayment */
use PayPal\Api\Payment;
// ### Retrieve payment
// Retrieve the payment object by calling the
// static `get` method
// on the Payment class by passing a valid
// Payment ID
// (See bootstrap.php for more on `ApiContext`)

$apiContext = new \PayPal\Rest\ApiContext(
        new \PayPal\Auth\OAuthTokenCredential(
            'production client id',     // ClientID
            'production secret'    // ClientSecret

$apiContext->setConfig( array( 'mode' => 'live', 'log.LogEnabled' => true, 'log.FileName' => 'PayPal.log', 'log.LogLevel' => 'DEBUG', 'cache.enabled' => true, ) );
try {
    $params = array('count' => 1000, 'start_index' => 0);

    $payments = Payment::all($params, $apiContext);
} catch (Exception $ex) {

    ResultPrinterSmiley Frustratedmiley TonguerintResult("List Payments", "Payment", null, $params, $ex);

ResultPrinterSmiley Frustratedmiley TonguerintResult("List Payments", "Payment", null, $params, $payments);

I've received 6 payments through the REST API but the PHP script only return an object array with 1 value, one single payment instead of 6.


I don't know what I'm doing wrong, I've just issued a new order but no matter what, it's not displaying the new order, it's only displaying 1 old order that I've made with the same REST API, I don't know what I'm doing wrong. The same thing happens if I try to search payment details using the API I can't find any payment using the order ID, I don't understand what I'm doing wrong I will appreciate any help I can have, thanks so much.