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 = null; try { $result = $obj->create($this->apiContext, $this->mockPayPalRestCall); } catch (PayPalConnectionException $ex) { $data = $ex->getData(); if (strpos($data, 'WEBHOOK_NUMBER_LIMIT_EXCEEDED') !== false) { $this->deleteAll(); $result = $obj->create($this->apiContext, $this->mockPayPalRestCall); } else { $this->fail($ex->getMessage()); } } $this->assertNotNull($result); return $result; }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Url is not a fully qualified URL */ public function testUrlValidationForUrl() { $obj = new Webhook(); $obj->setUrl(null); }
function create_webhook($data) { // auth $apiContext = $this->apiContext(); $webhookEventTypes = array(); for ($i = 0, $n = count($data['data']); $i < $n; $i++) { if ($data['data'][$i]['name'] != '') { $webhookEvent = new WebhookEventType(); $webhookEvent->setName($data['data'][$i]['name']); $webhookEventTypes[] = $webhookEvent; } } // set webhook $webhook = new Webhook(); $webhook->setUrl(xtc_catalog_href_link('callback/paypal/webhook.php', '', 'SSL', false))->setEventTypes($webhookEventTypes); try { $WebhookList = $webhook->create($apiContext); } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); } $sql_data_array = array(); for ($i = 0, $n = count($data['data']); $i < $n; $i++) { if ($data['data'][$i]['name'] != '') { $sql_data_array[] = array('config_key' => $data['data'][$i]['name'], 'config_value' => $data['data'][$i]['orders_status']); } } $this->save_config($sql_data_array); }