<?php

require 'includes/application_top.php';
require_once '../ext/modules/payment/paymill/WebHooks.php';
try {
    if ($_GET['type'] == 'CC') {
        $privateKey = trim(MODULE_PAYMENT_PAYMILL_CC_PRIVATEKEY);
    } elseif ($_GET['type'] == 'ELV') {
        $privateKey = trim(MODULE_PAYMENT_PAYMILL_ELV_PRIVATEKEY);
    } else {
        throw new Exception('Invalid Type');
    }
    $controller = new WebHooks($privateKey);
    $controller->setEventParameters(array_merge($_GET, $_POST));
} catch (Exception $exception) {
    die($exception->getMessage());
}
Ejemplo n.º 2
0
<?php

require 'includes/application_top.php';
require_once 'ext/modules/payment/paymill/WebHooks.php';
try {
    if ($_GET['type'] == 'CC') {
        $privateKey = trim(MODULE_PAYMENT_PAYMILL_CC_PRIVATEKEY);
    } elseif ($_GET['type'] == 'ELV') {
        $privateKey = trim(MODULE_PAYMENT_PAYMILL_ELV_PRIVATEKEY);
    } else {
        throw new Exception('Invalid Type');
    }
    $controller = new WebHooks($privateKey);
    $body = @file_get_contents('php://input');
    $event_json = json_decode($body, true);
    if (isset($event_json['event']['event_type']) && $event_json['event']['event_type'] != '') {
        $controller->setEventParameters(array_merge($_GET, $_POST, $event_json['event']));
    } else {
        throw new Exception("Invalid Notification");
    }
} catch (Exception $exception) {
    die($exception->getMessage());
}
Ejemplo n.º 3
0
 /**
  * Displays the register/remove Webhook button in the payment config.
  * @param String $type Can be either CC or ELV
  */
 function displayWebhookButton($type)
 {
     if (empty($this->privateKey)) {
         return;
     }
     $webhooks = new WebHooks($this->privateKey);
     $hooks = $webhooks->loadAllWebHooks($type);
     $action = empty($hooks) ? 'register' : 'remove';
     $buttonAction = 'CREATE';
     if ($action === 'remove') {
         $buttonAction = 'REMOVE';
     }
     $buttonText = constant('MODULE_PAYMENT_PAYMILL_' . $type . '_WEBHOOKS_LINK_' . $buttonAction);
     $this->description .= '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>';
     $this->description .= '<script type="text/javascript" src="javascript/paymill_button_webhook.js"></script>';
     $this->description .= '<p><form id="register_webhooks" method="GET">';
     $parameters = 'notification_action=' . $action . '&type=' . $type;
     $this->description .= '<input id="listener" type="hidden" value="' . zen_href_link('paymill_webhook_listener.php', $parameters, 'SSL', false, false) . '"> ';
     $this->description .= '<button type="submit">' . $buttonText . '</button></form></p>';
 }