<?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. // #### There is an open source tool http://requestb.in/ that allows you to receive any web requests to a url given there. // #### NOTE: Please note that you need an https url for paypal webhooks. You can however override the url with https, and accept // any warnings your browser might show you. Also, please note that this is entirely for demo purposes, and you should not // be using this in production $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.
/** * Delete webhook with webhookId for PayPal APP $this->_apiContext * * @param $webhookId * @return bool */ public function deleteWebhook($webhookId) { $webhook = new \PayPal\Api\Webhook(); $webhook->setId($webhookId); try { return $webhook->delete($this->_apiContext); } catch (PayPal\Exception\PayPalConnectionException $ex) { Mage::helper('iways_paypalplus')->handleException($ex); return false; } catch (Exception $e) { Mage::logException($e); return false; } return false; }