From 1476446765d88d697fea8f0215face31914443d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maurice=20Preu=C3=9F?= Date: Thu, 29 Sep 2022 14:48:44 +0200 Subject: [PATCH] Create Orders.php --- .../Traits/BitinflowPaymentsWallet/Orders.php | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/Accounts/Traits/BitinflowPaymentsWallet/Orders.php diff --git a/src/Accounts/Traits/BitinflowPaymentsWallet/Orders.php b/src/Accounts/Traits/BitinflowPaymentsWallet/Orders.php new file mode 100644 index 0000000..1f7db3a --- /dev/null +++ b/src/Accounts/Traits/BitinflowPaymentsWallet/Orders.php @@ -0,0 +1,76 @@ +user->asPaymentsUser('GET', 'orders'); + } + + /** + * @param string $id + * @return object|null + */ + public function get(string $id): ?object + { + return $this->user->asPaymentsUser('GET', sprintf('orders/%s', $id)); + } + + /** + * Create a new order. + * + * @param array $order_items + * @param array $attributes + * @param bool $checkout optional checkout it directly + * @return object|false + */ + public function create(array $order_items = [], array $attributes = [], bool $checkout = false): object|false + { + $attributes = array_merge($attributes, [ + 'order_items' => $order_items, + 'checkout' => $checkout + ]); + + return $this->user->asPaymentsUser('POST', 'orders', $attributes)->data; + } + + /** + * Checkout given subscription. + * + * @param string $id + * @return bool + */ + public function checkout(string $id): bool + { + $this->user->asPaymentsUser('PUT', sprintf('orders/%s/checkout', $id)); + + return true; + } + + /** + * Revoke a running subscription. + * + * @param string $id + * @return bool + */ + public function revoke(string $id): bool + { + $this->user->asPaymentsUser('PUT', sprintf('orders/%s/revoke', $id)); + + return true; + } +}