More Webhook API Changes

- Updated API Models with Fixes
- Updated Samples
- Additional Functional Tests
This commit is contained in:
japatel
2014-12-12 17:00:33 -06:00
parent d6575b49ae
commit fb9584ba66
30 changed files with 1454 additions and 73 deletions

View File

@@ -2,6 +2,7 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Common\ResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\WebhookEventList;
@@ -218,7 +219,7 @@ class WebhookEvent extends ResourceModel
/**
* This contains the resource that is identified by resource_type element.
*
* @param mixed $resource
* @param \PayPal\Common\PPModel $resource
*
* @return $this
*/
@@ -231,7 +232,7 @@ class WebhookEvent extends ResourceModel
/**
* This contains the resource that is identified by resource_type element.
*
* @return mixed
* @return \PayPal\Common\PPModel
*/
public function getResource()
{

View File

@@ -72,7 +72,7 @@ class WebhookEventType extends ResourceModel
* @param string $webhookId
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return WebhookEventList
* @return WebhookEventTypeList
*/
public static function subscribedEventTypes($webhookId, $apiContext = null, $restCall = null)
{
@@ -86,7 +86,7 @@ class WebhookEventType extends ResourceModel
$apiContext,
$restCall
);
$ret = new WebhookEventList();
$ret = new WebhookEventTypeList();
$ret->fromJson($json);
return $ret;
}
@@ -96,7 +96,7 @@ class WebhookEventType extends ResourceModel
*
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return WebhookEventList
* @return WebhookEventTypeList
*/
public static function availableEventTypes($apiContext = null, $restCall = null)
{
@@ -109,7 +109,7 @@ class WebhookEventType extends ResourceModel
$apiContext,
$restCall
);
$ret = new WebhookEventList();
$ret = new WebhookEventTypeList();
$ret->fromJson($json);
return $ret;
}

View File

@@ -34,6 +34,10 @@ class PPReflectionUtil
*/
public static function getPropertyClass($class, $propertyName)
{
if ($class == get_class(new PPModel())) {
// Make it generic if PPModel is used for generating this
return get_class(new PPModel());
}
if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) {
$param = $annotations['return'];

View File

@@ -1235,6 +1235,62 @@ 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
"depth": 1,
"children": [
{
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/notifications/CreateWebhook.php",
"projectPath": "notifications/CreateWebhook.php",
"targetPath": "notifications/CreateWebhook",
"pageTitle": "notifications/CreateWebhook",
"title": "CreateWebhook"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Webhook Sample",
"slug": "create-webhook-sample"
},
"depth": 1
}, {
"type": "heading",
"data": {
"level": 1,
"title": "Basic Information",
"slug": "basic-information"
},
"depth": 1
}, {
"type": "heading",
"data": {
"level": 1,
"title": "Event Types",
"slug": "event-types"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Create Webhook",
"slug": "create-webhook"
},
"depth": 3
}
]
}
]
}, {
"type": "file",
"data": {
"language": {
@@ -1639,62 +1695,6 @@ 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
]
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/notifications/createWebhook.php",
"projectPath": "notifications/createWebhook.php",
"targetPath": "notifications/createWebhook",
"pageTitle": "notifications/createWebhook",
"title": "createWebhook"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Webhook Sample",
"slug": "create-webhook-sample"
},
"depth": 1
}, {
"type": "heading",
"data": {
"level": 1,
"title": "Basic Information",
"slug": "basic-information"
},
"depth": 1
}, {
"type": "heading",
"data": {
"level": 1,
"title": "Event Types",
"slug": "event-types"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Create Webhook",
"slug": "create-webhook"
},
"depth": 3
}
]
}
]
}
]
}, {

View File

@@ -5,15 +5,16 @@ API used: GET /v1/notifications/webhooks-events</p></div></div></div><div class=
<h2 id="please-note">PLEASE NOTE:</h2>
<p>Creating webhook is sample purposes only. In real scenario, you dont need to create a new webhook everytime you want to search
for a webhook events. This is made in a sample just to make sure there is minimum of one webhook to listen to.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\Webhook $webhook */</span>
<span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateWebhook.php'</span>;
<span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
<span class="hljs-variable">$params</span> = <span class="hljs-keyword">array</span>();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="search-webhook-events">Search Webhook events</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$params</span> = <span class="hljs-keyword">array</span>(</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>&#39;start_time&#39;=&gt;&#39;2014-12-06T11:00:00Z&#39;,
&#39;end_time&#39;=&gt;&#39;2014-12-12T11:00:00Z&#39;</p></div></div><div class="code"><div class="wrapper">);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="search-webhook-events">Search Webhook events</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$output</span> = \PayPal\Api\WebhookEvent::all(<span class="hljs-variable">$params</span>, <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
ResultPrinter::printError(<span class="hljs-string">"Search Webhook events"</span>, <span class="hljs-string">"WebhookEventList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$ex</span>);
ResultPrinter::printError(<span class="hljs-string">"Search Webhook events"</span>, <span class="hljs-string">"WebhookEventList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Search Webhook events"</span>, <span class="hljs-string">"WebhookEventList"</span>, <span class="hljs-variable">$webhook</span>-&gt;getId(), <span class="hljs-variable">$params</span>, <span class="hljs-variable">$output</span>);
ResultPrinter::printResult(<span class="hljs-string">"Search Webhook events"</span>, <span class="hljs-string">"WebhookEventList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$output</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><title>notifications/createWebhook</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="notifications/createWebhook"><meta name="groc-project-path" content="notifications/createWebhook.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">notifications/createWebhook.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-webhook-sample">Create Webhook Sample</h1>
<!DOCTYPE html><html lang="en"><head><title>notifications/CreateWebhook</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="notifications/CreateWebhook"><meta name="groc-project-path" content="notifications/CreateWebhook.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">notifications/CreateWebhook.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-webhook-sample">Create Webhook Sample</h1>
<p>This sample code demonstrate how you can create a webhook, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#create-a-webhook">https://developer.paypal.com/webapps/developer/docs/api/#create-a-webhook</a>
API used: POST /v1/notifications/webhooks</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new instance of Webhook object</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Webhook();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="basic-information">Basic Information</h1>

View File

@@ -54,7 +54,7 @@ payment approval/ cancellation.</p></div></div><div class="code"><div class="wra
-&gt;setCancelUrl(<span class="hljs-string">"$baseUrl/ExecutePayment.php?success=false"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payment">Payment</h3>
<p>A Payment Resource; create one using
the above types and intent set to &#39;sale&#39;</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payment</span> = <span class="hljs-keyword">new</span> Payment();
<span class="hljs-variable">$payment</span>-&gt;setIntent(<span class="hljs-string">"sale"</span>)
<span class="hljs-variable">$payment</span>-&gt;setIntent(<span class="hljs-string">"authorize"</span>)
-&gt;setPayer(<span class="hljs-variable">$payer</span>)
-&gt;setRedirectUrls(<span class="hljs-variable">$redirectUrls</span>)
-&gt;setTransactions(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$transaction</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$payment</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-payment">Create Payment</h3>

View File

@@ -137,7 +137,7 @@ if (PHP_SAPI == 'cli') {
<![endif]-->
</head>
<body data-spy="scroll" data-target="#leftNavigation" data-offset="0" class="scrollspy-example">
<body data-spy="scroll" data-target="#leftNavigation" data-offset="10" class="scrollspy-example">
<!-- Main component for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container-fluid">
@@ -188,6 +188,7 @@ if (PHP_SAPI == 'cli') {
<li><a href="#billing">Billing Plan & Agreements</a></li>
<li><a href="#vault">Vault</a></li>
<li><a href="#experience">Payment Experience</a></li>
<li><a href="#notifications">Notifications</a></li>
<li><a href="#invoice">Invoice</a></li>
<li><a href="#identity">Identity (LIPP)</a></li>
</ul>
@@ -249,7 +250,7 @@ if (PHP_SAPI == 'cli') {
<a href="payments/CreatePaymentUsingSavedCard.php"
class="btn btn-primary pull-left execute">
Try It <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/CreatePayment.html" class="btn btn-default pull-right">Source <i
<a href="doc/payments/CreatePaymentUsingSavedCard.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
@@ -275,7 +276,7 @@ if (PHP_SAPI == 'cli') {
<div class="col-md-4">
<a href="payments/GetPayment.php" class="btn btn-primary pull-left execute"> Try It <i
class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/CreatePayment.html" class="btn btn-default pull-right">Source <i
<a href="doc/payments/GetPayment.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
@@ -286,7 +287,7 @@ if (PHP_SAPI == 'cli') {
<div class="col-md-4">
<a href="payments/ListPayments.php" class="btn btn-primary pull-left execute"> Try It <i
class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/CreatePayment.html" class="btn btn-default pull-right">Source <i
<a href="doc/payments/ListPayments.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
@@ -754,6 +755,111 @@ if (PHP_SAPI == 'cli') {
</ul>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 id="notifications" class="panel-title"><a
href="https://developer.paypal.com/webapps/developer/docs/api/#notifications"
target="_blank">Notifications</a></h3>
</div>
<!-- List group -->
<ul class="list-group">
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>Get a reference list of webhook event types</h5></div>
<div class="col-md-4">
<a href="notifications/WebhookEventTypesList.php" class="btn btn-primary pull-left execute"> Try It
<i
class="fa fa-play-circle-o"></i></a>
<a href="doc/notifications/WebhookEventTypesList.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>Create a webhook</h5></div>
<div class="col-md-4">
<a href="notifications/CreateWebhook.php" class="btn btn-primary pull-left execute"> Try It
<i
class="fa fa-play-circle-o"></i></a>
<a href="doc/notifications/CreateWebhook.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>Get a webhook</h5></div>
<div class="col-md-4">
<a href="notifications/GetWebhook.php" class="btn btn-primary pull-left execute"> Try It
<i
class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/GetAuthorization.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>List subscribed webhook event types</h5></div>
<div class="col-md-4">
<a href="notifications/ListSubscribedWebhookEventTypes.php" class="btn btn-primary pull-left execute"> Try It <i
class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/GetCapture.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>List all webhooks</h5></div>
<div class="col-md-4">
<a href="notifications/ListWebhooks.php" class="btn btn-primary pull-left execute">
Try It <i
class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/AuthorizationCapture.html" class="btn btn-default pull-right">Source
<i
class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>Update a webhook</h5></div>
<div class="col-md-4">
<a href="notifications/UpdateWebhook.php" class="btn btn-primary pull-left execute"> Try It
<i
class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/VoidAuthorization.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>Delete a webhook</h5></div>
<div class="col-md-4">
<a href="notifications/DeleteWebhook.php" class="btn btn-primary pull-left execute"> Try It <i
class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/Reauthorization.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>Search webhook events</h5></div>
<div class="col-md-4">
<a href="notifications/SearchWebhookEvents.php" class="btn btn-primary pull-left execute"> Try It <i
class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/RefundCapture.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
</ul>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 id="invoice" class="panel-title"><a

View File

@@ -0,0 +1,24 @@
<?php
// # Delete All Webhook Sample
// This is a sample helper method, to delete all existing webhooks, because of limited number of webhooks that are allowed per app.
// To properly use the sample, change the clientId and Secret from bootstrap.php file with your own app ClientId and Secret.
// ## Get Webhook Instance
/** @var \PayPal\Api\WebhookList $webhookList */
$webhookList = require 'ListWebhooks.php';
// ### Delete Webhook
try {
foreach ($webhookList->getWebhooks() as $webhook) {
$webhook->delete($apiContext);
}
} catch (Exception $ex) {
ResultPrinter::printError("Deleted all Webhooks", "WebhookList", null, null, $ex);
exit(1);
}
ResultPrinter::printResult("Delete all Webhook, as it may have exceed the maximum count.", "WebhookList", null, null, null);
return $output;

View File

@@ -0,0 +1,25 @@
<?php
// # Delete Webhook Sample
//
// This sample code demonstrate how to use this call to search for all webhook events., as documented here at:
// https://developer.paypal.com/docs/api/#delete-a-webhook
// API used: DELETE v1/notifications/webhooks/<Webhook-Id>
// ## Get Webhook Instance
/** @var \PayPal\Api\Webhook $webhook */
$webhook = require 'CreateWebhook.php';
// ### Delete Webhook
try {
$output = $webhook->delete($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Delete a Webhook", "Webhook", null, $webhookId, $ex);
exit(1);
}
ResultPrinter::printResult("Delete a Webhook", "Webhook", $webhook->getId(), null, null);
return $output;

View File

@@ -0,0 +1,26 @@
<?php
// # Get Webhook Sample
//
// This sample code demonstrate how you can get a webhook, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#get-a-webhook
// API used: GET /v1/notifications/webhooks/<Webhook-Id>
// ## Get Webhook ID.
// In samples we are using CreateWebhook.php sample to get the created instance of webhook.
// However, in real case scenario, we could use just the ID from database or retrieved from the form.
/** @var \PayPal\Api\Webhook $webhook */
$webhook = require 'CreateWebhook.php';
$webhookId = $webhook->getId();
// ### Get Webhook
try {
$output = \PayPal\Api\Webhook::get($webhookId, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Get a Webhook", "Webhook", null, $webhookId, $ex);
exit(1);
}
ResultPrinter::printResult("Get a Webhook", "Webhook", $output->getId(), null, $output);
return $output;

View File

@@ -0,0 +1,26 @@
<?php
// # Get Webhook Sample
//
// This sample code demonstrate how you can get a webhook, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#get-a-webhook
// API used: GET /v1/notifications/webhooks/<Webhook-Id>
// ## List Subscribed Event Types
// Use this call to retrieve the list of events types that are subscribed to a webhook.
/** @var \PayPal\Api\Webhook $webhook */
$webhook = require 'CreateWebhook.php';
$webhookId = $webhook->getId();
// ### Get List of Subscribed Event Types
try {
$output = \PayPal\Api\WebhookEventType::subscribedEventTypes($webhookId, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("List subscribed webhook event types", "WebhookEventTypeList", null, $webhookId, $ex);
exit(1);
}
ResultPrinter::printResult("List subscribed webhook event types", "WebhookEventTypeList",null, null, $output);
return $output;

View File

@@ -0,0 +1,27 @@
<?php
// # Get All Webhooks Sample
//
// Use this call to list all the webhooks, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#list-all-webhooks
// API used: GET /v1/notifications/webhooks
// ## List Webhooks
// This step is not necessarily required. We are creating a webhook for sample purpose only, so that we would not
// get an empty list at any point.
// In real case, you dont need to create any webhook to make this API call.
/** @var \PayPal\Api\Webhook $webhook */
$webhook = require_once __DIR__ . '/../bootstrap.php';
// ### Get List of All Webhooks
try {
$output = \PayPal\Api\Webhook::getAll($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("List all webhooks", "WebhookList", null, $webhookId, $ex);
exit(1);
}
ResultPrinter::printResult("List all webhooks", "WebhookList",null, null, $output);
return $output;

View File

@@ -0,0 +1,31 @@
<?php
// # Search Webhook Events Sample
//
// This sample code demonstrate how to use this call to search for all webhook events., as documented here at:
// https://developer.paypal.com/docs/api/#search-webhook-events
// API used: GET /v1/notifications/webhooks-events
// ## Get Webhook Instance
// ## PLEASE NOTE:
// Creating webhook is sample purposes only. In real scenario, you dont need to create a new webhook everytime you want to search
// for a webhook events. This is made in a sample just to make sure there is minimum of one webhook to listen to.
/** @var \PayPal\Api\Webhook $webhook */
$webhook = require __DIR__ . '/../bootstrap.php';
$params = array(
// 'start_time'=>'2014-12-06T11:00:00Z',
// 'end_time'=>'2014-12-12T11:00:00Z'
);
// ### Search Webhook events
try {
$output = \PayPal\Api\WebhookEvent::all($params, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Search Webhook events", "WebhookEventList", null, null, $ex);
exit(1);
}
ResultPrinter::printResult("Search Webhook events", "WebhookEventList", null, $params, $output);
return $output;

View File

@@ -0,0 +1,55 @@
<?php
// # Update Webhook Sample
//
// This sample code demonstrate how to use this call to update a webhook; supports the replace operation only, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#update-a-webhook
// API used: PATCH v1/notifications/webhooks/<Webhook-Id>
// ## Get Webhook ID.
// In samples we are using CreateWebhook.php sample to get the created instance of webhook.
// However, in real case scenario, we could use just the ID from database or use an already existing webhook.
/** @var \PayPal\Api\Webhook $webhook */
$webhook = require 'CreateWebhook.php';
// Updating the webhook as per given request
//
// [
// {
// "op":"replace",
// "path":"/url",
// "value":"https://requestb.in/10ujt3c1"
// },
// {
// "op":"replace",
// "path":"/event_types",
// "value":[
// {
// "name":"PAYMENT.SALE.REFUNDED"
// }
// ]
// }
// ]
$patch = new \PayPal\Api\Patch();
$patch->setOp("replace")
->setPath("/url")
->setValue("https://requestb.in/10ujt3c1?uniqid=". uniqid());
$patch2 = new \PayPal\Api\Patch();
$patch2->setOp("replace")
->setPath("/event_types")
->setValue(json_decode('[{"name":"PAYMENT.SALE.REFUNDED"}]'));
$patchRequest = new \PayPal\Api\PatchRequest();
$patchRequest->addPatch($patch)->addPatch($patch2);
// ### Get Webhook
try {
$output = $webhook->update($patchRequest, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Updated a Webhook", "Webhook", null, $patchRequest, $ex);
exit(1);
}
ResultPrinter::printResult("Updated a Webhook", "Webhook", $output->getId(), $patchRequest, $output);
return $output;

View File

@@ -0,0 +1,21 @@
<?php
// # Get Reference List of all Webhook Event Types
//
// This sample code demonstrate how you can get reference list of all webhook event types, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#get-a-reference-list-of-webhook-event-types
// API used: GET /v1/notifications/webhooks-event-types
$apiContext = require __DIR__ . '/../bootstrap.php';
// ### Get List of all Webhook event types
try {
$output = \PayPal\Api\WebhookEventType::availableEventTypes($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Get List of All Webhook Event Types", "WebhookEventTypeList", null, null, $ex);
exit(1);
}
ResultPrinter::printResult("Get List of All Webhook Event Types", "WebhookEventTypeList", null, null, $output);
return $output;

View File

@@ -0,0 +1,77 @@
<?php
// # Create Webhook Sample
//
// This sample code demonstrate how you can create a webhook, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#create-a-webhook
// API used: POST /v1/notifications/webhooks
require __DIR__ . '/../bootstrap.php';
// Create a new instance of Webhook object
$webhook = new \PayPal\Api\Webhook();
// # Basic Information
// {
// "url":"https://requestb.in/10ujt3c1",
// "event_types":[
// {
// "name":"PAYMENT.AUTHORIZATION.CREATED"
// },
// {
// "name":"PAYMENT.AUTHORIZATION.VOIDED"
// }
// ]
// }
// Fill up the basic information that is required for the webhook
// The URL should be actually accessible over the internet. Having a localhost here would not work.
$webhook->setUrl("https://requestb.in/10ujt3c1?uniqid=" . uniqid());
// # Event Types
// Event types correspond to what kind of notifications you want to receive on the given URL.
$webhookEventTypes = array();
$webhookEventTypes[] = new \PayPal\Api\WebhookEventType(
'{
"name":"PAYMENT.AUTHORIZATION.CREATED"
}'
);
$webhookEventTypes[] = new \PayPal\Api\WebhookEventType(
'{
"name":"PAYMENT.AUTHORIZATION.VOIDED"
}'
);
$webhook->setEventTypes($webhookEventTypes);
// For Sample Purposes Only.
$request = clone $webhook;
// ### Create Webhook
try {
$output = $webhook->create($apiContext);
} catch (Exception $ex) {
// ^ Ignore workflow code segment
if ($ex instanceof \PayPal\Exception\PPConnectionException) {
$data = $ex->getData();
ResultPrinter::printError("Created Webhook Failed. Checking if it is Webhook Number Limit Exceeded. Trying to delete all existing webhooks", "Webhook", "Please Use <a style='color: red;' href='DeleteAllWebhooks.php' >Delete All Webhooks</a> Sample to delete all existing webhooks in sample", $request, $ex);
if (strpos($data,'WEBHOOK_NUMBER_LIMIT_EXCEEDED') !== false) {
require 'DeleteAllWebhooks.php';
try {
$output = $webhook->create($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Created Webhook", "Webhook", null, $request, $ex);
exit(1);
}
} else {
ResultPrinter::printError("Created Webhook", "Webhook", null, $request, $ex);
exit(1);
}
} else {
ResultPrinter::printError("Created Webhook", "Webhook", null, $request, $ex);
exit(1);
}
// Print Success Result
}
ResultPrinter::printResult("Created Webhook", "Webhook", $output->getId(), $request, $output);
return $output;

View File

@@ -79,7 +79,7 @@ $redirectUrls->setReturnUrl("$baseUrl/ExecutePayment.php?success=true")
// A Payment Resource; create one using
// the above types and intent set to 'sale'
$payment = new Payment();
$payment->setIntent("sale")
$payment->setIntent("authorize")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));

View File

@@ -39,6 +39,18 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
ResultPrinter::printResult("Executed Payment", "Payment", $payment->getId(), $execution, $result);
try {
$payment = Payment::get($paymentId, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Get Payment", "Payment", null, null, $ex);
exit(1);
}
ResultPrinter::printResult("Get Payment", "Payment", $payment->getId(), null, $payment);
return $payment;
} else {
ResultPrinter::printResult("User Cancelled the Approval", null);
}

View File

@@ -0,0 +1,157 @@
<?php
namespace PayPal\Test\Functional\Api;
use PayPal\Api\Amount;
use PayPal\Api\Patch;
use PayPal\Api\PatchRequest;
use PayPal\Api\Payment;
use PayPal\Api\PaymentExecution;
use PayPal\Api\Refund;
use PayPal\Api\Sale;
use PayPal\Api\Webhook;
use PayPal\Api\WebhookEvent;
use PayPal\Api\WebhookEventList;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\CreateProfileResponse;
use PayPal\Test\Functional\Setup;
use PayPal\Transport\PPRestCall;
use PayPal\Api\WebProfile;
/**
* Class WebhookFunctionalTest
*
* @package PayPal\Test\Api
*/
class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
{
public $operation;
public $response;
public $mockPPRestCall;
public function setUp()
{
$className = $this->getClassName();
$testName = $this->getName();
$operationString = file_get_contents(__DIR__ . "/../resources/$className/$testName.json");
$this->operation = json_decode($operationString, true);
$this->response = true;
if (array_key_exists('body', $this->operation['response'])) {
$this->response = json_encode($this->operation['response']['body']);
}
Setup::SetUpForFunctionalTests($this);
}
/**
* Returns just the classname of the test you are executing. It removes the namespaces.
* @return string
*/
public function getClassName()
{
return join('', array_slice(explode('\\', get_class($this)), -1));
}
public function testCreate()
{
$request = $this->operation['request']['body'];
$obj = new Webhook($request);
// Adding a random url request to make it unique
$obj->setUrl($obj->getUrl() . '?rand=' . uniqid());
$result = $obj->create(null, $this->mockPPRestCall);
$this->assertNotNull($result);
return $result;
}
/**
* @depends testCreate
* @param $webhook Webhook
* @return Webhook
*/
public function testGet($webhook)
{
$result = Webhook::get($webhook->getId(), null, $this->mockPPRestCall);
$this->assertNotNull($result);
$this->assertEquals($webhook->getId(), $result->getId());
$this->assertEquals($webhook, $result, "", 0, 10, true);
return $result;
}
/**
* @depends testGet
* @param $webhook Webhook
*/
public function testGetAll($webhook)
{
$result = Webhook::getAll(null, $this->mockPPRestCall);
$this->assertNotNull($result);
$found = false;
$foundObject = null;
foreach ($result->getWebhooks() as $webhookObject) {
if ($webhookObject->getId() == $webhook->getId()) {
$found = true;
$foundObject = $webhookObject;
break;
}
}
$this->assertTrue($found, "The Created Web Profile was not found in the get list");
$this->assertEquals($webhook->getId(), $foundObject->getId());
}
/**
* @depends testGet
* @param $webhook Webhook
*/
public function testUpdate($webhook)
{
$patches = array();
foreach ($this->operation['request']['body'] as $request) {
/** @var Patch[] $request */
$patch = new Patch();
$patch->setOp($request['op']);
$patch->setPath($request['path']);
$patch->setValue($request['value']);
if ($request['path'] == "/url") {
$new_url = $request['value'] . '?rand=' .uniqid();
$patch->setValue($new_url);
}
$patches[] = $patch;
}
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $webhook->update($patchRequest, null, $this->mockPPRestCall);
$this->assertNotNull($result);
$found = false;
$foundObject = null;
foreach ($result->getEventTypes() as $eventType) {
if ($eventType->getName() == "PAYMENT.SALE.REFUNDED") {
$found = true;
break;
}
}
$this->assertTrue($found);
}
/**
* @depends testGet
* @param $webhook Webhook
*/
public function testDelete($webhook)
{
$result = $webhook->delete(null, $this->mockPPRestCall);
$this->assertTrue($result);
}
public function testEventSearch()
{
$result = WebhookEvent::all(array(),null, $this->mockPPRestCall);
$this->assertNotNull($result);
return $result;
}
}

View File

@@ -0,0 +1,75 @@
{
"description":"Create a webhook",
"title":"Create a webhook",
"runnable":true,
"operationId":"webhooks.create",
"user":{
"scopes":[
"https://uri.paypal.com/services/applications/webhooks"
]
},
"credentials":{
"oauth":{
"path":"/v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/notifications/webhooks",
"method":"POST",
"headers":{
"Content-Type":"application/json",
"Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn"
},
"body":{
"url":"https://requestb.in/10ujt3c1",
"event_types":[
{
"name":"PAYMENT.AUTHORIZATION.CREATED"
},
{
"name":"PAYMENT.AUTHORIZATION.VOIDED"
}
]
}
},
"response":{
"status":"201",
"headers":{
"Content-Type":"application/json",
"Paypal-Debug-id":"0c444abc1d12d"
},
"body":{
"id":"0EH40505U7160970P",
"url":"https://requestb.in/10ujt3c1",
"event_types":[
{
"name":"PAYMENT.AUTHORIZATION.CREATED",
"description":"A payment authorization was created"
},
{
"name":"PAYMENT.AUTHORIZATION.VOIDED",
"description":"A payment authorization was voided"
}
],
"links":[
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"update",
"method":"PATCH"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"delete",
"method":"DELETE"
}
]
}
}
}

View File

@@ -0,0 +1,33 @@
{
"description":"Delete a webhook",
"title":"Delete a webhook",
"runnable":true,
"operationId":"webhooks.delete",
"user":{
"scopes":[
"https://uri.paypal.com/services/applications/webhooks"
]
},
"credentials":{
"oauth":{
"path":"/v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/notifications/webhooks/5GP028458E2496506",
"method":"DELETE",
"headers":{
"Content-Type":"application/json",
"Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn"
}
},
"response":{
"status":"204",
"headers":{
"Content-Type":"application/json",
"Paypal-Debug-id":"0c444abc1d12d"
}
}
}

View File

@@ -0,0 +1,89 @@
{
"description":"Resend a webhook event",
"title":"Resend a webhook event",
"runnable":true,
"operationId":"event.resend",
"user":{
"scopes":[
"https://uri.paypal.com/services/applications/webhooks"
]
},
"credentials":{
"oauth":{
"path":"/v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/notifications/webhooks-events/8PT597110X687430LKGECATA/resend",
"method":"GET",
"headers":{
"Content-Type":"application/json",
"Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn"
}
},
"response":{
"status":"202",
"headers":{
"Content-Type":"application/json",
"Paypal-Debug-id":"0c444abc1d12d"
},
"body":{
"id":"8PT597110X687430LKGECATA",
"create_time":"2013-06-25T21:41:28Z",
"resource_type":"authorization",
"trigger_event":"PAYMENT.AUTHORIZATION.CREATED",
"summary":"A payment authorization was created",
"resource":{
"id":"2DC87612EK520411B",
"create_time":"2013-06-25T21:39:15Z",
"update_time":"2013-06-25T21:39:17Z",
"state":"authorized",
"amount":{
"total":"7.47",
"currency":"USD",
"details":{
"subtotal":"7.47"
}
},
"parent_payment":"PAY-36246664YD343335CKHFA4AY",
"valid_until":"2013-07-24T21:39:15Z",
"links":[
{
"href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
"rel":"capture",
"method":"POST"
},
{
"href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
"rel":"void",
"method":"POST"
},
{
"href":"https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
"rel":"parent_payment",
"method":"GET"
}
]
},
"links":[
{
"href":"https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend",
"rel":"resend",
"method":"POST"
}
]
}
}
}

View File

@@ -0,0 +1,162 @@
{
"description":"Get list of webhook events",
"title":"Get list of webhook events",
"runnable":true,
"operationId":"event.list",
"user":{
"scopes":[
"https://uri.paypal.com/services/applications/webhooks"
]
},
"credentials":{
"oauth":{
"path":"/v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/notifications/webhooks-events",
"method":"GET",
"headers":{
"Content-Type":"application/json",
"Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn"
}
},
"response":{
"status":"200",
"headers":{
"Content-Type":"application/json",
"Paypal-Debug-id":"0c444abc1d12d"
},
"body":{
"events": [
{
"id": "8PT597110X687430LKGECATA",
"create_time": "2013-06-25T21:41:28Z",
"resource_type": "authorization",
"event_type": "PAYMENT.AUTHORIZATION.CREATED",
"summary": "A payment authorization was created",
"resource": {
"id": "2DC87612EK520411B",
"create_time": "2013-06-25T21:39:15Z",
"update_time": "2013-06-25T21:39:17Z",
"state": "authorized",
"amount": {
"total": "7.47",
"currency": "USD",
"details": {
"subtotal": "7.47"
}
},
"parent_payment": "PAY-36246664YD343335CKHFA4AY",
"valid_until": "2013-07-24T21:39:15Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/authorization/2DC87612EK520411B",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
"rel": "capture",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
"rel": "void",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
"rel": "parent_payment",
"method": "GET"
}
]
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend",
"rel": "resend",
"method": "POST"
}
]
},
{
"id": "HTSPGS710X687430LKGECATA",
"create_time": "2013-06-25T21:41:28Z",
"resource_type": "authorization",
"event_type": "PAYMENT.AUTHORIZATION.CREATED",
"summary": "A payment authorization was created",
"resource": {
"id": "HATH7S72EK520411B",
"create_time": "2013-06-25T21:39:15Z",
"update_time": "2013-06-25T21:39:17Z",
"state": "authorized",
"amount": {
"total": "7.47",
"currency": "USD",
"details": {
"subtotal": "7.47"
}
},
"parent_payment": "PAY-ALDSFJ64YD343335CKHFA4AY",
"valid_until": "2013-07-24T21:39:15Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/authorization/HATH7S72EK520411B",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/authorization/HATH7S72EK520411B/capture",
"rel": "capture",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/authorization/HATH7S72EK520411B/void",
"rel": "void",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-HATH7S72EK520411B",
"rel": "parent_payment",
"method": "GET"
}
]
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/notfications/webhooks-events/HTSPGS710X687430LKGECATA",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/notfications/webhooks-events/HTSPGS710X687430LKGECATA/resend",
"rel": "resend",
"method": "POST"
}
]
}
],
"count": 2,
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/?start_time=2014-08-04T12:46:47-07:00&amp;amp;end_time=2014-09-18T12:46:47-07:00&amp;amp;page_size=2&amp;amp;move_to=next&amp;amp;index_time=2014-09-17T23:07:35Z&amp;amp;index_id=3",
"rel": "next",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/?start_time=2014-08-04T12:46:47-07:00&amp;amp;end_time=2014-09-18T12:46:47-07:00&amp;amp;page_size=2&amp;amp;move_to=previous&amp;amp;index_time=2014-09-17T23:07:35Z&amp;amp;index_id=0",
"rel": "previous",
"method": "GET"
}
]
}
}
}

View File

@@ -0,0 +1,64 @@
{
"description":"Get a webhook",
"title":"Get a webhook",
"runnable":true,
"operationId":"webhooks.get",
"user":{
"scopes":[
"https://uri.paypal.com/services/applications/webhooks"
]
},
"credentials":{
"oauth":{
"path":"/v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/notifications/webhooks/0EH40505U7160970P",
"method":"GET",
"headers":{
"Content-Type":"application/json",
"Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn"
}
},
"response":{
"status":"200",
"headers":{
"Content-Type":"application/json",
"Paypal-Debug-id":"0c444abc1d12d"
},
"body":{
"id":"0EH40505U7160970P",
"url":"https://requestb.in/10ujt3c1",
"event_types":[
{
"name":"PAYMENT.AUTHORIZATION.CREATED",
"description":"A payment authorization was created"
},
{
"name":"PAYMENT.AUTHORIZATION.VOIDED",
"description":"A payment authorization was voided"
}
],
"links":[
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"update",
"method":"PATCH"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"delete",
"method":"DELETE"
}
]
}
}
}

View File

@@ -0,0 +1,99 @@
{
"description":"Get all webhooks",
"title":"Get all webhook",
"runnable":true,
"operationId":"webhooks.get-all",
"user":{
"scopes":[
"https://uri.paypal.com/services/applications/webhooks"
]
},
"credentials":{
"oauth":{
"path":"/v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/notifications/webhooks",
"method":"GET",
"headers":{
"Content-Type":"application/json",
"Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn"
}
},
"response":{
"status":"200",
"headers":{
"Content-Type":"application/json",
"Paypal-Debug-id":"0c444abc1d12d"
},
"body":{
"webhooks":[
{
"id":"40Y916089Y8324740",
"url":"http://www.ebay.com/paypal_webhook",
"event_types":[
{
"name":"PAYMENT.AUTHORIZATION.CREATED",
"description":"A payment authorization was created"
},
{
"name":"PAYMENT.AUTHORIZATION.VOIDED",
"description":"A payment authorization was voided"
}
],
"links":[
{
"href":"https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740",
"rel":"update",
"method":"PATCH"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740",
"rel":"delete",
"method":"DELETE"
}
]
},
{
"id":"0EH40505U7160970P",
"url":"http://www.ebay.com/another_paypal_webhook",
"event_types":[
{
"name":"PAYMENT.AUTHORIZATION.CREATED",
"description":"A payment authorization was created"
},
{
"name":"PAYMENT.AUTHORIZATION.VOIDED",
"description":"A payment authorization was voided"
}
],
"links":[
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"update",
"method":"PATCH"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"delete",
"method":"DELETE"
}
]
}
]
}
}
}

View File

@@ -0,0 +1,89 @@
{
"description":"Get a webhook event",
"title":"Get a webhook event",
"runnable":true,
"operationId":"event.get",
"user":{
"scopes":[
"https://uri.paypal.com/services/applications/webhooks"
]
},
"credentials":{
"oauth":{
"path":"v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/notifications/webhooks-events/8PT597110X687430LKGECATA",
"method":"GET",
"headers":{
"Content-Type":"application/json",
"Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn"
}
},
"response":{
"status":"200",
"headers":{
"Content-Type":"application/json",
"Paypal-Debug-id":"0c444abc1d12d"
},
"body":{
"id":"8PT597110X687430LKGECATA",
"create_time":"2013-06-25T21:41:28Z",
"resource_type":"authorization",
"trigger_event":"PAYMENT.AUTHORIZATION.CREATED",
"summary":"A payment authorization was created",
"resource":{
"id":"2DC87612EK520411B",
"create_time":"2013-06-25T21:39:15Z",
"update_time":"2013-06-25T21:39:17Z",
"state":"authorized",
"amount":{
"total":"7.47",
"currency":"USD",
"details":{
"subtotal":"7.47"
}
},
"parent_payment":"PAY-36246664YD343335CKHFA4AY",
"valid_until":"2013-07-24T21:39:15Z",
"links":[
{
"href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture",
"rel":"capture",
"method":"POST"
},
{
"href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void",
"rel":"void",
"method":"POST"
},
{
"href":"https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY",
"rel":"parent_payment",
"method":"GET"
}
]
},
"links":[
{
"href":"https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend",
"rel":"resend",
"method":"POST"
}
]
}
}
}

View File

@@ -0,0 +1,76 @@
{
"description":"Update a webhook",
"title":"Updated a webhook",
"runnable":true,
"operationId":"webhooks.update",
"user":{
"scopes":[
"https://uri.paypal.com/services/applications/webhooks"
]
},
"credentials":{
"oauth":{
"path":"/v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/notifications/webhooks/0EH40505U7160970P",
"method":"PATCH",
"headers":{
"Content-Type":"application/json",
"Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn"
},
"body":[
{
"op":"replace",
"path":"/url",
"value":"https://requestb.in/10ujt3c1"
},
{
"op":"replace",
"path":"/event_types",
"value":[
{
"name":"PAYMENT.SALE.REFUNDED"
}
]
}
]
},
"response":{
"status":"200",
"headers":{
"Content-Type":"application/json",
"Paypal-Debug-id":"0c444abc1d12d"
},
"body":{
"id":"0EH40505U7160970P",
"url":"https://requestb.in/10ujt3c1",
"event_types":[
{
"name":"PAYMENT.SALE.REFUNDED",
"description":"A sale payment was refunded"
}
],
"links":[
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"self",
"method":"GET"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"update",
"method":"PATCH"
},
{
"href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P",
"rel":"delete",
"method":"DELETE"
}
]
}
}
}

View File

@@ -0,0 +1,56 @@
{
"description":"List of supported webhook events",
"title":"List of supported webhook events",
"runnable":true,
"operationId":"available-event-type.list",
"credentials":{
"oauth":{
"path":"/v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/notifications/webhooks-event-types",
"method":"GET",
"headers":{
"Content-Type":"application/json",
"Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn"
}
},
"response":{
"status":"200",
"headers":{
"Content-Type":"application/json",
"Paypal-Debug-id":"0c444abc1d12d"
},
"body":{
"event_types":[
{
"name":"PAYMENT.AUTHORIZATION.CREATED",
"description":"A payment authorization was created"
},
{
"name":"PAYMENT.AUTHORIZATION.VOIDED",
"description":"A payment authorization was voided"
},
{
"name":"PAYMENT.CAPTURE.COMPLETED",
"description":"A capture payment was completed"
},
{
"name":"PAYMENT.CAPTURE.REFUNDED",
"description":"A capture payment was refunded"
},
{
"name":"PAYMENT.SALE.COMPLETED",
"description":"A sale payment was completed"
},
{
"name":"PAYMENT.SALE.REFUNDED",
"description":"A sale payment was refunded"
}
]
}
}
}

View File

@@ -0,0 +1,45 @@
{
"description":"Events subscribed for a webhook",
"title":"Events subscribed for a webhook",
"runnable":true,
"operationId":"webhook.subscribed-event-types.list",
"user":{
"scopes":[
"https://uri.paypal.com/services/applications/webhooks"
]
},
"credentials":{
"oauth":{
"path":"/v1/oauth/token",
"clientId":"",
"clientSecret":""
}
},
"request":{
"path":"v1/notifications/webhooks/0EH40505U7160970P/event-types",
"method":"GET",
"headers":{
"Content-Type":"application/json",
"Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn"
}
},
"response":{
"status":"200",
"headers":{
"Content-Type":"application/json",
"Paypal-Debug-id":"0c444abc1d12d"
},
"body":{
"event_types":[
{
"name":"PAYMENT.AUTHORIZATION.CREATED",
"description":"A payment authorization was created"
},
{
"name":"PAYMENT.AUTHORIZATION.VOIDED",
"description":"A payment authorization was voided"
}
]
}
}
}