Updating samples to use fluent setters + doc fixes

This commit is contained in:
aydiv
2013-08-22 17:24:04 +05:30
parent 14b9a13f8a
commit f4d687b52b
27 changed files with 422 additions and 893 deletions

View File

@@ -1,50 +1,50 @@
<?php
// # Create Credit Card Sample
// Using the 'vault' API, you can store a
// Credit Card securely on PayPal. You can
// use a saved Credit Card to process
// a payment in the future.
// The following code demonstrates how
// can save a Credit Card on PayPal using
// the Vault API.
// API used: POST /v1/vault/credit-card
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\CreditCard;
use PayPal\Api\Address;
// ### CreditCard
// A resource representing a credit card that can be
// used to fund a payment.
$card = new CreditCard();
$card->setType("visa");
$card->setNumber("4417119669820331");
$card->setExpireMonth("11");
$card->setExpireYear("2019");
$card->setCvv2("012");
$card->setFirstName("Joe");
$card->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
// in the future payments.
// (See bootstrap.php for more on `ApiContext`)
try {
$card->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception:" . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<body>
<div>Saved a new credit card with id: <?php echo $card->getId();?></div>
<pre><?php var_dump($card);?></pre>
<a href='../index.html'>Back</a>
</body>
// # Create Credit Card Sample
// Using the 'vault' API, you can store a
// Credit Card securely on PayPal. You can
// use a saved Credit Card to process
// a payment in the future.
// The following code demonstrates how
// can save a Credit Card on PayPal using
// the Vault API.
// API used: POST /v1/vault/credit-card
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\CreditCard;
use PayPal\Api\Address;
// ### 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
// in future payments.
// (See bootstrap.php for more on `ApiContext`)
try {
$card->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception:" . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<body>
<div>Saved a new credit card with id: <?php echo $card->getId();?></div>
<pre><?php var_dump($card);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -14,13 +14,13 @@ use PayPal\Api\Address;
// A resource representing a credit card that can be
// used to fund a payment.
$card = new CreditCard();
$card->setType("visa");
$card->setNumber("4417119669820331");
$card->setExpireMonth("11");
$card->setExpireYear("2019");
$card->setCvv2("012");
$card->setFirstName("Joe");
$card->setLastName("Shopper");
$card->setType("visa")
->setNumber("4417119669820331")
->setExpireMonth("11")
->setExpireYear("2019")
->setCvv2("012")
->setFirstName("Joe")
->setLastName("Shopper");
// ### Save card
// Creates the credit card as a resource
@@ -29,14 +29,14 @@ $card->setLastName("Shopper");
// in the future payments.
// (See bootstrap.php for more on `ApiContext`)
try {
$res = $card->create($apiContext);
$card = $card->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception:" . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
$creditCard = CreditCard::get($res->getId(), $apiContext);
$creditCard = CreditCard::get($card->getId(), $apiContext);
try {
// ### Delete Card
// deletes saved credit card
@@ -50,7 +50,6 @@ try {
<html>
<body>
<div>Delete CreditCard:</div>
<p> Credit Card deleted Successfully</p>
<a href='../index.html'>Back</a>
</body>

View File

@@ -1,33 +1,33 @@
<?php
// # Get Credit Card Sample
// The CreditCard resource allows you to
// retrieve previously saved CreditCards,
// by sending a GET request to the URI
// '/v1/vault/credit-card'
// The following code takes you through
// the process of retrieving a saved CreditCard
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\CreditCard;
// The cardId can be obtained from a previous save credit
// card operation. Use $card->getId()
$cardId = "CARD-5AR29593TC404090HKIKN77Q";
/// ### Retrieve card
// (See bootstrap.php for more on `ApiContext`)
try {
$card = CreditCard::get($cardId, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<body>
<div>Retrieving credit card: <?php echo $cardId;?></div>
<pre><?php var_dump($card);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>
<?php
// # Get Credit Card Sample
// The CreditCard resource allows you to
// retrieve previously saved CreditCards,
// by sending a GET request to the URI
// '/v1/vault/credit-card'
// The following code takes you through
// the process of retrieving a saved CreditCard
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\CreditCard;
// The cardId can be obtained from a previous save credit
// card operation. Use $card->getId()
$cardId = "CARD-5AR29593TC404090HKIKN77Q";
/// ### Retrieve card
// (See bootstrap.php for more on `ApiContext`)
try {
$card = CreditCard::get($cardId, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<body>
<div>Retrieving credit card: <?php echo $cardId;?></div>
<pre><?php var_dump($card);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>