mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-06 23:58:35 +00:00
Restore CRLF line endings in ManagesBalance
This commit is contained in:
1 file changed
+66
-66
@@ -1,66 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Concerns;
|
||||
|
||||
use Anikeen\Id\Resources\Transaction;
|
||||
use Throwable;
|
||||
|
||||
trait ManagesBalance
|
||||
{
|
||||
use HasBillable;
|
||||
|
||||
/**
|
||||
* Get balance from the current user.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function balance(): float
|
||||
{
|
||||
return $this->getUserData()->current_balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get charges from the current user.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function charges(): float
|
||||
{
|
||||
return $this->getUserData()->current_charges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Billing overview of the current user: current_balance, current_charges, vat_rate,
|
||||
* 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,
|
||||
* 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
|
||||
* `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.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function billingOverview(): object
|
||||
{
|
||||
return $this->anikeenId()->request('GET', 'v1/billing')->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 string $paymentMethodId Stripe payment method ID (pm_…).
|
||||
* @param array $options Ignored; Stripe options can no longer be passed through.
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function charge(float|string $amount, string $paymentMethodId, array $options = []): Transaction
|
||||
{
|
||||
return (new Transaction(fn() => $this->anikeenId()
|
||||
->request('POST', 'v1/billing/charge', [
|
||||
'amount' => $amount,
|
||||
'payment_method_id' => $paymentMethodId,
|
||||
])))
|
||||
->setBillable($this);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Concerns;
|
||||
|
||||
use Anikeen\Id\Resources\Transaction;
|
||||
use Throwable;
|
||||
|
||||
trait ManagesBalance
|
||||
{
|
||||
use HasBillable;
|
||||
|
||||
/**
|
||||
* Get balance from the current user.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function balance(): float
|
||||
{
|
||||
return $this->getUserData()->current_balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get charges from the current user.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function charges(): float
|
||||
{
|
||||
return $this->getUserData()->current_charges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Billing overview of the current user: current_balance, current_charges, vat_rate,
|
||||
* 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,
|
||||
* 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
|
||||
* `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.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function billingOverview(): object
|
||||
{
|
||||
return $this->anikeenId()->request('GET', 'v1/billing')->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 string $paymentMethodId Stripe payment method ID (pm_…).
|
||||
* @param array $options Ignored; Stripe options can no longer be passed through.
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function charge(float|string $amount, string $paymentMethodId, array $options = []): Transaction
|
||||
{
|
||||
return (new Transaction(fn() => $this->anikeenId()
|
||||
->request('POST', 'v1/billing/charge', [
|
||||
'amount' => $amount,
|
||||
'payment_method_id' => $paymentMethodId,
|
||||
])))
|
||||
->setBillable($this);
|
||||
}
|
||||
}␍
|
||||
Reference in new issue
Block a user