/** * Send order shipment to Rakuten Checkout * * @param oxOrder $oOrder * @return bool * @throws Exception|oxException */ public function sendShipment($oOrder) { /** * Create Rakuten Checkout Send Order Shipment XML request * @var SimpleXMLElement $xml */ $xml = new SimpleXMLElement("<?xml version='1.0' encoding='UTF-8' ?><tradoria_order_shipment />"); $merchantAuth = $xml->addChild('merchant_authentication'); $merchantAuth->addChild('project_id', $this->getConfig()->getShopConfVar('sRakutenProjectId', -1)); $merchantAuth->addChild('api_key', $this->getConfig()->getShopConfVar('sRakutenApiKey', -1)); $xml->addChild('order_no', $oOrder->oxorder__oxtransid->value); /** In sendShipment() method **/ $delSet = oxConfig::getParameter("setDelSet") ? oxConfig::getParameter("setDelSet") : 'andere'; $trackCode = oxConfig::getParameter("oxorder__oxtrackcode"); $xml->addChild('carrier_tracking_id', $delSet); //'andere' $xml->addChild('carrier_tracking_url'); $xml->addChild('carrier_tracking_code', $trackCode); //$oOrder->oxorder__oxtrackcode->value $request = $xml->asXML(); $response = $this->sendShipmentRequest($request); try { $response = @new SimpleXMLElement($response); if ($response->success != 'true') { throw new oxException((string) $response->message, (int) $response->code); } else { if ((string) $response->invoice_number != '') { $oOrder->oxorder__oxremark = new oxField($oOrder->oxorder__oxremark->value . " // \n" . sprintf('Rakuten Invoice No: %s', (string) $response->invoice_number), oxField::T_RAW); $oOrder->save(); } } } catch (Exception $e) { if ($e->getCode()) { $error_code = $e->getCode(); } else { $error_code = '000'; } if ($e->getMessage()) { $error_message = $e->getMessage(); } else { $error_message = 'Unknown error'; } oxUtilsView::getInstance()->addErrorToDisplay('Error sending shipment to Rakuten Checkout. Shipment wasn\'t sent.'); oxUtilsView::getInstance()->addErrorToDisplay(sprintf('Error #%s: %s', $error_code, $error_message)); return false; } return true; }
/** * Overridden function calls Paymorrow services: confirmOrder * * @param $dAmount * @param oxOrder|OxpsPaymorrowOxOrder $oOrder * * @return bool|mixed */ public function executePayment($dAmount, &$oOrder) { /** @var oxUserPayment|OxpsPaymorrowOxUserPayment $oUserPayment */ $oUserPayment = $this->_oPaymentInfo; if ($oUserPayment->isUserPaymentPaymorrowMethod()) { // Set real order ID (OXID field) to session to be used in order confirmation during payment. $oOrder->savePaymorrowTemporaryOrderIdToSession($oOrder->getId()); /** @var OxpsPaymorrowRequestControllerProxy $oPmRequestControllerProxy */ $oPmRequestControllerProxy = oxNew('OxpsPaymorrowRequestControllerProxy'); $oPmRequestControllerProxy->confirmOrder(); /** @var OxpsPaymorrowResponseHandler $oPmResponseHandler */ $oPmResponseHandler = oxRegistry::get('OxpsPaymorrowResponseHandler'); /** * If Order has an error after validation from Paymorrow services invalidate order and delete it * If Payment data save failed return an error */ if ($oPmResponseHandler->hasErrors() or !$this->_savePaymorrowUserPaymentData($oOrder, $oPmResponseHandler)) { $this->_handleOrderResponseErrors($oPmResponseHandler); return false; } } return $this->_OxpsPaymorrowOxPaymentGateway_executePayment_parent($dAmount, $oOrder); }
/** * Return payment type of give order * * @param oxOrder $order * @return string */ protected function _getPaymentType($order) { $data = false; if (isset($order)) { $data = $order->getPaymentType()->oxuserpayments__oxpaymentsid->value; } return $data; }
/** * Checks if order was made using PayPal payment method. * Expected result- false */ public function testIsPayPalOrder_False() { $oPayPalOrder = new oePayPalOrder_PayPal(); $soxId = '_testOrderId'; $oSession = new oxSession(); $oSession->setVariable('saved_oxid', $soxId); $oOrder = new oxOrder(); $oOrder->setId($soxId); $oOrder->oxorder__oxpaymenttype = new oxField('other'); $oOrder->save(); $this->assertFalse($oPayPalOrder->isPayPalOrder()); }
/** * Test updating a completed refund transaction with an valid refund_completed * notification. */ public function testUpdateRefundAgainstCompleted() { $_GET = array('state' => 'refund_completed', 'refund_transaction_id' => '27828461', 'origin_transaction_id' => '27767585', 'shop_id' => '10000', 'customer_email' => '*****@*****.**', 'amount' => '3.9', 'currency' => 'EUR', 'origin_order_id' => '5', 'customer_var_0' => '', 'customer_var_1' => '', 'customer_var_2' => '', 'hash' => 'f261e1f2ec063b31c023dfa10b1471ce87bc4e90c2b3a5a554fdf410c444bce58b9030e86d1eb1298445cb2a8d9de3cceb119a04936418c5a29d86b979ce3337'); $this->oUpdateHandler->checkData($_GET); $this->assertFalse($this->oUpdateHandler->updateRefund()); $oOrder = new oxOrder(); $oOrder->load('6988a7466abe756b93c1f0b2b11af7d3'); $aRefundData = unserialize(str_replace(""", "\"", $oOrder->oxorder__bzrefunds->value)); foreach ($aRefundData as $aRefund) { if ($aRefund['refundid'] == '27828393') { $this->assertEquals('pending', $aRefund['state']); } } }
/** * Test case for oePayPalOxOrder::deletePayPalOrder() * * @return null */ public function testDeletePayPalOrder() { $oTestOrder = new oxOrder(); $oTestOrder->setId('_testOrderId'); $oTestOrder->save(); $this->getSession()->setVariable('sess_challenge', '_testOrderId'); $oOrder = new oePayPalOxOrder(); $oOrder->deletePayPalOrder(); $oUpdatedOrder = new oxOrder(); $this->assertFalse($oUpdatedOrder->load('_testOrderId')); }
/** * Check totals of saved (recalculated) order * * @param array $expected * @param int $approach number of order recalculate events starting at 1 * @param oxOrder $order */ protected function checkTotals($expected, $approach, $order) { $expectedTotals = $expected[$approach]['totals']; $articles = $expected[$approach]['articles']; $isNettoMode = $order->isNettoMode(); $orderArticles = $order->getOrderArticles(); foreach ($orderArticles as $article) { /** @var oxOrderArticle $article */ $articleId = $article->oxorderarticles__oxartid->value; if ($isNettoMode) { $unitPrice = $article->getNetPriceFormated(); $totalPrice = $article->getTotalNetPriceFormated(); } else { $unitPrice = $article->getBrutPriceFormated(); $totalPrice = $article->getTotalBrutPriceFormated(); } $this->assertEquals($articles[$articleId][0], $unitPrice, "#{$approach} Unit price of order art no #{$articleId}"); $this->assertEquals($articles[$articleId][1], $totalPrice, "#{$approach} Total price of order art no #{$articleId}"); } $productVats = $order->getProductVats(true); $this->assertEquals($expectedTotals['totalNetto'], $order->getFormattedTotalNetSum(), "Product Net Price #{$approach}"); $this->assertEquals($expectedTotals['discount'], $order->getFormattedDiscount(), "Discount #{$approach}"); if ($productVats) { foreach ($productVats as $vat => $vatPrice) { $this->assertEquals($expectedTotals['vats'][$vat], $vatPrice, "Vat %{$vat} total cost #{$approach}"); } } $this->assertEquals($expectedTotals['totalBrutto'], $order->getFormattedTotalBrutSum(), "Product Gross Price #{$approach}"); if ($expectedTotals['voucher']) { $this->assertEquals($expectedTotals['voucher']['brutto'], $order->getFormattedTotalVouchers(), "Voucher costs #{$approach}"); } if ($expectedTotals['delivery']) { $this->assertEquals($expectedTotals['delivery']['brutto'], $order->getFormattedeliveryCost(), "Shipping costs #{$approach}"); } if ($expectedTotals['wrapping']) { $this->assertEquals($expectedTotals['wrapping']['brutto'], $order->getFormattedWrapCost(), "Wrapping costs #{$approach}"); } if ($expectedTotals['giftcard']) { $this->assertEquals($expectedTotals['giftcard']['brutto'], $order->getFormattedGiftCardCost(), "Giftcard costs #{$approach}"); } if ($expectedTotals['payment']) { $this->assertEquals($expectedTotals['payment']['brutto'], $order->getFormattedPayCost(), "Charge Payment Method #{$approach}"); } $this->assertEquals($expectedTotals['grandTotal'], $order->getFormattedTotalOrderSum(), "Sum total #{$approach}"); }