/** * @param OrderPayment $orderPayment * @return \SecurionPay\Response\Charge */ protected function createRefundRequest($orderPayment) { $currencyObject = new Currency((int) $orderPayment['id_currency']); $currency = $currencyObject->iso_code; $total = (double) $orderPayment['amount']; $amount = CurrencyUtils::toMinorUnits($total, $currency); try { $refundRequest = new \SecurionPay\Request\RefundRequest(); $refundRequest->amount($amount)->chargeId($orderPayment['transaction_id']); return $this->module->gateway->refundCharge($refundRequest); } catch (Exception $e) { $this->errors[] = Tools::displayError('Refund exception: ' . $e->getMessage()); } }
/** * @param array $params * @return Response */ public function hookPayment($params) { if (!$this->active) { return; } $cart = $this->context->cart; $currencyObject = new Currency((int) $cart->id_currency); $currency = $currencyObject->iso_code; $total = (double) $cart->getOrderTotal(true, Cart::BOTH); $amount = CurrencyUtils::toMinorUnits($total, $currency); $signedCheckoutRequest = $this->createSecurionPayCharge($amount, $currency); $this->context->smarty->assign(array('publicKey' => $this->getPublicKey(), 'email' => $this->getCurrentUserEmail(), 'checkoutFirstLine' => Configuration::get(self::CHECKOUT_FIRST_LINE), 'checkoutSecondLine' => Configuration::get(self::CHECKOUT_SECOND_LINE), 'checkoutPaymentButton' => Configuration::get(self::CHECKOUT_PAYMENT_BUTTON), 'checkoutRequest' => $signedCheckoutRequest, 'version' => (double) _PS_VERSION_)); if ((double) _PS_VERSION_ >= '1.6') { $this->context->controller->addCSS(_MODULE_DIR_ . $this->name . '/views/css/securionpay.css'); } return $this->display(__FILE__, 'payment.tpl'); }