Adjustments for mollie fee removal on pending payments
This commit is contained in:
parent
e50a3e692d
commit
493d3e0d19
|
|
@ -429,10 +429,6 @@ class BaseDriver extends AbstractPaymentDriver
|
|||
return;
|
||||
}
|
||||
|
||||
// $confirmed_fee_count = collect($invoice->line_items)
|
||||
// ->where('type_id', '4')
|
||||
// ->count();
|
||||
|
||||
$unconfirmed_fee_count = collect($invoice->line_items)
|
||||
->where('type_id', '3')
|
||||
->count();
|
||||
|
|
|
|||
|
|
@ -357,7 +357,14 @@ class MolliePaymentDriver extends BaseDriver
|
|||
|
||||
if ($record) {
|
||||
if (in_array($payment->status, ['canceled', 'expired', 'failed'])) {
|
||||
$record->service()->deletePayment(false); //sometimes mollie does not return but we still decrement the paid to date, this is incorrect.
|
||||
|
||||
if(property_exists($payment->metadata, 'hash') && $payment->metadata->hash){
|
||||
$payment_hash = PaymentHash::where('hash', $payment->metadata->hash)->first();
|
||||
$this->handlePendingGatewayFeeRemoval($payment_hash);
|
||||
}
|
||||
|
||||
$record->service()->deletePayment(false);
|
||||
|
||||
}
|
||||
|
||||
$record->status_id = $codes[$payment->status];
|
||||
|
|
@ -380,6 +387,28 @@ class MolliePaymentDriver extends BaseDriver
|
|||
}
|
||||
}
|
||||
|
||||
private function handlePendingGatewayFeeRemoval(PaymentHash $payment_hash)
|
||||
{
|
||||
$invoice = $payment_hash->fee_invoice;
|
||||
|
||||
if($invoice){
|
||||
$line_items = $invoice->line_items;
|
||||
|
||||
$line_items = collect($line_items)->filter(function($line_item, $key) use ($line_items) {
|
||||
$last_type_4_key = collect($line_items)->filter(function($item) {
|
||||
return $item->type_id == '4';
|
||||
})->keys()->last();
|
||||
|
||||
return $key != $last_type_4_key;
|
||||
})->toArray();
|
||||
|
||||
$invoice->line_items = array_values($line_items);
|
||||
|
||||
$invoice = $invoice->calc()->getInvoice();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function process3dsConfirmation(Mollie3dsRequest $request)
|
||||
{
|
||||
$this->init();
|
||||
|
|
|
|||
|
|
@ -141,9 +141,9 @@ class DeletePayment
|
|||
->updateBalanceAndPaidToDate($net_deletable, ($net_deletable * -1) > 0 ? 0 : ($net_deletable * -1)) // if negative, set to 0, the paid to date will be reduced further down.
|
||||
->save();
|
||||
|
||||
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
|
||||
if (abs(floatval($paymentable_invoice->balance) - floatval($paymentable_invoice->amount)) < 0.005) {
|
||||
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
|
||||
} elseif ($paymentable_invoice->balance == 0) {
|
||||
} elseif (floatval($paymentable_invoice->balance) == 0) {
|
||||
$paymentable_invoice->service()->setStatus(Invoice::STATUS_PAID)->save();
|
||||
} else {
|
||||
$paymentable_invoice->service()->setStatus(Invoice::STATUS_PARTIAL)->save();
|
||||
|
|
|
|||
Loading…
Reference in New Issue