Updating sample comments

This commit is contained in:
aydiv
2013-08-26 12:21:29 +05:30
parent b1f1887cec
commit 05a4aef55e
18 changed files with 180 additions and 121 deletions

View File

@@ -1,23 +1,18 @@
<?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.
// You can store credit card details securely
// with PayPal. You can then use the returned
// Credit card id to process future payments.
// 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.
// A resource representing a credit card that is
// to be stored with PayPal.
$card = new CreditCard();
$card->setType("visa")
->setNumber("4417119669820331")
@@ -42,6 +37,9 @@ try {
}
?>
<html>
<head>
<title>Save a credit card</title>
</head>
<body>
<div>Saved a new credit card with id: <?php echo $card->getId();?></div>
<pre><?php var_dump($card);?></pre>

View File

@@ -1,15 +1,14 @@
<?php
// # Delete CreditCard Sample
// This sample code demonstrate how you can
//delete a saved creditcard
// using the delete API.
// delete a saved credit card.
// API used: /v1/vault/credit-card/{<creditCardId>}
// NOTE: HTTP method used here is DELETE
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\CreditCard;
use PayPal\Api\Address;
// save card for demo
// Store a mock card that can be deleted later.
// ### CreditCard
// A resource representing a credit card that can be
// used to fund a payment.
@@ -25,8 +24,7 @@ $card->setType("visa")
// ### 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.
// an 'id' that you can use to refer to it later.
// (See bootstrap.php for more on `ApiContext`)
try {
$card = $card->create($apiContext);
@@ -36,19 +34,22 @@ try {
exit(1);
}
$creditCard = CreditCard::get($card->getId(), $apiContext);
try {
// ### Delete Card
// deletes 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>

View File

@@ -2,9 +2,8 @@
// # 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'
// retrieve previously saved CreditCards.
// API called: '/v1/vault/credit-card'
// The following code takes you through
// the process of retrieving a saved CreditCard
require __DIR__ . '/../bootstrap.php';
@@ -25,8 +24,11 @@ try {
}
?>
<html>
<head>
<title>Lookup a saved credit card</title>
</head>
<body>
<div>Retrieving credit card: <?php echo $cardId;?></div>
<div>Retrieving saved credit card: <?php echo $cardId;?></div>
<pre><?php var_dump($card);?></pre>
<a href='../index.html'>Back</a>
</body>