Shows details for a webhook, by ID.
public static get ( string $webhookId, |
||
$webhookId | string | |
$apiContext | is the APIContext for this call. It can be used to pass dynamic configuration and credentials. | |
$restCall | PayPalRestCall | is the Rest Call Service that is used to make rest calls |
return |
/** * @depends testCreate * @param $webhook Webhook * @return Webhook */ public function testGet($webhook) { $result = Webhook::get($webhook->getId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($webhook->getId(), $result->getId()); return $result; }
/** * @dataProvider mockProvider * @param Webhook $obj */ public function testGet($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPayPalRestCall->expects($this->any())->method('execute')->will($this->returnValue(WebhookTest::getJson())); $result = $obj->get("webhookId", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); }
<?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;
function delete_webhook($id) { // auth $apiContext = $this->apiContext(); // set webhooks $webhook = new Webhook(); try { $WebhookList = $webhook->get($id, $apiContext); $valid = true; } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $valid = false; } if ($valid === true) { try { $WebhookList->delete($apiContext); } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); } } $avaliable_data = $this->available_webhooks(); for ($i = 0, $n = count($avaliable_data); $i < $n; $i++) { $this->delete_config($avaliable_data[$i]['name']); } }