List Payments only retrieving 1 payment using the PHP SDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
<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 6 using the REST API, I'm using the following PHP 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:Smiley TonguerintResult("List Payments", "Payment", null, $params, $ex); exit(1); } ResultPrinter:Smiley TonguerintResult("List Payments", "Payment", null, $params, $payments); exit(1); ?>
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.
- Labels:
-
REST SDK

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- where does paypal payments go to if there is no linked phone or email to the seller ? in PayPal Payments Standard
- Couldn't receive International payment in PayPal Payments Standard
- Is it possible to make payments in RON (Romanian Leu) through PayPal? in REST APIs
- [WooCommerce PayPal Payments] - Required phone country code, different than the cards country code. in PayPal Payments Standard
- Assistance Needed: Passing and Retrieving Custom Data in PayPal Webhook Payload in PayPal Payments Standard