/** * 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; }
/** * 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 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')); }