1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Fixes for duplicate mollie requests

This commit is contained in:
David Bomba 2024-09-26 13:19:01 +10:00
parent 5beaa80786
commit 1e5faf2ecd
3 changed files with 15 additions and 1 deletions

View File

@ -36,6 +36,7 @@ class InvoiceTransformer extends BaseTransformer
$invoiceStatusMap = [
'sent' => Invoice::STATUS_SENT,
'draft' => Invoice::STATUS_DRAFT,
'paid' => Invoice::STATUS_PAID,
];
$transformed = [

View File

@ -176,6 +176,19 @@ class IDEAL implements MethodInterface, LivewireMethodInterface
*/
public function processSuccessfulPayment(\Mollie\Api\Resources\Payment $payment, string $status = 'paid'): RedirectResponse
{
$p = \App\Models\Payment::query()
->withTrashed()
->where('company_id', $this->mollie->client->company_id)
->where('transaction_reference', $payment->id)
->first();
if($p) {
$p->status_id = Payment::STATUS_COMPLETED;
$p->save();
return redirect()->route('client.payments.show', ['payment' => $p->hashed_id]);
}
$data = [
'gateway_type_id' => GatewayType::IDEAL,
'amount' => array_sum(array_column($this->mollie->payment_hash->invoices(), 'amount')) + $this->mollie->payment_hash->fee_total,

View File

@ -287,7 +287,7 @@ class MolliePaymentDriver extends BaseDriver
{
// Allow app to catch up with webhook request.
// sleep(4);
usleep(rand(2800000, 4000000));
usleep(rand(1500000, 4000000));
$validator = Validator::make($request->all(), [
'id' => ['required', 'starts_with:tr'],