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

Use idempotency keys for mollie payments to prevent race conditions

This commit is contained in:
David Bomba 2024-11-02 08:34:27 +11:00
parent d747be4c06
commit 5a53a65e39
3 changed files with 5 additions and 0 deletions

View File

@ -329,6 +329,9 @@ class BaseDriver extends AbstractPaymentDriver
$client_contact = $this->getContact();
$client_contact_id = $client_contact ? $client_contact->id : $this->client->contacts()->first()->id;
if(isset($data['idempotency_key']))
$payment->idempotency_key = $data['idempotency_key'];
$payment->amount = $data['amount'];
$payment->type_id = $data['payment_type'];
$payment->transaction_reference = $data['transaction_reference'];

View File

@ -194,6 +194,7 @@ class IDEAL implements MethodInterface, LivewireMethodInterface
'amount' => array_sum(array_column($this->mollie->payment_hash->invoices(), 'amount')) + $this->mollie->payment_hash->fee_total,
'payment_type' => PaymentType::IDEAL,
'transaction_reference' => $payment->id,
'idempotency_key' => substr("{$payment->id}{$this->mollie->payment_hash}",0,64)
];
$payment_record = $this->mollie->createPayment(

View File

@ -336,6 +336,7 @@ class MolliePaymentDriver extends BaseDriver
'amount' => $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total,
'payment_type' => $payment->metadata->payment_type_id,
'transaction_reference' => $payment->id,
'idempotency_key' => substr("{$payment->id}{$payment_hash->hash}",0,64)
];
$this->confirmGatewayFee($data);