@param array|JsonSerializable|Webhook $data
@param string|null $webhookId

@return Webhook
960728
public function create($data, $webhookId = null)
    {
        if (isset($webhookId)) {
            return $this->client()->put($data, 'webhooks/{webhookId}', ['webhookId' => $webhookId]);
        }

        return $this->client()->post($data, 'webhooks');
    }
319418
public function createFromToken($token, $data, $cardId = null)
    {
        if ($data instanceof JsonSerializable) {
            $data = $data->jsonSerialize();
        }

        if (is_string($token)) {
            $data['token'] = $token;
        } else {
            $data['token'] = $token['token'];
        }

        return $this->create($data, $cardId);
    }
1245175
function post($url, $data, $callback = null)
    {
        $ret = new CoURLResult($url, $callback, $this->handle);
        $ret->method = self::METHOD_POST;
        $ret->data = $data;
        $this->requests[$ret->id] = $ret;
        return $ret;
    }
294681
private function handleWebhook() {
        $identifier = $this->field('identifier');

        if ($identifier !== $this->identifier) {
            return;
        }

        $event_id = $this->field('event_id');
        $webhook_id = $this->field('webhook_id');

        if (!$event_id || !$webhook_id) {
            Log::info($this->patrol, 'Webhook ' . $this->identifier . ' has no event_id or webhook_id');
            return;
        }

        $httpClient = new HttpClient($this->patrol, 'GET', 'webhooks/' . $webhook_id . '/events/' . $event_id);
        $response = $httpClient->response();

        if (!$response) {
            Log::info($this->patrol, 'Retrieving webhook from ' . $httpClient->getUrl() . ' failed');
            return;
        }

        $data = $this->field($response, 'data');

        if (!$data) {
            Log::info($this->patrol, 'Event has invalid format to be processed: ' . print_r($response, true));
        }

        $callable = $this->callback;

        if (is_callable($callable)) {
            $callable($data);
        }
    }
266536
function decode(string $data) {
        try {
            $msg = $this->etf->decode($data);
            if($msg === '' || $msg === null) {
                throw new \CharlotteDunois\Yasmin\WebSocket\DiscordGatewayException('The ETF decoder was unable to decode the data');
            }
        } catch (\CharlotteDunois\Kimberly\Exception $e) {
            throw new \CharlotteDunois\Yasmin\WebSocket\DiscordGatewayException('The ETF decoder was unable to decode the data', 0, $e);
        }
        
        $obj = $this->convertIDs($msg);
        return $obj;
    }
756180
public function setWebhookUrls(array $webhookUrls)
    {
        foreach ($webhookUrls as $key => $webhookUrl) {
            $this->webhookUrls[$key] = $this->parseUrl($webhookUrl);
        }
    }
410125
def send_webhook(config, payload):
    
    try:
        response = requests.post(
            config['webhook_url'],
            data=json.dumps(payload, cls=ModelJSONEncoder),
            headers={config['api_key_header_name']: config['api_key']},
        )
    except Exception as e:
        logger.warning('Unable to send webhook: ({1}) {2}'.format(
            e.__class__.__name__,
            e.message,
        ))
    else:
        logger.debug('Webhook response: ({0}) {1}'.format(
            response.status_code,
            response.text,
        ))
413673
public function msgOk ($data = null, $groups = "", $message = "", $httpStatusCode = Response::HTTP_ACCEPTED)
    {
        return $this->responseOk ($data, $groups, $message, $httpStatusCode);
    }
301119
public function addWebhook($listId, array $webhookData)
    {
        $result = $this->mailchimp->post("lists/$listId/webhooks", $webhookData);

        if (!$this->mailchimp->success()) {
            $this->throwMailchimpError($this->mailchimp->getLastResponse());
        }

        return $result;
    }
688272
public function sendData($data)
    {
        $request = new AopNotifyRequest($this->httpClient, $this->httpRequest);
        $request->initialize($this->parameters->all());
        $request->setEndpoint($this->getEndpoint());
        $request->setParams($data);
        $request->setSort(false);
        $request->setEncodePolicy(Signer::ENCODE_POLICY_JSON);
        $request->setAlipayPublicKey($this->getAlipayPublicKey());

        /**
         * @var AopNotifyResponse $response
         */
        $response = $request->send();

        return $response;
    }
191618
public function onCallbackSuccess($order, $data = null)
    {
        $paymentId  = is_array($data) ? $data['paymentId'] : $data->paymentId;

        $payerId    = is_array($data) ? $data['PayerID'] : $data->PayerID;

        $this->statusCode = 'failed';

        $this->detail = sprintf('Payment failed. Ref: %s', $paymentId);

        // Begin paypal
        try {

            $this->setContext();

            $payment = Payment::get($paymentId, $this->apiContext);
            
            $execution = new PaymentExecution();

            $execution->setPayerId($payerId);

            $payment->execute($execution, $this->apiContext);

            $payment = Payment::get($paymentId, $this->apiContext);

            $this->statusCode = 'completed';

            $this->transactionId = $payment->id;

            $this->detail = 'Success';

        } catch (PayPalConnectionException $e) {

            $response = json_decode($e->getData());

            throw new GatewayException(
                sprintf(
                    '%s: %s',
                    $response->name,
                    isset($response->message) ? $response->message : 'Paypal payment Failed.'
                ),
                1001,
                $e
            );

        } catch (\Exception $e) {

            throw new GatewayException(
                $e->getMessage(),
                1000,
                $e
            );

        }
    }
475343
private function _handle3DSecureFlowEvent(array $data)
    {
        $dataObject = $data['data']['object'];
        $sourceId = $dataObject['id'];
        $counter = 0;
        $limit = 15;

        do {
            // Handle cases when Stripe sends us a webhook so soon that we haven't processed the transactions that triggered the webhook
            sleep(1);
            $transaction = Commerce::getInstance()->getTransactions()->getTransactionByReferenceAndStatus($sourceId, TransactionRecord::STATUS_PROCESSING);
            $counter++;
        } while (!$transaction && $counter < $limit);

        if (!$transaction) {
            Craft::error('Transaction with the reference “' . $sourceId . '” and status “' . TransactionRecord::STATUS_PROCESSING . '” not found when processing webhook ' . $data['id'], 'stripe');

            throw new TransactionException('Transaction with the reference “' . $sourceId . '” and status “' . TransactionRecord::STATUS_PROCESSING . '” not found when processing webhook ' . $data['id']);
        }

        $childTransaction = Commerce::getInstance()->getTransactions()->createTransaction(null, $transaction);
        $childTransaction->reference = $data['id'];

        try {
            switch ($data['type']) {
                case 'source.chargeable':
                    $sourceId = $dataObject['id'];
                    $requestData = $this->_buildRequestData($transaction);
                    $requestData['source'] = $sourceId;
                    $requestData['capture'] = !($childTransaction->type === TransactionRecord::TYPE_AUTHORIZE);

                    try {
                        $charge = Charge::create($requestData, ['idempotency_key' => $childTransaction->hash]);

                        $stripeResponse = $this->_createPaymentResponseFromApiResource($charge);
                    } catch (\Exception $exception) {
                        $stripeResponse = $this->_createPaymentResponseFromError($exception);
                    }

                    if ($stripeResponse->isSuccessful()) {
                        $childTransaction->status = TransactionRecord::STATUS_SUCCESS;
                    } else {
                        $childTransaction->status = TransactionRecord::STATUS_FAILED;
                    }

                    $childTransaction->response = $stripeResponse->getData();
                    $childTransaction->code = $stripeResponse->getCode();
                    $childTransaction->reference = $stripeResponse->getTransactionReference();
                    $childTransaction->message = $stripeResponse->getMessage();

                    break;
                case 'source.canceled':
                case 'source.failed':
                    $childTransaction->status = TransactionRecord::STATUS_FAILED;
                    $childTransaction->reference = $data['id'];
                    $childTransaction->code = $data['type'];
                    $childTransaction->message = Craft::t('commerce-stripe', 'Failed to process the charge.');
                    $childTransaction->response = Json::encode($data);
                    break;
            }

            Commerce::getInstance()->getTransactions()->saveTransaction($childTransaction);

            if (
                ($childTransaction->status === TransactionRecord::STATUS_SUCCESS) &&
                $this->hasEventHandlers(self::EVENT_RECEIVE_3DS_PAYMENT)
            ) {
                $this->trigger(self::EVENT_RECEIVE_3DS_PAYMENT, new Receive3dsPaymentEvent([
                    'transaction' => $childTransaction
                ]));
            }
        } catch (\Exception $exception) {
            Craft::error('Could not process webhook ' . $data['id'] . ': ' . $exception->getMessage(), 'stripe');
            $childTransaction->status = TransactionRecord::STATUS_FAILED;
            Commerce::getInstance()->getTransactions()->saveTransaction($childTransaction);
        }
    }
279165
public static function post($urls, $data = null, callable $callback = null)
    {
        return static::make('post', $urls, $data, $callback);
    }
421818
public ItemRequest<Webhook> getById(String webhook) {
    
        String path = String.format("/webhooks/%s", webhook);
        return new ItemRequest<Webhook>(this, Webhook.class, path, "GET");
    }
1109549
public function update($webhookId, $url)
    {
        $enpoint = "{$this->apiUrl}/webhooks/stores/{$webhookId}";
        $data = [
            "url" => $url
        ];

        $res = Requests::put(
            $enpoint,
            $this->headers,
            json_encode($data),
            $this->options
        );
        $this->validateResponse($res);

        return json_decode($res->body, true);
    }
718326
public function validateAndParseWebhookNotificationFromRequest(\Symfony\Component\HttpFoundation\Request $request) {
        $json_data = json_decode($request->getContent(), true);
        if (!is_array($json_data)) { throw new AuthorizationException("Invalid webhook data received"); }

        // make sure the message is signed properly
        //   throws an exception if invalid
        $this->validateWebhookNotification($json_data);

        return $this->parseWebhookNotificationData($json_data);
    }
732457
public function setup($data) {

    if (is_object($data[0])) {
      $data = Converter::toArray($data[0]);
    }

    foreach ($data as $k => $d) {
      if (!in_array($k,array("token","expires"))) {
        throw new CatapultApiException("$k is not a valid key for endpoint token");
      }
    }
    $arr = array('token', 'expires');
    foreach ($arr as $a) {
      if (isset($data[$a])) {
        $this->$a = $data[$a];
      }
    }
    // important don't serialize
    // when sending in a Endpoints object
    $this->serialize = FALSE;
  }