Ejemplo n.º 1
0
 /**
  * Verifies the parameters posted back by Payrexx
  * @return boolean True on success, false otherwise
  */
 public static function checkIn()
 {
     if (empty($_POST['transaction']['invoice']['paymentRequestId']) || empty($_POST['transaction']['status'])) {
         return false;
     }
     if ($_POST['transaction']['status'] === 'waiting') {
         die;
         // we don't want the shop to update the status to cancelled or confirmed
     }
     if ($_POST['transaction']['status'] !== 'confirmed') {
         return false;
     }
     $invoiceId = $_POST['transaction']['invoice']['paymentRequestId'];
     $arrSettings = \Cx\Core\Setting\Controller\Setting::getArray('Shop', 'config');
     if (empty($arrSettings)) {
         return false;
     }
     $instanceName = !empty($arrSettings['payrexx_instance_name']['value']) ? $arrSettings['payrexx_instance_name']['value'] : '';
     $apiSecret = !empty($arrSettings['payrexx_api_secret']['value']) ? $arrSettings['payrexx_api_secret']['value'] : '';
     if (empty($instanceName) || empty($apiSecret)) {
         return false;
     }
     $payrexx = new \Payrexx\Payrexx($instanceName, $apiSecret);
     $invoice = new \Payrexx\Models\Request\Invoice();
     $invoice->setId($invoiceId);
     try {
         $invoice = $payrexx->getOne($invoice);
     } catch (\Payrexx\PayrexxException $e) {
         return false;
     }
     return $invoice->getStatus() === $_POST['transaction']['status'];
 }