Retrieves a list of Credit Card resources.
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 | is the Rest Call Service that is used to make rest calls | |
return | PayPal\Api\CreditCardList |
public function getAll($sortBy = CreditCardConst::SORT_BY_CREATE_TIME, $sortOrder = CreditCardConst::SORT_ORDER_DESC) { $apiContext = $this->connectionService->getApiContext(); $dispatcher = $this->connectionService->getDispatcher(); $dispatcher->dispatch(CreditCardEvent::GET_ALL_START); $params = array('sort_by' => $sortBy, 'sort_order' => $sortOrder); $cards = CreditCard::all($params, $apiContext); $dispatcher->dispatch(CreditCardEvent::GET_ALL_END); return $cards; }
/** * @dataProvider mockProvider * @param CreditCard $obj */ public function testList($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(CreditCardListTest::getJson())); $params = array(); $result = $obj->all($params, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); }
<?php // # List Credit Card Sample // The CreditCard resource allows you to // retrieve all previously saved CreditCards. // API called: '/v1/vault/credit-cards' // Documentation: https://developer.paypal.com/webapps/developer/docs/api/#list-credit-card-resources // Creating a Credit Card just in case /** @var CreditCard $card */ $card = (require 'CreateCreditCard.php'); use PayPal\Api\CreditCard; /// ### List All Credit Cards // (See bootstrap.php for more on `ApiContext`) try { // ### Parameters to Filter // There are many possible filters that you could apply to it. For complete list, please refere to developer docs at above link. $params = array("sort_by" => "create_time", "sort_order" => "desc", "merchant_id" => "MyStore1"); $cards = CreditCard::all($params, $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("List All Credit Cards", "CreditCardList", null, $params, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("List All Credit Cards", "CreditCardList", null, $params, $cards); return $card;