diff --git a/sample/doc/assets/behavior.js b/sample/doc/assets/behavior.js index b7f845b..44f4ed2 100644 --- a/sample/doc/assets/behavior.js +++ b/sample/doc/assets/behavior.js @@ -346,7 +346,29 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "pageTitle": "invoice/GetInvoice", "title": "GetInvoice" }, - "depth": 2 + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Get Invoice Sample", + "slug": "get-invoice-sample" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Retrieve Invoice", + "slug": "retrieve-invoice" + }, + "depth": 3 + } + ] + } + ] }, { "type": "file", "data": { @@ -554,7 +576,18 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "pageTitle": "lipp/ObtainUserConsent", "title": "ObtainUserConsent" }, - "depth": 2 + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Get User Consent URL", + "slug": "get-user-consent-url" + }, + "depth": 3 + } + ] }, { "type": "file", "data": { @@ -572,7 +605,18 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "pageTitle": "lipp/UserConsentRedirect", "title": "UserConsentRedirect" }, - "depth": 2 + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "User Consent Response", + "slug": "user-consent-response" + }, + "depth": 3 + } + ] } ] }, { @@ -727,6 +771,57 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "title": "UpdateWebhook" }, "depth": 2 + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [{}, ".fbp"], + "pygmentsLexer": "php", + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "PHP" + }, + "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/notifications/ValidateWebhookEvent.php", + "projectPath": "notifications/ValidateWebhookEvent.php", + "targetPath": "notifications/ValidateWebhookEvent", + "pageTitle": "notifications/ValidateWebhookEvent", + "title": "ValidateWebhookEvent" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Validate Webhook", + "slug": "validate-webhook" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 2, + "title": "Received Body from Webhook", + "slug": "received-body-from-webhook" + }, + "depth": 2, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Validate Received Event Method", + "slug": "validate-received-event-method" + }, + "depth": 3 + } + ] + } + ] + } + ] }, { "type": "file", "data": { @@ -962,93 +1057,7 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "pageTitle": "payments/CreatePayment", "title": "CreatePayment" }, - "depth": 2, - "outline": [ - { - "type": "heading", - "data": { - "level": 1, - "title": "CreatePaymentSample", - "slug": "createpaymentsample" - }, - "depth": 1, - "children": [ - { - "type": "heading", - "data": { - "level": 3, - "title": "CreditCard", - "slug": "creditcard" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "FundingInstrument", - "slug": "fundinginstrument" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Payer", - "slug": "payer" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Itemized information", - "slug": "itemized-information" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Additional payment details", - "slug": "additional-payment-details" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Amount", - "slug": "amount" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Transaction", - "slug": "transaction" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Payment", - "slug": "payment" - }, - "depth": 3 - }, { - "type": "heading", - "data": { - "level": 3, - "title": "Create Payment", - "slug": "create-payment" - }, - "depth": 3 - } - ] - } - ] + "depth": 2 }, { "type": "file", "data": { @@ -1170,7 +1179,93 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "pageTitle": "payments/CreatePaymentUsingSavedCard", "title": "CreatePaymentUsingSavedCard" }, - "depth": 2 + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Create payment using a saved credit card", + "slug": "create-payment-using-a-saved-credit-card" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Credit card token", + "slug": "credit-card-token" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "FundingInstrument", + "slug": "fundinginstrument" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Payer", + "slug": "payer" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Itemized information", + "slug": "itemized-information" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Additional payment details", + "slug": "additional-payment-details" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Amount", + "slug": "amount" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Transaction", + "slug": "transaction" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Payment", + "slug": "payment" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Create Payment", + "slug": "create-payment" + }, + "depth": 3 + } + ] + } + ] }, { "type": "file", "data": { @@ -1404,7 +1499,29 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "pageTitle": "payments/OrderGet", "title": "OrderGet" }, - "depth": 2 + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Get Order Sample", + "slug": "get-order-sample" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Approval Status", + "slug": "approval-status" + }, + "depth": 3 + } + ] + } + ] }, { "type": "file", "data": { @@ -1440,7 +1557,29 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "pageTitle": "payments/RefundCapture", "title": "RefundCapture" }, - "depth": 2 + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Refund Capture Sample", + "slug": "refund-capture-sample" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Refund", + "slug": "refund" + }, + "depth": 3 + } + ] + } + ] }, { "type": "file", "data": { @@ -1604,7 +1743,37 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "pageTitle": "sale/GetSale", "title": "GetSale" }, - "depth": 2 + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Get Sale sample", + "slug": "get-sale-sample" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Get Sale From Created Payment", + "slug": "get-sale-from-created-payment" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Retrieve the sale object", + "slug": "retrieve-the-sale-object" + }, + "depth": 3 + } + ] + } + ] }, { "type": "file", "data": { diff --git a/sample/doc/lipp/ObtainUserConsent.html b/sample/doc/lipp/ObtainUserConsent.html index 3542e51..96631fa 100644 --- a/sample/doc/lipp/ObtainUserConsent.html +++ b/sample/doc/lipp/ObtainUserConsent.html @@ -14,7 +14,4 @@ null, null, $apiContext -); - -// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printResult("Generated the User Consent URL", "URL", '<a href="'. $redirectUrl . '" >Click Here to Obtain User Consent</a>', $baseUrl, $redirectUrl); +);

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Generated the User Consent URL", "URL", '<a href="'. $redirectUrl . '" >Click Here to Obtain User Consent</a>', $baseUrl, $redirectUrl);
\ No newline at end of file diff --git a/sample/doc/notifications/ValidateWebhookEvent.html b/sample/doc/notifications/ValidateWebhookEvent.html new file mode 100644 index 0000000..cae295b --- /dev/null +++ b/sample/doc/notifications/ValidateWebhookEvent.html @@ -0,0 +1,19 @@ +notifications/ValidateWebhookEvent
notifications/ValidateWebhookEvent.php
<?php + +$apiContext = require __DIR__ . '/../bootstrap.php';

Validate Webhook

+

PHP Currently does not support certificate chain validation, that is necessary to validate webhook directly, from received data +To resolve that, we need to use alternative, which includes making a GET call to obtain the data directly from PayPal.

Received Body from Webhook

+

Body received from webhook. This would be the data that you receive in the post request that comes from PayPal, to your webhook set URL. +This is a sample data, that represents the webhook event data.

$bodyReceived = '{"id":"WH-36G56432PK518391U-9HW18392D95289106","create_time":"2015-06-01T20:21:13Z","resource_type":"sale","event_type":"PAYMENT.SALE.COMPLETED","summary":"Payment completed for $ 20.0 USD","resource":{"id":"2FY57107YS3937627","create_time":"2015-06-01T20:20:28Z","update_time":"2015-06-01T20:20:46Z","amount":{"total":"20.00","currency":"USD"},"payment_mode":"INSTANT_TRANSFER","state":"completed","protection_eligibility":"ELIGIBLE","protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE","parent_payment":"PAY-2SV945219E505370PKVWL5DA","transaction_fee":{"value":"0.88","currency":"USD"},"links":[{"href":"https://api.sandbox.paypal.com/v1/payments/sale/2FY57107YS3937627","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/sale/2FY57107YS3937627/refund","rel":"refund","method":"POST"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-2SV945219E505370PKVWL5DA","rel":"parent_payment","method":"GET"}]},"links":[{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-36G56432PK518391U-9HW18392D95289106","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-36G56432PK518391U-9HW18392D95289106/resend","rel":"resend","method":"POST"}]}'; + +/** + * This is one way to receive the entire body that you received from PayPal webhook. This is one of the way to retrieve that information. + * Just uncomment the below line to read the data from actual request. + */ +/** @var String $bodyReceived */

$bodyReceived = file_get_contents('php://input');

Validate Received Event Method

+

Call the validateReceivedEvent() method with provided body, and apiContext object to validate

try { + /** @var \PayPal\Api\WebhookEvent $output */ + $output = \PayPal\Api\WebhookEvent::validateAndGetReceivedEvent($bodyReceived, $apiContext); +} catch (Exception $ex) {

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printError("Validate Received Webhook Event", "WebhookEvent", null, $bodyReceived, $ex); + exit(1); +}

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Validate Received Webhook Event", "WebhookEvent", $output->getId(), $bodyReceived, $output);
\ No newline at end of file diff --git a/sample/doc/payments/CreatePaymentUsingSavedCard.html b/sample/doc/payments/CreatePaymentUsingSavedCard.html index aa54775..d04a7f3 100644 --- a/sample/doc/payments/CreatePaymentUsingSavedCard.html +++ b/sample/doc/payments/CreatePaymentUsingSavedCard.html @@ -68,13 +68,8 @@ passing it a valid apiContext. (See bootstrap.php for more on ApiContext) The return object contains the state.

try { $payment->create($apiContext); -} catch (Exception $ex) { - // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printError("Create Payment using Saved Card", "Payment", null, $request, $ex); +} catch (Exception $ex) {

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printError("Create Payment using Saved Card", "Payment", null, $request, $ex); exit(1); -} +}

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Create Payment using Saved Card", "Payment", $payment->getId(), $request, $payment); -// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printResult("Create Payment using Saved Card", "Payment", $payment->getId(), $request, $payment); - -return $card;
+return $card; \ No newline at end of file diff --git a/sample/doc/sale/GetSale.html b/sample/doc/sale/GetSale.html index c2c694e..4b4616a 100644 --- a/sample/doc/sale/GetSale.html +++ b/sample/doc/sale/GetSale.html @@ -14,13 +14,8 @@ API used: /v1/payments/sale/{sale-id}

try {

Retrieve the sale object

Pass the ID of the sale transaction from your payment resource.

$sale = Sale::get($saleId, $apiContext); -} catch (Exception $ex) { - // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printError("Look Up A Sale", "Sale", $sale->getId(), null, $ex); +} catch (Exception $ex) {

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printError("Look Up A Sale", "Sale", $sale->getId(), null, $ex); exit(1); -} +}

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Look Up A Sale", "Sale", $sale->getId(), null, $sale); -// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printResult("Look Up A Sale", "Sale", $sale->getId(), null, $sale); - -return $sale;
+return $sale; \ No newline at end of file