From 78f570f40448f177bd37caf9eef0b6badd191309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maurice=20Preu=C3=9F?= Date: Thu, 29 Sep 2022 14:54:37 +0200 Subject: [PATCH] Create Balance.php --- .../BitinflowPaymentsWallet/Balance.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/Accounts/Traits/BitinflowPaymentsWallet/Balance.php diff --git a/src/Accounts/Traits/BitinflowPaymentsWallet/Balance.php b/src/Accounts/Traits/BitinflowPaymentsWallet/Balance.php new file mode 100644 index 0000000..ab2c40f --- /dev/null +++ b/src/Accounts/Traits/BitinflowPaymentsWallet/Balance.php @@ -0,0 +1,57 @@ +user->getPaymentsUser()->data->balance; + } + + /** + * Deposit given amount from bank to account. + * + * @param float $amount + * @param string $description + * @return bool + */ + public function deposit(float $amount, string $decription): bool + { + $this->user->asPaymentsUser('PUT', sprintf('wallet/deposit', [ + 'amount' => $amount, + 'decription' => $decription, + ])); + } + + /** + * Charge given amount from account. + * + * @param float $amount + * @param string $decription + * @return bool + */ + public function charge(float $amount, string $decription): bool + { + $order = $this->user->orders()->create([ + 'name' => $decription, + 'description' => 'one-time payment', + 'amount' => 1, + 'price' => $amount, + ]); + + return $this->user->orders()->checkout($order->id); + } +}