File: /home/p/e/t/petsclubcc/shop/modules/amazonpay/controllers/front/keyshare.php
<?php
/**
* 2007-2021 patworx.de
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade AmazonPay to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author patworx multimedia GmbH <service@patworx.de>
* @copyright 2007-2021 patworx multimedia GmbH
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
class AmazonpayKeyshareModuleFrontController extends ModuleFrontController
{
protected $response = [
'result' => ''
];
/**
* Handle KeyShare automatically
*/
public function postProcess()
{
$keyShareHandler = new AmazonPayKeyShareHandler();
if ($keyShareHandler->isValid()) {
if ($keyShareHandler->decrypt()) {
if ($keyShareHandler->store()) {
$this->response['result'] = 'success';
} else {
$this->setError('Storage of configuration not successful');
}
} else {
$this->setError('Decryption of payload not successful');
}
} else {
$this->setError('Payload not valid');
}
if ($this->response['result'] == 'success') {
header("HTTP/1.1 200 OK");
} else {
header("HTTP/1.0 400 Bad Request");
}
header('Content-Type: application/json');
echo Tools::jsonEncode($this->response);
exit();
}
/**
* @param $string
*/
private function setError($string)
{
$this->response['result'] = 'error';
$this->response['message'] = $string;
}
}