Cancel an order
@param string $purchaseOrderId
@param array $order
@return array
@throws \Exception
483583
public function cancel($purchaseOrderId, $order)
    {
        if(!is_numeric($purchaseOrderId)){
            throw new \Exception("purchaseOrderId must be numeric",1448480746);
        }

        $schema = [
            '/orderCancellation' => [
                'namespace' => 'ns3',
                'childNamespace' => 'ns3',
            ],
            '/orderCancellation/orderLines' => [
                'sendItemsAs' => 'orderLine',
            ],
            '/orderCancellation/orderLines/orderLine/orderLineStatuses' => [
                'sendItemsAs' => 'orderLineStatus',
            ],
            '@namespaces' => [
                'ns3' => 'http://walmart.com/mp/v3/orders'
            ],
        ];

        $a2x = new A2X($order, $schema);
        $xml = $a2x->asXml();
        
        return $this->cancelOrder([
            'purchaseOrderId' => $purchaseOrderId,
            'order' => $xml,
        ]);
    }
657346
public function setOrder($order)
    {
        if (!empty($order)) {
            $this->query['order'] = $order;
        } else {
            unset($this->query['order']);
        }
        return $this;
    }
259018
public function close(array $order)
    {
        Datasheet::set($order);
        $param_keys = ['appid', 'mch_id', 'out_trade_no', 'nonce_str'];
        return Helper::request(Helper::GATEWAY_CLOSEORDER, $param_keys);
    }
296389
def delete_order(self, order_id):
        
        payload = {
            "request": "/v1/order/cancel",
            "nonce": self._nonce,
            "order_id": order_id
        }

        signed_payload = self._sign_payload(payload)
        r = requests.post(self.URL + "/order/cancel", headers=signed_payload, verify=True)
        json_resp = r.json()

        try:
            json_resp['avg_execution_price']
        except:
            return json_resp['message']

        return json_resp
846537
public function destroy(Order $order)
    {
        $this->order->destroy($order);

        return redirect()->route('admin.order.order.index')
            ->withSuccess(trans('core::core.messages.resource deleted', ['name' => trans('order::orders.title.orders')]));
    }
1092739
public function cancel( MShop_Order_Item_Interface $order )
	{
		$orderManager = MShop_Factory::createManager( $this->_getContext(), 'order' );

		if( ( $tid = $this->_getOrderServiceItem( $order->getBaseId() )->getAttribute('TRANSACTIONID') ) === null )
		{
			$msg = sprintf( 'PayPal Express: Payment transaction ID for order ID "%1$s" not available', $order->getId() );
			throw new MShop_Service_Exception( $msg );
		}

		$values = $this->_getAuthParameter();
		$values['METHOD'] = 'DoVoid';
		$values['AUTHORIZATIONID'] = $tid;

		$urlQuery = http_build_query( $values, '', '&' );
		$response = $this->_getCommunication()->transmit( $this->_apiendpoint, 'POST', $urlQuery );
		$this->_checkResponse( $order->getId(), $response, __METHOD__ );

		$order->setPaymentStatus( MShop_Order_Item_Abstract::PAY_CANCELED );
		$orderManager->saveItem( $order );
	}
1300455
def cancel_order(self, order_id: str) -> str:
        """"""
        self.log.debug(f'Canceling order id={order_id} on {self.name}')

        if self.dry_run:  # Don't cancel if dry run
            self.log.warning(f'DRY RUN: Order cancelled on {self.name}: id={order_id}')
            return order_id

        try:  # Cancel order
            self._cancel_order(order_id)
        except Exception as e:
            raise self.exception(OrderNotFound, f'Failed to cancel order: id={order_id}', e) from e

        self.log.info(f'Order cancelled on {self.name}: id={order_id}')
        return order_id
708267
public function refund( MShop_Order_Item_Interface $order )
	{
		$orderManager = MShop_Factory::createManager( $this->_getContext(), 'order' );

		$serviceItem = $this->_getOrderServiceItem( $order->getBaseId() );

		if( ( $tid = $serviceItem->getAttribute('TRANSACTIONID') ) === null )
		{
			$msg = sprintf( 'PayPal Express: Payment transaction ID for order ID "%1$s" not available', $order->getId() );
			throw new MShop_Service_Exception( $msg );
		}

		$values = $this->_getAuthParameter();
		$values['METHOD'] = 'RefundTransaction';
		$values['REFUNDSOURCE'] = 'instant';
		$values['REFUNDTYPE'] = 'Full';
		$values['TRANSACTIONID'] = $tid;
		$values['INVOICEID'] = $order->getId();

		$urlQuery = http_build_query( $values, '', '&' );
		$response = $this->_getCommunication()->transmit( $this->_apiendpoint, 'POST', $urlQuery );
		$rvals = $this->_checkResponse( $order->getId(), $response, __METHOD__ );

		$attributes = array( 'REFUNDTRANSACTIONID' => $rvals['REFUNDTRANSACTIONID'] );
		$this->_saveAttributes( $attributes, $serviceItem );

		$order->setPaymentStatus( MShop_Order_Item_Abstract::PAY_REFUND );
		$orderManager->saveItem( $order );
	}
810297
def cancel(self, orderID):
        """"""
        api = "order"
        postdict = {
            'orderID': orderID,
        }
        return self._curl_bitmex(api=api, postdict=postdict, verb="DELETE")
534769
public function shipmentException($orderId, $datetime, $observation)
    {
        /** @var OrderHandler $handler */
        $handler = $this->requestHandler();
        return $handler->shipmentException($orderId, $datetime, $observation);
    }
230772
public function dispatchAction(Order $order)
    {
        $em = $this->getDoctrine()->getEntityManager();

        $order->dispatchBySeller($this->get('exchange_manager')->getExchange());

        $em->persist($order);
        $em->flush();

        $this->get('notifier')->notify(new OrderDispatchedBySellerEvent($order), $this->getUser());

        return $this->redirect($this->generateUrl('Order_show', array(
            'id' => $order->getNumberForPath()
        )));
    }
295986
def _cancel_orphan_orders(self, orderId):
        
        orders = self.ibConn.orders
        for order in orders:
            order = orders[order]
            if order['parentId'] != orderId:
                self.ibConn.cancelOrder(order['id'])
124837
public function cancel(OrderInterface $order): void
    {
        $this->lockProductVariants($order);

        $this->decoratedOperator->cancel($order);
    }
761782
def cancel(self, tid, session):
        ''''''
        request = TOPRequest('taobao.logistics.online.cancel')
        request['tid'] = tid
        self.create(self.execute(request, session), fields = ['is_success','modify_time','recreated_order_id'], models = {'modify_time':TOPDate})
        return self
837487
def cancelOrder(self, order: Order) -> Trade:
        
        self.client.cancelOrder(order.orderId)
        now = datetime.datetime.now(datetime.timezone.utc)
        key = self.wrapper.orderKey(
            order.clientId, order.orderId, order.permId)
        trade = self.wrapper.trades.get(key)
        if trade:
            if not trade.isDone():
                status = trade.orderStatus.status
                if (status == OrderStatus.PendingSubmit and not order.transmit
                        or status == OrderStatus.Inactive):
                    newStatus = OrderStatus.Cancelled
                else:
                    newStatus = OrderStatus.PendingCancel
                logEntry = TradeLogEntry(now, newStatus, '')
                trade.log.append(logEntry)
                trade.orderStatus.status = newStatus
                self._logger.info(f'cancelOrder: {trade}')
                trade.cancelEvent.emit(trade)
                trade.statusEvent.emit(trade)
                self.cancelOrderEvent.emit(trade)
                self.orderStatusEvent.emit(trade)
                if newStatus == OrderStatus.Cancelled:
                    trade.cancelledEvent.emit(trade)
        else:
            self._logger.error(f'cancelOrder: Unknown orderId {order.orderId}')
        return trade
1326346
protected function _cancelOrder()
    {
         if ($this->_order->getId()) {
            // Only save order that's in this magento store
            $this->_order->cancel()->save();
        } else {
            // The order is not in this magento store, simply set state of this empty order to cancel
            $this->_order->setState(Mage_Sales_Model_Order::STATE_CANCELED);
        }
        return $this;
    }
255089
public function refundOrder($orderCode = false, $amount = null)
    {
        if (empty($orderCode) || !is_string($orderCode)) {
            Error::throwError('ip', Error::$errors['refund']['ordercode']);
        }
        OrderService::refundOrder($orderCode, $amount);
    }