Platební brána Comgate – výsledek platby
- norbe
- Backer | 405
Tady jsem vykuchal nějaký základ od nás ze systému (vychází to ze https://github.com/…Protocol.php):
$params = $this->presenter->request->getPost()
if(!$this->isAllowedIp($_SERVER["REMOTE_ADDR"])) {
throw new \Exception("IP '{$_SERVER["REMOTE_ADDR"]}' is not allowed");
}
if (
!isset($params) ||
!is_array($params) ||
!isset($params['merchant']) || $params['merchant'] === '' ||
!isset($params['test']) || $params['test'] === '' ||
!isset($params['price']) || $params['price'] === '' ||
!isset($params['curr']) || $params['curr'] === '' ||
!isset($params['refId']) || $params['refId'] === '' ||
!isset($params['cat']) || $params['cat'] === '' ||
!isset($params['transId']) || $params['transId'] === '' ||
!isset($params['secret']) || $params['secret'] === '' ||
!isset($params['status']) || $params['status'] === ''
) {
throw new \Exception('Missing parameters');
}
if (
$params['merchant'] !== $this->merchant ||
$params['test'] !== ($this->test ? 'true' : 'false') ||
$params['secret'] !== $this->secret
) {
throw new \Exception('Invalid merchant identification');
}
$payment = $this->getPaymentByTransaction($params['transId']);
if($payment) {
switch($params['status']) {
case AgmoPaymentsSimpleProtocol::STATUS_PAID:
$payment->completed = TRUE;
break;
case AgmoPaymentsSimpleProtocol::STATUS_CANCELLED:
$payment->completed = FALSE;
break;
}
$this->save($payment);
}