This repository has been archived on 2026-04-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
PayPal-PHP-SDK/sample/vault/ListCreditCards.php
Jay Patel 46d77f15a6 Enabled Vault Credit Card List API
- Added Credit Card List API Operation
- Updated Credit Card to include new properties
- Updated Tests
- Updated Samples
- Fixed Billing Agreement Sample (Expired Set Date).
2015-06-25 12:03:18 -05:00

37 lines
1.3 KiB
PHP

<?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" // Filtering by MerchantId set during CreateCreditCard.
);
$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;