/** * {@inheritdoc} */ public function processCallback(PaymentTransaction $paymentTransaction, CallbackResponse $callbackResponse) { $paymentTransaction->setProcessorType(PaymentTransaction::PROCESSOR_CALLBACK); $paymentTransaction->setProcessorName($callbackResponse->getType()); parent::processCallback($paymentTransaction, $callbackResponse); }
/** * 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 order for cart and payment response. * * @param Cart $prestashop_cart Prestashop cart object. * @param CallbackResponse $paynet_response PaynetEasy payment response. * @param int $order_status_id Order status id. * @param float $payment_amount Payment amount. * @param string $order_comment Comment for order. */ protected function createOrder(Cart $prestashop_cart, CallbackResponse $paynet_response, $order_status_id, $payment_amount, $order_comment = null) { $db = Db::getInstance(); $paynet_payment_id = $db->escape($paynet_response->getPaymentPaynetId()); $prestashop_cart_id = $db->escape($prestashop_cart->id); $this->module->validateOrder($prestashop_cart_id, $order_status_id, $payment_amount, $this->module->name, $order_comment, array('transaction_id' => $paynet_payment_id)); $db->update('paynet_payments', array('id_prestashop_order' => $this->module->currentOrder), "`id_paynet_payment` = {$paynet_payment_id} AND `id_prestashop_cart` = {$prestashop_cart_id}"); }
/** * Executes payment gateway processor for customer return from payment form or 3D-auth * * @param CallbackResponse $callbackResponse Callback object with data from payment gateway * @param PaymentTransaction $paymentTransaction Payment transaction for processing * * @return CallbackResponse Validated payment gateway callback */ public function processCustomerReturn(CallbackResponse $callbackResponse, PaymentTransaction $paymentTransaction) { $callbackResponse->setType('customer_return'); return $this->processPaynetEasyCallback($callbackResponse, $paymentTransaction); }
/** * 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); }