/** * 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 payment status */ public function testGetPaymentStatus() { $oResponse = new oePayPalResponseDoExpressCheckoutPayment(); $oResponse->setData($this->_getResponseData()); $this->assertEquals('confirmed', $oResponse->getPaymentStatus()); }