/** * Test case for oePayPalOxOrder::finalizePayPalOrder() * * @return null */ public function testFinalizePayPalOrder() { // creating order $oOrder = new oxOrder(); $oOrder->setId('_testOrderId'); $oOrder->oxorder__oxtransstatus = new oxField('NOT_FINISHED'); $oOrder->save(); /** @var oxBasket $oBasket */ $oBasket = oxNew('oxBasket'); $this->getSession()->setVariable('sess_challenge', '_testOrderId'); $oOrder = new oePayPalOxOrder(); $oOrder->loadPayPalOrder(); $aResult = array('PAYMENTINFO_0_TRANSACTIONID' => '_testTranzactionId'); $oDetails = new oePayPalResponseDoExpressCheckoutPayment(); $oDetails->setData($aResult); $oOrder->finalizePayPalOrder($oDetails, $oBasket, 'Sale'); $this->assertEquals('NOT_FINISHED', $oOrder->oxorder__oxtransstatus->value); $this->assertEquals('_testTranzactionId', $oOrder->oxorder__oxtransid->value); $this->assertEquals('0000-00-00', substr($oOrder->oxorder__oxpaid->value, 0, 10)); }
/** * Finalizes PayPal order. * * @param oePayPalResponseDoExpressCheckoutPayment $oResult PayPal results array. * @param oxBasket $oBasket Basket object. * @param string $sTransactionMode Transaction mode Sale|Authorization. */ public function finalizePayPalOrder($oResult, $oBasket, $sTransactionMode) { $sDate = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime()); // set order status, transaction ID and payment date to order $this->_setPaymentInfoPayPalOrder($oResult->getTransactionId()); $sCurrency = $oResult->getCurrencyCode(); if (!$sCurrency) { $sCurrency = $this->getOrderCurrency()->name; } //PayPal order info $oPayPalOrder = $this->getPayPalOrder(); $oPayPalOrder->setOrderId($this->getId()); $oPayPalOrder->setPaymentStatus('pending'); $oPayPalOrder->setTransactionMode($sTransactionMode); $oPayPalOrder->setCurrency($sCurrency); $oPayPalOrder->setTotalOrderSum($oBasket->getPrice()->getBruttoPrice()); if ($sTransactionMode == 'Sale') { $oPayPalOrder->setCapturedAmount($oBasket->getPrice()->getBruttoPrice()); } $oPayPalOrder->save(); $oOrderPayment = oxNew('oePayPalOrderPayment'); $oOrderPayment->setTransactionId($oResult->getTransactionId()); $oOrderPayment->setCorrelationId($oResult->getCorrelationId()); $oOrderPayment->setDate($sDate); $oOrderPayment->setAction($sTransactionMode == 'Sale' ? 'capture' : 'authorization'); $oOrderPayment->setStatus($oResult->getPaymentStatus()); $oOrderPayment->setAmount($oResult->getAmount()); $oOrderPayment->setCurrency($oResult->getCurrencyCode()); //Adding payment information $oPaymentList = $this->getPayPalOrder()->getPaymentList(); $oPaymentList->addPayment($oOrderPayment); //setting order payment status after $oPaymentStatusCalculator = oxNew('oePayPalOrderPaymentStatusCalculator'); $oPaymentStatusCalculator->setOrder($this->getPayPalOrder()); $this->getPayPalOrder()->setPaymentStatus($oPaymentStatusCalculator->getStatus()); $this->getPayPalOrder()->save(); //clear PayPal identification $this->getSession()->deleteVariable('oepaypal'); $this->getSession()->deleteVariable("oepaypal-payerId"); $this->getSession()->deleteVariable("oepaypal-userId"); $this->getSession()->deleteVariable('oepaypal-basketAmount'); }
/** * Test get currency code */ public function testGetCurrencyCode() { $oResponse = new oePayPalResponseDoExpressCheckoutPayment(); $oResponse->setData($this->_getResponseData()); $this->assertEquals('LTL', $oResponse->getCurrencyCode()); }