forked from LiveCarta/PayPal-PHP-SDK
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).
This commit is contained in:
@@ -22,6 +22,17 @@ $card->setType("visa")
|
||||
->setFirstName("Joe")
|
||||
->setLastName("Shopper");
|
||||
|
||||
// ### Additional Information
|
||||
// Now you can also store the information that could help you connect
|
||||
// your users with the stored credit cards.
|
||||
// All these three fields could be used for storing any information that could help merchant to point the card.
|
||||
// However, Ideally, MerchantId could be used to categorize stores, apps, websites, etc.
|
||||
// ExternalCardId could be used for uniquely identifying the card per MerchantId. So, combination of "MerchantId" and "ExternalCardId" should be unique.
|
||||
// ExternalCustomerId could be userId, user email, etc to group multiple cards per user.
|
||||
$card->setMerchantId("MyStore1");
|
||||
$card->setExternalCardId("CardNumber123" . uniqid());
|
||||
$card->setExternalCustomerId("123123-myUser1@something.com");
|
||||
|
||||
// For Sample Purposes Only.
|
||||
$request = clone $card;
|
||||
|
||||
|
||||
36
sample/vault/ListCreditCards.php
Normal file
36
sample/vault/ListCreditCards.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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;
|
||||
Reference in New Issue
Block a user