Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/PaymentsController.php
Show First 20 Lines • Show All 370 Lines • ▼ Show 20 Lines | public static function walletMandate(Wallet $wallet): array | ||||
$settings = $wallet->getSettings(['mandate_disabled', 'mandate_balance', 'mandate_amount']); | $settings = $wallet->getSettings(['mandate_disabled', 'mandate_balance', 'mandate_amount']); | ||||
// Get the Mandate info | // Get the Mandate info | ||||
$mandate = (array) $provider->getMandate($wallet); | $mandate = (array) $provider->getMandate($wallet); | ||||
$mandate['amount'] = $mandate['minAmount'] = (int) ceil(Payment::MIN_AMOUNT / 100); | $mandate['amount'] = $mandate['minAmount'] = (int) ceil(Payment::MIN_AMOUNT / 100); | ||||
$mandate['balance'] = 0; | $mandate['balance'] = 0; | ||||
$mandate['isDisabled'] = !empty($mandate['id']) && $settings['mandate_disabled']; | $mandate['isDisabled'] = !empty($mandate['id']) && $settings['mandate_disabled']; | ||||
$mandate['isValid'] = !empty($mandate['isValid']); | |||||
foreach (['amount', 'balance'] as $key) { | foreach (['amount', 'balance'] as $key) { | ||||
if (($value = $settings["mandate_{$key}"]) !== null) { | if (($value = $settings["mandate_{$key}"]) !== null) { | ||||
$mandate[$key] = $value; | $mandate[$key] = $value; | ||||
} | } | ||||
} | } | ||||
// If this is a multi-month plan, we calculate the expected amount to be payed. | // If this is a multi-month plan, we calculate the expected amount to be payed. | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | class PaymentsController extends Controller | ||||
{ | { | ||||
$request['vat_rate_id'] = null; | $request['vat_rate_id'] = null; | ||||
$request['credit_amount'] = $request['amount']; | $request['credit_amount'] = $request['amount']; | ||||
if ($rate = $wallet->vatRate()) { | if ($rate = $wallet->vatRate()) { | ||||
$request['vat_rate_id'] = $rate->id; | $request['vat_rate_id'] = $rate->id; | ||||
switch (\config('app.vat.mode')) { | switch (\config('app.vat.mode')) { | ||||
case 1: | case 1: | ||||
// In this mode tax is added on top of the payment. The amount | // In this mode tax is added on top of the payment. The amount | ||||
// to pay grows, but we keep wallet balance without tax. | // to pay grows, but we keep wallet balance without tax. | ||||
$request['amount'] = $request['amount'] + round($request['amount'] * $rate->rate / 100); | $request['amount'] = $request['amount'] + round($request['amount'] * $rate->rate / 100); | ||||
break; | break; | ||||
default: | default: | ||||
// In this mode tax is "swallowed" by the vendor. The payment | // In this mode tax is "swallowed" by the vendor. The payment | ||||
// amount does not change | // amount does not change | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |