From 3645920f0ba7063382f6a509899f1eaea28be257 Mon Sep 17 00:00:00 2001 From: sasha Date: Mon, 14 Feb 2022 05:46:43 +0200 Subject: [PATCH] add cancel for order --- src/API2Client/Api.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/API2Client/Api.php b/src/API2Client/Api.php index 3a5b706..9522403 100644 --- a/src/API2Client/Api.php +++ b/src/API2Client/Api.php @@ -362,4 +362,32 @@ public function cancelPaymentSubscription ($id) return $subscription ->create ($response->getResult ()); } -} \ No newline at end of file + + /** + * @param $order_id + * @param $black_list + * @param $refund + * @param $comment + * @return string + * @throws ApiException + */ + public function cancelOrder($order_id, $black_list = 0, $refund = 1, $comment = '') + { + $response = $this->client->call( + 'orders.cancel', + array( + 'order_id' => $order_id, + 'black_list' => $black_list, + 'refund' => $refund, + 'comment' => $comment + ), + HttpClient::REQUEST_RAW + ); + + if (!$response->isSuccess ()) { + throw new ApiException ($response->getErrorMessage ()); + } + + return $order_id; + } +}