The Credit Card resource allows you to retrieve all previously saved Credit Cards.
API used for it: '/v1/vault/credit-cards'
There are many possible filters that you could apply to it. For complete list, please refere to developer docs here.
use PayPal\Api\CreditCard;
"params = array(
"sort_by" => "create_time",
"sort_order" => "desc",
"merchant_id" => "Your Merchant ID" // Filtering by MerchantId set during CreateCreditCard.
);"
cards = CreditCard::all($params, $apiContext);
The Credit Card resource allows you to delete saved Credit Cards, You must have its unique creditCardId to perform delete
API used for it: /v1/vault/credit-card/{}
The CreditCard resource allows you to update previously saved Credit Cards. Please note that Credit card id is required for it.
API used for it: PATCH /v1/vault/credit-cards/
use PayPal\Api\CreditCard;
use PayPal\Api\Patch;
You could update a credit card by sending patch requests. Each path object would have a specific detail in the object to be updated.
pathOperation = new Patch();
pathOperation->setOp("replace")
->setPath('/expire_month')
->setValue("12");
To add Another Patch Object, You could set more than one patch while updating a credit card.
"pathOperation2 = new Patch();
pathOperation2->setOp('add')
->setPath('/billing_address')
->setValue(json_decode('{
"line1": "111 First Street",
"city": "Saratoga",
"country_code": "US",
"state": "CA",
"postal_code": "95070"
}'));
pathRequest = new \PayPal\Api\PatchRequest();
pathRequest->addPatch($pathOperation)
->addPatch($pathOperation2);"