Restore CRLF line endings in ManagesBalance

This commit is contained in:
envoyr committed 2026-11-06 20:03:12 +00:00
1 parent 3a78359f59
commit be91df6d18
1 file changed
+66 -66
+66 -66
View File
@@ -1,66 +1,66 @@
<?php <?php
namespace Anikeen\Id\Concerns; namespace Anikeen\Id\Concerns;
use Anikeen\Id\Resources\Transaction; use Anikeen\Id\Resources\Transaction;
use Throwable; use Throwable;
trait ManagesBalance trait ManagesBalance
{ {
use HasBillable; use HasBillable;
/** /**
* Get balance from the current user. * Get balance from the current user.
* *
* @throws Throwable * @throws Throwable
*/ */
public function balance(): float public function balance(): float
{ {
return $this->getUserData()->current_balance; return $this->getUserData()->current_balance;
} }
/** /**
* Get charges from the current user. * Get charges from the current user.
* *
* @throws Throwable * @throws Throwable
*/ */
public function charges(): float public function charges(): float
{ {
return $this->getUserData()->current_charges; return $this->getUserData()->current_charges;
} }
/** /**
* Billing overview of the current user: current_balance, current_charges, vat_rate, * Billing overview of the current user: current_balance, current_charges, vat_rate,
* has_billing_address, has_default_payment_method, open_orders and billing_limit. * has_billing_address, has_default_payment_method, open_orders and billing_limit.
* *
* billing_limit is the user's monthly billing limit {object: "billing_limit", user_id, * billing_limit is the user's monthly billing limit {object: "billing_limit", user_id,
* currency, basis, limit, used, remaining, remaining_net, vat_rate, reached, resets_at, * currency, basis, limit, used, remaining, remaining_net, vat_rate, reached, resets_at,
* version} (`limit`, `remaining` and `remaining_net` null without a limit; wrap it in * version} (`limit`, `remaining` and `remaining_net` null without a limit; wrap it in
* `new \Anikeen\Id\Resources\BillingLimit(…)` for its helpers), or null while the user has no * `new \Anikeen\Id\Resources\BillingLimit(…)` for its helpers), or null while the user has no
* limit and can't set one yet. Older Anikeen ID releases don't send the key. * limit and can't set one yet. Older Anikeen ID releases don't send the key.
* *
* @throws Throwable * @throws Throwable
*/ */
public function billingOverview(): object public function billingOverview(): object
{ {
return $this->anikeenId()->request('GET', 'v1/billing')->data; return $this->anikeenId()->request('GET', 'v1/billing')->data;
} }
/** /**
* Charge given amount (deposit) from one of the current user's payment methods. * Charge given amount (deposit) from one of the current user's payment methods.
* *
* @param float|string $amount Amount in euros (0.50 to 10,000, at most 2 decimals). * @param float|string $amount Amount in euros (0.50 to 10,000, at most 2 decimals).
* @param string $paymentMethodId Stripe payment method ID (pm_…). * @param string $paymentMethodId Stripe payment method ID (pm_…).
* @param array $options Ignored; Stripe options can no longer be passed through. * @param array $options Ignored; Stripe options can no longer be passed through.
* @throws Throwable * @throws Throwable
*/ */
public function charge(float|string $amount, string $paymentMethodId, array $options = []): Transaction public function charge(float|string $amount, string $paymentMethodId, array $options = []): Transaction
{ {
return (new Transaction(fn() => $this->anikeenId() return (new Transaction(fn() => $this->anikeenId()
->request('POST', 'v1/billing/charge', [ ->request('POST', 'v1/billing/charge', [
'amount' => $amount, 'amount' => $amount,
'payment_method_id' => $paymentMethodId, 'payment_method_id' => $paymentMethodId,
]))) ])))
->setBillable($this); ->setBillable($this);
} }
} }␍