Enforce max payment amount

This commit is contained in:
Hillel Coren 2018-06-17 09:54:05 +03:00
parent 1b5d8f850b
commit 9d6b8aed15
2 changed files with 2 additions and 1 deletions

View File

@ -45,7 +45,7 @@ class CreatePaymentAPIRequest extends PaymentRequest
]);
$rules = [
'amount' => 'required|numeric|not_in:0',
'amount' => 'required|numeric',
];
if ($this->payment_type_id == PAYMENT_TYPE_CREDIT) {

View File

@ -194,6 +194,7 @@ class PaymentRepository extends BaseRepository
if (! $publicId) {
$clientId = $input['client_id'];
$amount = Utils::parseFloat($input['amount']);
$amount = min($amount, MAX_INVOICE_AMOUNT);
if ($paymentTypeId == PAYMENT_TYPE_CREDIT) {
$credits = Credit::scope()->where('client_id', '=', $clientId)