List payments that were made to the merchant who issues the request. Payments can be in any state.
public static all ( array $params, |
||
$params | array | |
$apiContext | is the APIContext for this call. It can be used to pass dynamic configuration and credentials. | |
$restCall | PayPalRestCall | is the Rest Call Service that is used to make rest calls |
Résultat |
public function getList($count = 10, $index = 0) { $apiContext = $this->connectionService->getApiContext(); $dispatcher = $this->connectionService->getDispatcher(); $dispatcher->dispatch(PaymentEvent::GET_ALL_START); $params = array('count' => $count, 'start_index' => $index); $payments = Payment::all($params, $apiContext); $dispatcher->dispatch(PaymentEvent::GET_ALL_END); return $payments->getPayments(); }
public function testOperations() { $p1 = $this->payments['new']; $p1->create(); $this->assertNotNull($p1->getId()); $p2 = Payment::get($p1->getId()); $this->assertNotNull($p2); $paymentHistory = Payment::all(array('count' => '10')); $this->assertNotNull($paymentHistory); }
public static function all($param, $apiContext = null) { if (isset($apiContext)) { return Payment::all($param, $apiContext); } return Payment::all($param); }
// 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 require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Payment; // ### Retrieve payment // Retrieve the PaymentHistory object by calling the // static `get` method on the Payment class, // and pass a Map object that contains // query parameters for paginations and filtering. // Refer the method doc for valid values for keys // (See bootstrap.php for more on `ApiContext`) try { $payments = Payment::all(array('count' => 10, 'start_index' => 5), $apiContext); } catch (PayPal\Exception\PPConnectionException $ex) { echo "Exception:" . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } ?> <html> <head> <title>Lookup payment history</title> </head> <body> <div>Got <?php echo $payments->getCount(); ?> matching payments </div>
<?php // #GetPaymentList // 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 require 'CreatePayment.php'; use PayPal\Api\Payment; // ### Retrieve payment // Retrieve the PaymentHistory object by calling the // static `get` method on the Payment class, // and pass a Map object that contains // query parameters for paginations and filtering. // Refer the method doc for valid values for keys // (See bootstrap.php for more on `ApiContext`) try { $params = array('count' => 10, 'start_index' => 5); $payments = Payment::all($params, $apiContext); } catch (Exception $ex) { ResultPrinter::printError("List Payments", "Payment", null, $params, $ex); exit(1); } ResultPrinter::printResult("List Payments", "Payment", null, $params, $payments);
/** * @dataProvider mockProvider * @param Payment $obj */ public function testList($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(PaymentHistoryTest::getJson())); $params = array(); $result = $obj->all($params, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); }
/** * Get payment list * * @param int $limit Limit number payment * @param int $offset Start index payment * @return mixed Object payment list */ public function getPaymentList($limit = 10, $offset = 0) { $params = ['count' => $limit, 'start_index' => $offset]; try { $payments = Payment::all($params, $this->apiContext); } catch (\PayPal\Exception\PPConnectionException $paypalException) { throw new \Exception($paypalException->getMessage()); } return $payments; }
require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Payment; // ### Authentication // Pass in a `OAuthTokenCredential` object // explicilty to authenticate the call. // If you skip this step, the client id/secret // set in the config file will be used. Payment::setCredential($cred); // ### Retrieve payment // Retrieve the PaymentHistory object by calling the // static `get` method on the Payment class, // and pass a Map object that contains // query parameters for paginations and filtering. // Refer the method doc for valid values for keys try { $payments = Payment::all(array('count' => 10, 'start_index' => 5)); } catch (\PPConnectionException $ex) { echo "Exception:" . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } ?> <html> <body> <div>Got <?php echo $payments->getCount(); ?> matching payments </div> <pre><?php var_dump($payments->toArray()); ?>
function get_payments($count, $offset) { // auth $apiContext = $this->apiContext(); $params = array('count' => $count, 'start_index' => $offset); try { // Get the payment Object by passing paymentId $PaymentHistory = Payment::all($params, $apiContext); $valid = true; } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $valid = false; } $payment_array = array(); if ($valid === true) { $payments = $PaymentHistory->getPayments(); for ($p = 0, $x = count($payments); $p < $x; $p++) { $payment_array[$p] = $this->get_payment_details($payments[$p], true); } } return $payment_array; }