cancel
Showing results for 
Search instead for 
Did you mean: 

List Payments not retrieving all payments

Member

List Payments not retrieving all payments

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 <removed> and everything works fine, I'm using the following JS code yo issue the order:

 

 

<script>

// Render the PayPal button

paypal.Button.render({

// 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: https://developer.paypal.com/developer/applications/create

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() {
actions.redirect();
}
);
},

onCancel: function(data, actions) {
actions.redirect();
}

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

</script>

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 4, I'm using the following code to retrieve the List Payments:

 

 

<?php
	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) {

    ResultPrinter::printResult("List Payments", "Payment", null, $params, $ex);
    exit(1);
}

ResultPrinter::printResult("List Payments", "Payment", null, $params, $payments);
exit(1);
	?>

I've received 4 payments through the REST API but as you can see here the paments counts is only 1:

 

 

1. List Payments
Request Object
Array
(
    [count] => 1000
    [start_index] => 0
)
Response Object
{
    "payments": [
        {
            "id": "PAYID-LO54BHA7AG75843948893509",
            "intent": "sale",
            "state": "approved",
            "cart": "4K127932J0040083T",
            "payer": {
                "payment_method": "paypal",
                "status": "VERIFIED",
                "payer_info": {
                    "email": "hidden",
                    "first_name": "Juan Jose",
                    "last_name": "Huerta Torres",
                    "payer_id": "KR3JVJQNMF7UG",
                    "shipping_address": {
                        "recipient_name": "Juan Jose Huerta Torres"
                    },
                    "phone": "7773635312",
                    "country_code": "MX"
                }
            },
            "transactions": [
                {
                    "amount": {
                        "total": "14.99",
                        "currency": "USD",
                        "details": {
                            "subtotal": "14.99",
                            "shipping": "0.00",
                            "insurance": "0.00",
                            "handling_fee": "0.00",
                            "shipping_discount": "0.00"
                        }
                    },
                    "payee": {
                        "merchant_id": "47KN2NLRKXSSL",
                        "email": "hidden"
                    },
                    "soft_descriptor": "PAYPAL *SIMPLESOLUT",
                    "item_list": {
                        "shipping_address": {
                            "recipient_name": "Juan Jose Huerta Torres"
                        }
                    },
                    "related_resources": [
                        {
                            "sale": {
                                "id": "0V429233M9875821C",
                                "state": "refunded",
                                "amount": {
                                    "total": "14.99",
                                    "currency": "USD",
                                    "details": {
                                        "subtotal": "14.99",
                                        "shipping": "0.00",
                                        "insurance": "0.00",
                                        "handling_fee": "0.00",
                                        "shipping_discount": "0.00"
                                    }
                                },
                                "payment_mode": "INSTANT_TRANSFER",
                                "protection_eligibility": "INELIGIBLE",
                                "transaction_fee": {
                                    "value": "1.11",
                                    "currency": "USD"
                                },
                                "receivable_amount": {
                                    "value": "298.87",
                                    "currency": "MXN"
                                },
                                "exchange_rate": "19.938086asdasdas311393996",
                                "parent_payment": "PAYID-LO54BHA7AG75843948893509",
                                "create_time": "2018-10-08T20:40:28Z",
                                "update_time": "2018-10-08T20:41:50Z",
                                "links": [
                                    {
                                        "href": "https://api.paypal.com/v1/payments/sale/0V429233M9875821C",
                                        "rel": "self",
                                        "method": "GET"
                                    },
                                    {
                                        "href": "https://api.paypal.com/v1/payments/sale/0V429233M9875821C/refund",
                                        "rel": "refund",
                                        "method": "POST"
                                    },
                                    {
                                        "href": "https://api.paypal.com/v1/payments/payment/PAYID-LO54BHA7AG75843948893509",
                                        "rel": "parent_payment",
                                        "method": "GET"
                                    }
                                ],
                                "soft_descriptor": "PAYPAL *SIMPLESOLUT"
                            }
                        },
                        {
                            "refund": {
                                "id": "8U7235895W693942F",
                                "state": "completed",
                                "amount": {
                                    "total": "-14.99",
                                    "currency": "USD"
                                },
                                "parent_payment": "PAYID-LO54BHA7AG75843948893509",
                                "sale_id": "0V429233M9875821C",
                                "create_time": "2018-10-08T20:41:50Z",
                                "update_time": "2018-10-08T20:41:50Z",
                                "links": [
                                    {
                                        "href": "https://api.paypal.com/v1/payments/refund/8U7235895W693942F",
                                        "rel": "self",
                                        "method": "GET"
                                    },
                                    {
                                        "href": "https://api.paypal.com/v1/payments/payment/PAYID-LO54BHA7AG75843948893509",
                                        "rel": "parent_payment",
                                        "method": "GET"
                                    },
                                    {
                                        "href": "https://api.paypal.com/v1/payments/sale/0V429233M9875821C",
                                        "rel": "sale",
                                        "method": "GET"
                                    }
                                ]
                            }
                        }
                    ]
                }
            ],
            "create_time": "2018-10-08T20:39:56Z",
            "update_time": "2018-10-08T20:41:50Z",
            "links": [
                {
                    "href": "https://api.paypal.com/v1/payments/payment/PAYID-LO54BHA7AG75843948893509",
                    "rel": "self",
                    "method": "GET"
                }
            ]
        }
    ],
    "count": 1
}
Request
Response
Request Object
Array
(
    [count] => 1000
    [start_index] => 0
)
Response Object
{
    "payments": [
        {
            "id": "PAYID-LO54BHA7AG75843948893509",
            "intent": "sale",
            "state": "approved",
            "cart": "4K127932J0040083T",
            "payer": {
                "payment_method": "paypal",
                "status": "VERIFIED",
                "payer_info": {
                    "email": "hidden",
                    "first_name": "Juan Jose",
                    "last_name": "Huerta Torres",
                    "payer_id": "KR3JVJQNMF7UG",
                    "shipping_address": {
                        "recipient_name": "Juan Jose Huerta Torres"
                    },
                    "phone": "7773635312",
                    "country_code": "MX"
                }
            },
            "transactions": [
                {
                    "amount": {
                        "total": "14.99",
                        "currency": "USD",
                        "details": {
                            "subtotal": "14.99",
                            "shipping": "0.00",
                            "insurance": "0.00",
                            "handling_fee": "0.00",
                            "shipping_discount": "0.00"
                        }
                    },
                    "payee": {
                        "merchant_id": "47KN2NLRKXSSL",
                        "email": "hidden"
                    },
                    "soft_descriptor": "PAYPAL *SIMPLESOLUT",
                    "item_list": {
                        "shipping_address": {
                            "recipient_name": "Juan Jose Huerta Torres"
                        }
                    },
                    "related_resources": [
                        {
                            "sale": {
                                "id": "0V429233M9875821C",
                                "state": "refunded",
                                "amount": {
                                    "total": "14.99",
                                    "currency": "USD",
                                    "details": {
                                        "subtotal": "14.99",
                                        "shipping": "0.00",
                                        "insurance": "0.00",
                                        "handling_fee": "0.00",
                                        "shipping_discount": "0.00"
                                    }
                                },
                                "payment_mode": "INSTANT_TRANSFER",
                                "protection_eligibility": "INELIGIBLE",
                                "transaction_fee": {
                                    "value": "1.11",
                                    "currency": "USD"
                                },
                                "receivable_amount": {
                                    "value": "298.87",
                                    "currency": "MXN"
                                },
                                "exchange_rate": "hidden",
                                "parent_payment": "PAYID-LO54BHA7AG75843948893509",
                                "create_time": "2018-10-08T20:40:28Z",
                                "update_time": "2018-10-08T20:41:50Z",
                                "links": [
                                    {
                                        "href": "https://api.paypal.com/v1/payments/sale/0V429233M9875821C",
                                        "rel": "self",
                                        "method": "GET"
                                    },
                                    {
                                        "href": "https://api.paypal.com/v1/payments/sale/0V429233M9875821C/refund",
                                        "rel": "refund",
                                        "method": "POST"
                                    },
                                    {
                                        "href": "https://api.paypal.com/v1/payments/payment/PAYID-LO54BHA7AG75843948893509",
                                        "rel": "parent_payment",
                                        "method": "GET"
                                    }
                                ],
                                "soft_descriptor": "PAYPAL *SIMPLESOLUT"
                            }
                        },
                        {
                            "refund": {
                                "id": "8U7235895W693942F",
                                "state": "completed",
                                "amount": {
                                    "total": "-14.99",
                                    "currency": "USD"
                                },
                                "parent_payment": "PAYID-LO54BHA7AG75843948893509",
                                "sale_id": "0V429233M9875821C",
                                "create_time": "2018-10-08T20:41:50Z",
                                "update_time": "2018-10-08T20:41:50Z",
                                "links": [
                                    {
                                        "href": "https://api.paypal.com/v1/payments/refund/8U7235895W693942F",
                                        "rel": "self",
                                        "method": "GET"
                                    },
                                    {
                                        "href": "https://api.paypal.com/v1/payments/payment/PAYID-LO54BHA7AG75843948893509",
                                        "rel": "parent_payment",
                                        "method": "GET"
                                    },
                                    {
                                        "href": "https://api.paypal.com/v1/payments/sale/0V429233M9875821C",
                                        "rel": "sale",
                                        "method": "GET"
                                    }
                                ]
                            }
                        }
                    ]
                }
            ],
            "create_time": "2018-10-08T20:39:56Z",
            "update_time": "2018-10-08T20:41:50Z",
            "links": [
                {
                    "href": "https://api.paypal.com/v1/payments/payment/PAYID-LO54BHA7AG75843948893509",
                    "rel": "self",
                    "method": "GET"
                }
            ]
        }
    ],
    "count": 1

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.