From 9498a2efce9e4f7b8cef01b4cdf8d0d0cddc8f94 Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Thu, 30 May 2013 16:26:31 +0530 Subject: [PATCH] updating code docs --- sample/source/AuthorizationCapture.html | 6 +++--- sample/source/CreatePayment.html | 4 ++-- sample/source/CreatePaymentUsingPayPal.html | 4 ++-- .../source/CreatePaymentUsingSavedCard.html | 4 ++-- sample/source/DeleteCreditCard.html | 3 --- sample/source/ExecutePayment.html | 4 ++-- sample/source/GetAuthorization.html | 6 +++--- sample/source/GetCapture.html | 7 ++++--- sample/source/GetPayment.html | 4 ++-- sample/source/ListPayments.html | 4 ++-- sample/source/RefundCapture.html | 20 ++++++++++--------- sample/source/VoidAuthorization.html | 6 +++--- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sample/source/AuthorizationCapture.html b/sample/source/AuthorizationCapture.html index 6f964db..2bcf992 100644 --- a/sample/source/AuthorizationCapture.html +++ b/sample/source/AuthorizationCapture.html @@ -10,7 +10,7 @@ API used: /v1/payments/payment

use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); +use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); @@ -44,7 +44,7 @@ The return object contains the status;

</body> </html> <?php -function createAuthorization() +function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); @@ -85,7 +85,7 @@ The return object contains the status;

$payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/source/CreatePayment.html b/sample/source/CreatePayment.html index 11c231e..bd7e65c 100644 --- a/sample/source/CreatePayment.html +++ b/sample/source/CreatePayment.html @@ -1,4 +1,4 @@ -CreatePayment
<?php

CreatePaymentSample

+CreatePaymentBack
<?php

CreatePaymentSample

This sample code demonstrate how you can process a payment with a credit card. @@ -81,4 +81,4 @@ The return object contains the status;

<pre><?php var_dump($payment->toArray());?></pre> <a href='../index.html'>Back</a> </body> -</html>
\ No newline at end of file +</html>
\ No newline at end of file diff --git a/sample/source/CreatePaymentUsingPayPal.html b/sample/source/CreatePaymentUsingPayPal.html index 3282114..1cf0ed2 100644 --- a/sample/source/CreatePaymentUsingPayPal.html +++ b/sample/source/CreatePaymentUsingPayPal.html @@ -1,4 +1,4 @@ -CreatePaymentUsingPayPal
<?php

Create Payment using PayPal as payment method

+CreatePaymentUsingPayPalBack
<?php

Create Payment using PayPal as payment method

This sample code demonstrates how you can process a PayPal Account based Payment. @@ -64,4 +64,4 @@ payment id in a database.

if(isset($redirectUrl)) { header("Location: $redirectUrl"); exit; -}
\ No newline at end of file +}
\ No newline at end of file diff --git a/sample/source/CreatePaymentUsingSavedCard.html b/sample/source/CreatePaymentUsingSavedCard.html index 9e070fa..e729795 100644 --- a/sample/source/CreatePaymentUsingSavedCard.html +++ b/sample/source/CreatePaymentUsingSavedCard.html @@ -1,4 +1,4 @@ -CreatePaymentUsingSavedCard
<?php

Create payment using a saved credit card

+CreatePaymentUsingSavedCardBack
<?php

Create payment using a saved credit card

This sample code demonstrates how you can process a Payment using a previously saved credit card. @@ -68,4 +68,4 @@ The return object contains the status;

<pre><?php var_dump($payment->toArray());?></pre> <a href='../index.html'>Back</a> </body> -</html>
\ No newline at end of file +</html>
\ No newline at end of file diff --git a/sample/source/DeleteCreditCard.html b/sample/source/DeleteCreditCard.html index b690aae..6dfd07a 100644 --- a/sample/source/DeleteCreditCard.html +++ b/sample/source/DeleteCreditCard.html @@ -4,7 +4,6 @@ API used: /v1/vault/credit-card/{} NOTE: HTTP method used here is DELETE

require __DIR__ . '/../bootstrap.php'; use PayPal\Api\CreditCard; -use PayPal\Api\CreditCard; use PayPal\Api\Address;

save card for demo

CreditCard

@@ -31,9 +30,7 @@ in the future payments. exit(1); } - $creditCard = CreditCard::get($res->getId(), $apiContext); - try {

Delete Card

deletes saved credit card diff --git a/sample/source/ExecutePayment.html b/sample/source/ExecutePayment.html index ab77e3d..2bc88b6 100644 --- a/sample/source/ExecutePayment.html +++ b/sample/source/ExecutePayment.html @@ -1,4 +1,4 @@ -ExecutePayment

<?php

Execute Payment Sample

+ExecutePaymentBack
<?php

Execute Payment Sample

This sample shows how you can complete a payment that has been approved by @@ -29,4 +29,4 @@ when the user is redirected from paypal back to your site

} else { echo "User cancelled payment."; -}
\ No newline at end of file +}
\ No newline at end of file diff --git a/sample/source/GetAuthorization.html b/sample/source/GetAuthorization.html index 513f5f6..fa7afcb 100644 --- a/sample/source/GetAuthorization.html +++ b/sample/source/GetAuthorization.html @@ -10,7 +10,7 @@ API used: /v1/payments/authorization/<$authorizationId>

use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization();

GetAuthorization

+use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization($apiContext);

GetAuthorization

GetAuthorization by posting to the APIService using a valid ApiContext (See bootstrap.php for more on ApiContext) @@ -33,7 +33,7 @@ The return object contains the status;

</body> </html> <?php -function createAuthorization() +function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); @@ -74,7 +74,7 @@ The return object contains the status;

$payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/source/GetCapture.html b/sample/source/GetCapture.html index bcd6310..4b647a8 100644 --- a/sample/source/GetCapture.html +++ b/sample/source/GetCapture.html @@ -9,7 +9,8 @@ API used: /v1/payments/capture/<$captureId>

use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); +use PayPal\Api\Transaction; +use PayPal\Api\Authorization;

create payment to get authorization Id

$authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); $amt->setTotal("1.00"); @@ -50,7 +51,7 @@ The return object contains the status;

</body> </html> <?php -function createAuthorization() +function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); @@ -91,7 +92,7 @@ The return object contains the status;

$payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/source/GetPayment.html b/sample/source/GetPayment.html index 0f451bf..c59c1c8 100644 --- a/sample/source/GetPayment.html +++ b/sample/source/GetPayment.html @@ -1,4 +1,4 @@ -GetPayment
<?php

GetPaymentSample

+GetPaymentBack
<?php

GetPaymentSample

This sample code demonstrate how you can retrieve a list of all Payment resources @@ -29,4 +29,4 @@ Payment ID <pre><?php var_dump($payment->toArray());?></pre> <a href='../index.html'>Back</a> </body> -</html>

\ No newline at end of file +</html>
\ No newline at end of file diff --git a/sample/source/ListPayments.html b/sample/source/ListPayments.html index c86444d..b4050b3 100644 --- a/sample/source/ListPayments.html +++ b/sample/source/ListPayments.html @@ -1,4 +1,4 @@ -ListPayments
<?php

GetPaymentList

+ListPaymentsBack
<?php

GetPaymentList

This sample code demonstrate how you can retrieve a list of all Payment resources @@ -28,4 +28,4 @@ Refer the method doc for valid values for keys <pre><?php var_dump($payments->toArray());?></pre> <a href='../index.html'>Back</a> </body> -</html>

\ No newline at end of file +</html>
\ No newline at end of file diff --git a/sample/source/RefundCapture.html b/sample/source/RefundCapture.html index 7d0a43f..2b48d65 100644 --- a/sample/source/RefundCapture.html +++ b/sample/source/RefundCapture.html @@ -4,6 +4,7 @@ process a refund on a Captured transaction created using the Capture API. API used: /v1/payments/capture/{}/refund

require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Authorization; use PayPal\Api\Capture; use PayPal\Api\Refund; use PayPal\Api\Address; @@ -12,7 +13,9 @@ API used: /v1/payments/capture/{}/refund

use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); +use PayPal\Api\Transaction; +use PayPal\Rest\ApiContext; +use PayPal\Auth\OAuthTokenCredential;

create payment to get authorization Id

$authId = createAuthorization($apiContext); $amt = new Amount(); $amt->setCurrency("USD"); @@ -20,7 +23,6 @@ API used: /v1/payments/capture/{}/refund

### Capture $captur = new Capture(); -$captur->setId($authId); $captur->setAmount($amt);

get the authorization

$authorization = Authorization::get($authId, $apiContext);

Capture Payment

Capture Payment by posting to the APIService @@ -35,12 +37,12 @@ The return object contains the status;

Create a refund object indicating refund amount

$refund = new Refund(); -$refund->setId($capt->getId()); $refund->setAmount($amt); - -$capture = Capture::get($capt->getId(), $apiContext); -try {

(See bootstrap.php for more on ApiContext)

$captureRefund = $capture->refund($refund, $apiContext); +$capture = Capture::get($capt->getId(), $apiContext);

create new API context

$context = new ApiContext(new OAuthTokenCredential( + 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM', + 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM')); +try {

(See bootstrap.php for more on ApiContext)

$captureRefund = $capture->refund($refund, $context); } catch (\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); @@ -56,7 +58,7 @@ refund amount

</body> </html> <?php -function createAuthorization() +function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); @@ -86,7 +88,7 @@ refund amount

$amount = new Amount(); $amount->setCurrency("USD"); - $amount->setTotal("1.00"); + $amount->setTotal("10.00"); $transaction = new Transaction(); $transaction->setAmount($amount); @@ -97,7 +99,7 @@ refund amount

$payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; diff --git a/sample/source/VoidAuthorization.html b/sample/source/VoidAuthorization.html index b091c04..f3de626 100644 --- a/sample/source/VoidAuthorization.html +++ b/sample/source/VoidAuthorization.html @@ -10,7 +10,7 @@ API used: /v1/payments/authorization/<{authorizationid}>/void"

use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization(); +use PayPal\Api\Transaction;

create payment to get authorization Id

$authId = createAuthorization($apiContext); $authorization = Authorization::get($authId, $apiContext);

VoidAuthorization

@@ -34,7 +34,7 @@ The return object contains the status;

</body> </html> <?php -function createAuthorization() +function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); @@ -75,7 +75,7 @@ The return object contains the status;

$payment->setPayer($payer); $payment->setTransactions(array($transaction)); - $paymnt = $payment->create(); + $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id'];