PayPal\Api\Webhook::create PHP Method

create() public method

Subscribes your webhook listener to events. A successful call returns a webhook object, which includes the webhook ID for later use.
public create ( ApiContext $apiContext = null, PayPalRestCall $restCall = null ) : Webhook
$apiContext PayPal\Rest\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 Webhook
    public function create($apiContext = null, $restCall = null)
    {
        $payLoad = $this->toJSON();
        $json = self::executeCall("/v1/notifications/webhooks", "POST", $payLoad, null, $apiContext, $restCall);
        $this->fromJson($json);
        return $this;
    }

Usage Example

 /**
  * @dataProvider mockProvider
  * @param Webhook $obj
  */
 public function testCreate($obj, $mockApiContext)
 {
     $mockPayPalRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPayPalRestCall->expects($this->any())->method('execute')->will($this->returnValue(self::getJson()));
     $result = $obj->create($mockApiContext, $mockPayPalRestCall);
     $this->assertNotNull($result);
 }
All Usage Examples Of PayPal\Api\Webhook::create