/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { parent::setUp(); $pluginVersion = WirecardCEE_QMore_FrontendClient::generatePluginVersion('InitiationTest', '0.0.0', 'defaultInstance', '0.0.0'); $oBackClient = new WirecardCEE_QMore_BackendClient(array('CUSTOMER_ID' => $this->_customerId, 'SHOP_ID' => $this->_shopId, 'SECRET' => $this->_secret, 'LANGUAGE' => $this->_language, 'PASSWORD' => $this->_toolkitPassword)); $this->object = $oBackClient->getOrderDetails($this->_orderNumber)->getOrder()->getPayments()->current(); }
public function testSetFinancialInstitution() { $sFinancialInstitution = 'BA-CA'; $this->object->setFinancialInstitution($sFinancialInstitution); $expected = array_merge($this->aExpectedRequestData, array(WirecardCEE_QMore_FrontendClient::FINANCIAL_INSTITUTION => $sFinancialInstitution)); $this->assertAttributeEquals($expected, '_requestData', $this->object); }
public function initPayment($storageId, $orderIdent) { $order = $this->getOrder(); /** @var Wirecard_CheckoutSeamless_Helper_Data $helper */ $helper = Mage::helper('wirecard_checkoutseamless'); $precision = 2; $returnUrl = Mage::getUrl('wirecard_checkoutseamless/processing/return', array('_secure' => true, '_nosid' => true)); $init = new WirecardCEE_QMore_FrontendClient($helper->getConfigArray()); $init->setPluginVersion($helper->getPluginVersion()); $init->setConfirmUrl(Mage::getUrl('wirecard_checkoutseamless/processing/confirm', array('_secure' => true, '_nosid' => true))); $init->setOrderReference(sprintf('%010d', $this->getOrder()->getRealOrderId())); if (strlen($storageId)) { $init->setStorageId($storageId); } if (strlen($orderIdent)) { $init->setOrderIdent($orderIdent); } if ($helper->getConfigData('options/sendconfirmationemail')) { $init->setConfirmMail(Mage::getStoreConfig('trans_email/ident_general/email')); } if (strlen($this->getFinancialInstitution())) { $init->setFinancialInstitution($this->getFinancialInstitution()); } $paymenttype = $this->_paymentMethod; $init->setAmount(round($this->getOrder()->getBaseGrandTotal(), 2))->setCurrency($this->getOrder()->getBaseCurrencyCode())->setPaymentType($paymenttype)->setOrderDescription($this->getUserDescription())->setSuccessUrl($returnUrl)->setPendingUrl($returnUrl)->setCancelUrl($returnUrl)->setFailureUrl($returnUrl)->setServiceUrl($helper->getConfigData('options/serviceurl'))->setConsumerData($this->_getConsumerData()); // XXX ToDo setWindowName $init->mage_orderId = $this->getOrder()->getRealOrderId(); $init->generateCustomerStatement($helper->getConfigData('options/shopname')); if ($helper->getConfigData('options/sendbasketinformation') || $this->_paymentMethod == WirecardCEE_Stdlib_PaymentTypeAbstract::INSTALLMENT && $this->getConfigData('provider') == 'ratepay' || $this->_paymentMethod == WirecardCEE_Stdlib_PaymentTypeAbstract::INVOICE && $this->getConfigData('provider') == 'ratepay') { $basket = new WirecardCEE_Stdlib_Basket(); $basket->setCurrency($this->getOrder()->getBaseCurrencyCode()); foreach ($order->getAllVisibleItems() as $item) { /** @var Mage_Sales_Model_Order_Item $item */ $bitem = new WirecardCEE_Stdlib_Basket_Item(); $bitem->setDescription($item->getProduct()->getName()); $bitem->setArticleNumber($item->getSku()); $bitem->setUnitPrice(number_format($item->getPrice(), $precision, '.', '')); $bitem->setTax(number_format($item->getTaxAmount(), $precision, '.', '')); $basket->addItem($bitem, (int) $item->getQtyOrdered()); $helper->log(print_r($bitem, true)); } $bitem = new WirecardCEE_Stdlib_Basket_Item(); $bitem->setArticleNumber('shipping'); $bitem->setUnitPrice(number_format($order->getShippingAmount(), $precision, '.', '')); $bitem->setTax(number_format($order->getShippingTaxAmount(), $precision, '.', '')); $bitem->setDescription($order->getShippingDescription()); $basket->addItem($bitem); foreach ($basket->__toArray() as $k => $v) { $init->{$k} = $v; } } $helper->log(__METHOD__ . ':' . print_r($init->getRequestData(), true), Zend_Log::INFO); try { $initResponse = $init->initiate(); } catch (Exception $e) { $helper->log(__METHOD__ . ':' . $e->getMessage(), Zend_Log::ERR); $message = $helper->__('An error occurred during the payment process'); throw new Exception($message); } if ($initResponse->getStatus() == WirecardCEE_QMore_Response_Initiation::STATE_FAILURE) { $msg = array(); foreach ($initResponse->getErrors() as $error) { $msg[] = $error->getConsumerMessage(); } if (!count($msg)) { // dont show technical error to consumer $message = $helper->__('An error occurred during the payment process'); } else { $message = implode("<br/>\n", $msg); } $helper->log(__METHOD__ . ':' . $message, Zend_Log::ERR); throw new Exception($message); } return $initResponse; }
public function getPluginVersion() { return WirecardCEE_QMore_FrontendClient::generatePluginVersion('Magento', Mage::getVersion(), $this->_pluginName, $this->_pluginVersion); }
/** * * @param array|Object $config */ public function __construct(array $config = null) { $this->_fingerprintOrder = new WirecardCEE_Stdlib_FingerprintOrder(); //if no config was sent fallback to default config file if (is_null($config)) { $config = WirecardCEE_QMore_Module::getConfig(); } if (isset($config['WirecardCEEQMoreConfig'])) { //we only need the WirecardCEEQMoreConfig here $config = $config['WirecardCEEQMoreConfig']; } //let's store configuration details in internal objects $this->oUserConfig = is_object($config) ? $config : new WirecardCEE_Stdlib_Config($config); $this->oClientConfig = new WirecardCEE_Stdlib_Config(WirecardCEE_QMore_Module::getClientConfig()); self::$FRAMEWORK_NAME = $this->getClientConfig()->DEPENDENCIES->FRAMEWORK_NAME; //now let's check if the CUSTOMER_ID, SHOP_ID, LANGUAGE and SECRET exist in $this->oUserConfig object that we've created from config array $sCustomerId = isset($this->oUserConfig->CUSTOMER_ID) ? trim($this->oUserConfig->CUSTOMER_ID) : null; $sShopId = isset($this->oUserConfig->SHOP_ID) ? trim($this->oUserConfig->SHOP_ID) : null; $sLanguage = isset($this->oUserConfig->LANGUAGE) ? trim($this->oUserConfig->LANGUAGE) : null; $sSecret = isset($this->oUserConfig->SECRET) ? trim($this->oUserConfig->SECRET) : null; //If not throw the InvalidArgumentException exception! if (empty($sCustomerId) || is_null($sCustomerId)) { throw new WirecardCEE_QMore_Exception_InvalidArgumentException(sprintf('CUSTOMER_ID passed to %s is invalid.', __METHOD__)); } if (empty($sLanguage) || is_null($sLanguage)) { throw new WirecardCEE_QMore_Exception_InvalidArgumentException(sprintf('LANGUAGE passed to %s is invalid.', __METHOD__)); } if (empty($sSecret) || is_null($sSecret)) { throw new WirecardCEE_QMore_Exception_InvalidArgumentException(sprintf('SECRET passed to %s is invalid.', __METHOD__)); } //everything ok! let's set the fields $this->_setField(self::SHOP_ID, $sShopId); $this->_setField(self::CUSTOMER_ID, $sCustomerId); $this->_setField(self::LANGUAGE, $sLanguage); $this->_setSecret($sSecret); }