You can capture and process a previously created authorization
by invoking the $authorization->capture method
-with a valid ApiContext (See bootstrap.php for more on ApiContext)
$getCapture=$authorization->capture($capture,$apiContext);}catch(PayPal\Exception\PPConnectionException$ex){echo"Exception: ".$ex->getMessage().PHP_EOL;var_dump($ex->getData());
@@ -28,14 +27,15 @@ createAuthorization defined in common.php
\ No newline at end of file
diff --git a/sample/source/CreateCreditCard.html b/sample/source/CreateCreditCard.html
index 9ca4434..e3a0edd 100644
--- a/sample/source/CreateCreditCard.html
+++ b/sample/source/CreateCreditCard.html
@@ -1,25 +1,20 @@
-CreateCreditCard
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
Creates the credit card as a resource
in the PayPal vault. The response contains
@@ -34,9 +29,12 @@ in future payments.
}?><html>
+<head>
+ <title>Save a credit card</title>
+</head><body> <div>Saved a new credit card with id: <?phpecho$card->getId();?></div> <pre><?phpvar_dump($card);?></pre> <a href='../index.html'>Back</a></body>
-</html>
\ No newline at end of file
diff --git a/sample/source/CreatePayment.html b/sample/source/CreatePayment.html
index ac4d0e6..e3f1073 100644
--- a/sample/source/CreatePayment.html
+++ b/sample/source/CreatePayment.html
@@ -1,7 +1,7 @@
-CreatePayment
This sample code demonstrate how you can process
-a payment with a credit card.
+
CreatePayment
CreatePayment.php
<?php
CreatePaymentSample
//
This sample code demonstrate how you can process
+a direct credit card payment. Please note that direct
+credit card payment and related features using the
+REST API is restricted in some countries.
API used: /v1/payments/payment
require__DIR__.'/../bootstrap.php';usePayPal\Api\Address;usePayPal\Api\Amount;
@@ -9,17 +9,16 @@ API used: /v1/payments/payment
use PayPal\Api\Payer;usePayPal\Api\Payment;usePayPal\Api\FundingInstrument;
-usePayPal\Api\Transaction;
A resource representing a Payer's funding instrument.
-Use a Payer ID (A unique identifier of the payer generated
-and provided by the facilitator. This is required when
-creating or using a tokenized funding instrument)
-and the CreditCardDetails
A transaction defines the contract of a
payment - what is the payment for and who
-is fulfilling it. Transaction is created with
-a Payee and Amount types
$transaction=newTransaction();
+is fulfilling it.
$transaction=newTransaction();$transaction->setAmount($amount)
- ->setDescription("This is the payment description.");
Create a payment by posting to the APIService
using a valid ApiContext (See bootstrap.php for more on ApiContext)
-The return object contains the status;
try{
+The return object contains the state.
try{$payment->create($apiContext);}catch(PayPal\Exception\PPConnectionException$ex){echo"Exception: ".$ex->getMessage().PHP_EOL;
@@ -73,6 +71,9 @@ The return object contains the status;
}
?><html>
+<head>
+ <title>Direct Credit card payments</title>
+</head><body> <div> Created payment:
@@ -81,4 +82,4 @@ The return object contains the status;
\ No newline at end of file
diff --git a/sample/source/CreatePaymentUsingPayPal.html b/sample/source/CreatePaymentUsingPayPal.html
index 4cca2db..d1b0aae 100644
--- a/sample/source/CreatePaymentUsingPayPal.html
+++ b/sample/source/CreatePaymentUsingPayPal.html
@@ -1,50 +1,49 @@
-CreatePaymentUsingPayPal
A transaction defines the contract of a
payment - what is the payment for and who
-is fulfilling it. Transaction is created with
-a Payee and Amount types
$transaction=newTransaction();
+is fulfilling it.
$transaction=newTransaction();$transaction->setAmount($amount)
- ->setDescription("This is the payment description.");
Create a payment by posting to the APIService
-using a valid apiContext.
+
Create a payment by calling the 'create' method
+passing it a valid apiContext.
(See bootstrap.php for more on ApiContext)
-The return object contains the status and the
+The return object contains the state and the
url to which the buyer must be redirected to
for payment approval
try{$payment->create($apiContext);
@@ -52,16 +51,23 @@ for payment approval
\ No newline at end of file
diff --git a/sample/source/CreatePaymentUsingSavedCard.html b/sample/source/CreatePaymentUsingSavedCard.html
index 4b207e1..3788f73 100644
--- a/sample/source/CreatePaymentUsingSavedCard.html
+++ b/sample/source/CreatePaymentUsingSavedCard.html
@@ -1,57 +1,52 @@
-CreatePaymentUsingSavedCard
This sample code demonstrates how you can process a
-Payment using a previously saved credit card.
+Payment using a previously stored credit card token.
API used: /v1/payments/payment
A resource representing a Payer's funding instrument.
-Use a Payer ID (A unique identifier of the payer generated
-and provided by the facilitator. This is required when
-creating or using a tokenized funding instrument)
-and the CreditCardDetails
A transaction defines the contract of a
payment - what is the payment for and who
-is fulfilling it. Transaction is created with
-a Payee and Amount types
$transaction=newTransaction();
+is fulfilling it.
$transaction=newTransaction();$transaction->setAmount($amount)
- ->setDescription("This is the payment description.");
Create a payment by calling the 'create' method
+passing it a valid apiContext.
(See bootstrap.php for more on ApiContext)
-The return object contains the status;
try{
+The return object contains the state.
try{$payment->create($apiContext);}catch(PayPal\Exception\PPConnectionException$ex){echo"Exception: ".$ex->getMessage().PHP_EOL;
@@ -60,6 +55,9 @@ The return object contains the status;
}
?><html>
+<head>
+ <title>Saved Credit card payments</title>
+</head><body> <div> Created payment:
@@ -68,4 +66,4 @@ The return object contains the status;
\ No newline at end of file
diff --git a/sample/source/DeleteCreditCard.html b/sample/source/DeleteCreditCard.html
index a18ab74..c66e287 100644
--- a/sample/source/DeleteCreditCard.html
+++ b/sample/source/DeleteCreditCard.html
@@ -1,10 +1,10 @@
-DeleteCreditCard
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);}catch(PayPal\Exception\PPConnectionException$ex){
@@ -30,20 +29,22 @@ in the future payments.
exit(1);}
-$creditCard=CreditCard::get($card->getId(),$apiContext);
-try{
\ No newline at end of file
diff --git a/sample/source/ExecutePayment.html b/sample/source/ExecutePayment.html
index 8a6a6c0..9812667 100644
--- a/sample/source/ExecutePayment.html
+++ b/sample/source/ExecutePayment.html
@@ -1,4 +1,4 @@
-ExecutePayment
PaymentExecution object includes information necessary
+
PaymentExecution object includes information necessary
to execute a PayPal account payment.
The payer_id is added to the request query parameters
when the user is redirected from paypal back to your site
$execution=newPaymentExecution();$execution->setPayerId($_GET['PayerID']);
- //Execute the payment
$payment->execute($execution,$apiContext);
+ //Execute the payment
(See bootstrap.php for more on ApiContext)
$payment->execute($execution,$apiContext);echo"<html><body><pre>";var_dump($payment->toArray());
@@ -29,4 +29,4 @@ when the user is redirected from paypal back to your site
\ No newline at end of file
diff --git a/sample/source/GetAuthorization.html b/sample/source/GetAuthorization.html
index c9a1d71..0bf6b5b 100644
--- a/sample/source/GetAuthorization.html
+++ b/sample/source/GetAuthorization.html
@@ -1,16 +1,17 @@
-GetAuthorization
You can retrieve info about an Authorization
by invoking the Authorization::get method
with a valid ApiContext (See bootstrap.php for more on ApiContext)
-The return object contains the authorization state.
$authorization=Authorization::get($authId,$apiContext);}catch(PayPal\Exception\PPConnectionException$ex){echo"Exception: ".$ex->getMessage().PHP_EOL;var_dump($ex->getData());
@@ -18,6 +19,9 @@ createAuthorization is defined in common.php
}
?><html>
+<head>
+ <title>Lookup an authorization</title>
+</head><body> <div> Retrieved Authorization:
@@ -26,4 +30,4 @@ createAuthorization is defined in common.php
\ No newline at end of file
diff --git a/sample/source/GetCapture.html b/sample/source/GetCapture.html
index 481e401..521bb68 100644
--- a/sample/source/GetCapture.html
+++ b/sample/source/GetCapture.html
@@ -1,28 +1,33 @@
-GetCapture
You can look up a capture by invoking the Capture::get method
with a valid ApiContext (See bootstrap.php for more on ApiContext)
try{
- $capture=Capture::get($capt->getId(),$apiContext);
+ $capture=Capture::get($capture->getId(),$apiContext);}catch(PayPal\Exception\PPConnectionException$ex){echo"Exception: ".$ex->getMessage().PHP_EOL;var_dump($ex->getData());
@@ -30,6 +35,9 @@ with a valid ApiContext (See bootstrap.php for more on ApiContext)<
}?><html>
+<head>
+ <title>Lookup a capture</title>
+</head><body> <div> Capture Id:
@@ -38,4 +46,4 @@ with a valid ApiContext (See bootstrap.php for more on ApiContext)<
<pre><?phpvar_dump($capture->toArray());?></pre> <a href='../index.html'>Back</a></body>
-</html>
\ No newline at end of file
diff --git a/sample/source/GetCreditCard.html b/sample/source/GetCreditCard.html
index 1455817..8761a9f 100644
--- a/sample/source/GetCreditCard.html
+++ b/sample/source/GetCreditCard.html
@@ -1,15 +1,14 @@
-GetCreditCard
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
\ No newline at end of file
diff --git a/sample/source/GetPayment.html b/sample/source/GetPayment.html
index ddbcd9b..dba7df8 100644
--- a/sample/source/GetPayment.html
+++ b/sample/source/GetPayment.html
@@ -1,4 +1,4 @@
-GetPayment
\ No newline at end of file
diff --git a/sample/source/GetSale.html b/sample/source/GetSale.html
index 5330fac..6aa2ea5 100644
--- a/sample/source/GetSale.html
+++ b/sample/source/GetSale.html
@@ -1,13 +1,14 @@
-GetSale
This sample code demonstrates how you can retrieve
+
Sale transactions are nothing but completed payments.
+This sample code demonstrates how you can retrieve
details of completed Sale Transaction.
API used: /v1/payments/sale/{sale-id}
\ No newline at end of file
diff --git a/sample/source/ListPayments.html b/sample/source/ListPayments.html
index b420ec8..f56e302 100644
--- a/sample/source/ListPayments.html
+++ b/sample/source/ListPayments.html
@@ -1,4 +1,4 @@
-ListPayments
This sample code demonstrate how you can
retrieve a list of all Payment resources
@@ -7,7 +7,7 @@ Note various query parameters that you can
use to filter, and paginate through the
payments list.
API used: GET /v1/payments/payments
Retrieve the PaymentHistory object by calling the
static get method on the Payment class,
@@ -23,9 +23,12 @@ Refer the method doc for valid values for keys
}?><html>
+<head>
+ <title>Lookup payment history</title>
+</head><body> <div>Got <?phpecho$payments->getCount();?> matching payments </div> <pre><?phpvar_dump($payments->toArray());?></pre> <a href='../index.html'>Back</a></body>
-</html>
\ No newline at end of file
diff --git a/sample/source/Reauthorization.html b/sample/source/Reauthorization.html
index a26843b..76c9b24 100644
--- a/sample/source/Reauthorization.html
+++ b/sample/source/Reauthorization.html
@@ -1,19 +1,20 @@
-Reauthorization
\ No newline at end of file
diff --git a/sample/source/RefundCapture.html b/sample/source/RefundCapture.html
index 4969b7f..7d237ad 100644
--- a/sample/source/RefundCapture.html
+++ b/sample/source/RefundCapture.html
@@ -1,37 +1,40 @@
-RefundCapture
\ No newline at end of file
diff --git a/sample/source/RefundSale.html b/sample/source/RefundSale.html
index c7acbd5..0b33301 100644
--- a/sample/source/RefundSale.html
+++ b/sample/source/RefundSale.html
@@ -1,4 +1,4 @@
-RefundSale
This sample code demonstrate how you can
process a refund on a sale transaction created
@@ -6,24 +6,22 @@ using the Payments API.
API used: /v1/payments/sale/{sale-id}/refund
Refund the sale
(See bootstrap.php for more on ApiContext)
$sale->refund($refund,$apiContext);}catch(PayPal\Exception\PPConnectionException$ex){echo"Exception:".$ex->getMessage().PHP_EOL;
@@ -32,9 +30,12 @@ given sale transaction id.
}
?><html>
+<head>
+ <title>Refund a sale</title>
+</head><body> <div>Refunding sale id: <?phpecho$saleId;?></div> <pre><?phpvar_dump($sale);?></pre> <a href='../index.html'>Back</a></body>
-</html>
\ No newline at end of file
diff --git a/sample/source/VoidAuthorization.html b/sample/source/VoidAuthorization.html
index 2c58302..3aea3e0 100644
--- a/sample/source/VoidAuthorization.html
+++ b/sample/source/VoidAuthorization.html
@@ -1,17 +1,15 @@
-VoidAuthorization
You can void a previously authorized payment
by invoking the $authorization->void method
-with a valid ApiContext (See bootstrap.php for more on ApiContext)
create payment to get authorization Id
-createAuthorization is defined in common.php
$authId=createAuthorization($apiContext);
-
- $authorization=Authorization::get($authId,$apiContext);
- $voidedAuth=$authorization->void($apiContext);
+with a valid ApiContext (See bootstrap.php for more on ApiContext)
try{
create an authorization to get authorization Id
+createAuthorization is defined in common.php
$voidedAuth=$authorization->void($apiContext);}catch(PayPal\Exception\PPConnectionException$ex){echo"Exception: ".$ex->getMessage().PHP_EOL;var_dump($ex->getData());
@@ -19,6 +17,9 @@ createAuthorization is defined in common.php
}
?><html>
+<head>
+ <title>Void an authorization</title>
+</head><body> <div> Voided authorization
@@ -26,4 +27,4 @@ createAuthorization is defined in common.php
AuthorizationCapture
+AuthorizationCapture
-This sample code demonstrate how you can capture the authorized payment +
This sample code demonstrates how you can capture +a previously authorized payment. API used: /v1/payments/payment
Capture Payment
+use PayPal\Api\Authorization;Capture Payment
You can capture and process a previously created authorization by invoking the $authorization->capture method -with a valid ApiContext (See bootstrap.php for more on
ApiContext)create payment to get authorization Id +with a valid ApiContext (See bootstrap.php for more on
ApiContext)Create a new authorization to get authorization Id createAuthorization defined in common.php
Get the authorization
Lookup the authorization.
Perform a capture