/** * Is called when the user clicks the "process button" but before the order is saved * here we send the PAYMENT_INIT and PAYMENT_REQUEST call to RatePAY in case of an * we redirect the user to the checkout_payment.php with an error message */ public function before_process() { global $order; $result = $this->_paymentInit(); if (!array_key_exists('error', $result) && array_key_exists('transactionId', $result)) { rpSession::setRpSessionEntry('transactionId', $result['transactionId']); rpSession::setRpSessionEntry('transactionShortId', $result['transactionShortId']); $result = $this->_paymentRequest($result['transactionId'], $result['transactionShortId']); if (array_key_exists('error', $result) && !array_key_exists('transactionId', $result)) { rpSession::cleanRpSession(); if ($this->sandbox !== true) { rpData::disableRatepay(); } $error = urlencode(constant(strtoupper($this->code) . '_ERROR')); xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . $error, 'SSL')); } else { rpSession::setRpSessionEntry('customers_country_code', $order->customer['country']['iso_code_2']); rpSession::setRpSessionEntry('descriptor', $result['descriptor']); rpSession::setRpSessionEntry('rpOrder', clone $order); } } else { if ($this->sandbox !== true) { rpData::disableRatepay(); } $error = urlencode(constant(strtoupper($this->code) . '_ERROR_GATEWAY')); xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . $error, 'SSL')); } }