/** * Creates order for cart if payment processed with error. * * @param Cart $prestashop_cart Prestashop cart object. */ protected function createOrderWithErrorPayment(Cart $prestashop_cart, CallbackResponse $paynet_response, $error_message = null) { $order_comment = $paynet_response->getStatus(); if (!is_null($error_message)) { $order_comment .= ": {$error_message}"; } // If now set status 'PS_OS_ERROR', transaction will not be saved. // But because assigned amount '0' and status 'PS_OS_PAYMENT', transaction will be saved // and displayed with warning in admin control panel. $this->createOrder($prestashop_cart, $paynet_response, Configuration::get('PS_OS_PAYMENT'), 0, $order_comment); }
/** * Validate callback response control code * * @param PaymentTransaction $paymentTransaction Payment transaction for control code checking * @param CallbackResponse $callbackResponse Callback for control code checking * * @throws ValidationException Invalid control code */ protected function validateSignature(PaymentTransaction $paymentTransaction, CallbackResponse $callbackResponse) { // This is SHA-1 checksum of the concatenation // status + orderid + client_orderid + merchant-control. $expectedControlCode = sha1($callbackResponse->getStatus() . $callbackResponse->getPaymentPaynetId() . $callbackResponse->getPaymentClientId() . $paymentTransaction->getQueryConfig()->getSigningKey()); if ($expectedControlCode !== $callbackResponse->getControlCode()) { throw new ValidationException("Actual control code '{$callbackResponse->getControlCode()}' does " . "not equal expected '{$expectedControlCode}'"); } }
/** * Creates control code and set in to callback * * @param CallbackResponse $callbackResponse Callback object */ protected function signCallback(CallbackResponse $callbackResponse) { $callbackResponse['control'] = sha1($callbackResponse->getStatus() . $callbackResponse->getPaymentPaynetId() . $callbackResponse->getPaymentClientId() . self::SIGNING_KEY); }