From 268b39b374f8349a8ade38ce94ffcf00c93fcae2 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Tue, 28 May 2013 09:57:10 +0530 Subject: [PATCH] adding auth capture samples --- sample/payments/AuthorizationCapture.php | 48 ++++++++++++++++++++++++ sample/payments/GetAuthorization.php | 31 +++++++++++++++ sample/payments/GetCapture.php | 30 +++++++++++++++ sample/payments/RefundCapture.php | 45 ++++++++++++++++++++++ sample/payments/VoidAuthorization.php | 33 ++++++++++++++++ 5 files changed, 187 insertions(+) create mode 100644 sample/payments/AuthorizationCapture.php create mode 100644 sample/payments/GetAuthorization.php create mode 100644 sample/payments/GetCapture.php create mode 100644 sample/payments/RefundCapture.php create mode 100644 sample/payments/VoidAuthorization.php diff --git a/sample/payments/AuthorizationCapture.php b/sample/payments/AuthorizationCapture.php new file mode 100644 index 0000000..328b518 --- /dev/null +++ b/sample/payments/AuthorizationCapture.php @@ -0,0 +1,48 @@ +setCurrency("USD"); + $amount->setTotal("1.00"); + + +### Capture + +$captur = new Capture(); +$captur->setId('5RA45624N3531924N'); +$captur->setAmount($amount); + +// get the authorization +$authorization = Authorization::get('8UA90289RG279654G', $apiContext); + +// ### Capture Payment +// Capture Payment by posting to the APIService +// using a valid ApiContext (See bootstrap.php for more on `ApiContext`) +// The return object contains the status; +try { + $capt = $authorization->capture($captur, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + +
+ Capture payment: + getId();?> +
+
toArray());?>
+ Back + + diff --git a/sample/payments/GetAuthorization.php b/sample/payments/GetAuthorization.php new file mode 100644 index 0000000..1bf13a0 --- /dev/null +++ b/sample/payments/GetAuthorization.php @@ -0,0 +1,31 @@ + + +require __DIR__ . '/../bootstrap.php'; + +use PayPal\Api\Authorization; + +// ### GetAuthorization +// GetAuthorization by posting to the APIService +// using a valid ApiContext (See bootstrap.php for more on `ApiContext`) +// The return object contains the status; +try { + $authorization = Authorization::get('1FR49283DF589111P', $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + +
+ Get Authorization: + getId();?> +
+
toArray());?>
+ Back + + diff --git a/sample/payments/GetCapture.php b/sample/payments/GetCapture.php new file mode 100644 index 0000000..73a7062 --- /dev/null +++ b/sample/payments/GetCapture.php @@ -0,0 +1,30 @@ + + +require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Capture; + +// ### Get Capture +// Get Capture by posting to the APIService +// using a valid ApiContext (See bootstrap.php for more on `ApiContext`) +// The return object contains the status; +try { + $capture = Capture::get('7BA08426L46375838', $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + +
+ Get Capture : + getId();?> +
+
toArray());?>
+ Back + + diff --git a/sample/payments/RefundCapture.php b/sample/payments/RefundCapture.php new file mode 100644 index 0000000..447cd4c --- /dev/null +++ b/sample/payments/RefundCapture.php @@ -0,0 +1,45 @@ +}/refund + + +// ### Refund +// Create a refund object indicating +// refund amount + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + +$refund = new Refund(); +$refund->setId('7BA08426L46375838'); +$refund->setAmount($amount); + + +$capture = Capture::get('7BA08426L46375838', $apiContext); +try { + // (See bootstrap.php for more on `ApiContext`) + $captureRefund = $capture->refund($refund, $apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + + +
Refund Capture:
+
+ Back + + + diff --git a/sample/payments/VoidAuthorization.php b/sample/payments/VoidAuthorization.php new file mode 100644 index 0000000..dfeb051 --- /dev/null +++ b/sample/payments/VoidAuthorization.php @@ -0,0 +1,33 @@ +/void" + +require __DIR__ . '/../bootstrap.php'; + +use PayPal\Api\Authorization; + +$authorization = Authorization::get('87U86133WD4359724', $apiContext); + + +// ### VoidAuthorization +// VoidAuthorization by posting to the APIService +// using a valid ApiContext (See bootstrap.php for more on `ApiContext`) +// The return object contains the status; +try { + $void = $authorization->void($apiContext); +} catch (\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + +
+ Void Authorization: +
+
toArray());?>
+ Back + +