/** * Set the the Credentials and Environment to the Gateway Client * @return void * @throws \Genesis\Exceptions\InvalidArgument */ public function initGatewayClient() { \Genesis\Config::setEndpoint(\Genesis\API\Constants\Endpoints::EMERCHANTPAY); \Genesis\Config::setUsername($this->getUserName()); \Genesis\Config::setPassword($this->getPassword()); $token = $this->getToken(); if (!empty($token)) { \Genesis\Config::setToken($token); } \Genesis\Config::setEnvironment($this->getIsStagingMode() ? \Genesis\API\Constants\Environments::STAGING : \Genesis\API\Constants\Environments::PRODUCTION); }
/** * During "Checkout" we don't know a Token, * however its required at a latter stage, which * means we have to extract it from the payment * data. We save the token when we receive a * notification from Genesis. * * @param \Magento\Sales\Model\Order\Payment\Transaction $paymentTransaction * * @return bool */ public function setTokenByPaymentTransaction($paymentTransaction) { if (!isset($paymentTransaction) || empty($paymentTransaction)) { return false; } $transactionTerminalToken = $this->getTransactionTerminalToken($paymentTransaction); if (!empty($transactionTerminalToken)) { \Genesis\Config::setToken($transactionTerminalToken); return true; } return false; }
/** * During "Checkout" we don't know have a Token, * however its required at a latter stage, which * means we have to extract it from the payment * data. We save the token when we receive a * notification from Genesis, then we only have * to find the earliest payment_transaction * * @param Mage_Sales_Model_Order_Payment $payment * * @return void */ public function setTokenByPaymentTransaction($payment) { $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()->setOrderFilter($payment->getOrder())->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_ASC); /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */ foreach ($collection as $transaction) { $information = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS); foreach ($information as $field => $value) { if ($field == 'terminal_token') { \Genesis\Config::setToken($value); } } } }