forked from LiveCarta/PayPal-PHP-SDK
Updates to Sample Code
- Updated UI Presentation on samples - Fixed Bugs
This commit is contained in:
@@ -5,53 +5,20 @@
|
||||
// API used: /v1/vault/credit-card/{<creditCardId>}
|
||||
// NOTE: HTTP method used here is DELETE
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
/** @var CreditCard $card */
|
||||
$card = require 'CreateCreditCard.php';
|
||||
use PayPal\Api\CreditCard;
|
||||
|
||||
// Store a mock card that can be deleted later.
|
||||
// ### CreditCard
|
||||
// A resource representing a credit card that can be
|
||||
// used to fund a payment.
|
||||
$card = new CreditCard();
|
||||
$card->setType("visa")
|
||||
->setNumber("4417119669820331")
|
||||
->setExpireMonth("11")
|
||||
->setExpireYear("2019")
|
||||
->setCvv2("012")
|
||||
->setFirstName("Joe")
|
||||
->setLastName("Shopper");
|
||||
|
||||
// ### Save card
|
||||
// Creates the credit card as a resource
|
||||
// in the PayPal vault. The response contains
|
||||
// an 'id' that you can use to refer to it later.
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
try {
|
||||
$card = $card->create($apiContext);
|
||||
} catch (PayPal\Exception\PPConnectionException $ex) {
|
||||
echo "Exception:" . $ex->getMessage() . PHP_EOL;
|
||||
var_dump($ex->getData());
|
||||
exit(1);
|
||||
// ### Delete Card
|
||||
// Lookup and delete a saved credit card.
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
$creditCard = CreditCard::get($card->getId(), $apiContext);
|
||||
|
||||
$creditCard->delete($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Delete Credit Card", "Credit Card", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
// ### Delete Card
|
||||
// Lookup and delete a saved credit card.
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
|
||||
$creditCard = CreditCard::get($card->getId(), $apiContext);
|
||||
$creditCard->delete($apiContext);
|
||||
} catch (PayPal\Exception\PPConnectionException $ex) {
|
||||
echo "Exception: " . $ex->getMessage() . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>Delete a saved credit card</title>
|
||||
</head>
|
||||
<body>
|
||||
<p> Credit Card deleted Successfully</p>
|
||||
<a href='../index.html'>Back</a>
|
||||
</body>
|
||||
</html>
|
||||
ResultPrinter::printResult("Delete Credit Card", "Credit Card", $card->getId(), null, $creditCard);
|
||||
|
||||
Reference in New Issue
Block a user