Commit 5e05f73e authored by Michael Iseard's avatar Michael Iseard
Browse files

Update sync_payments method to add missing transactions

parent d4204e0c
......@@ -731,12 +731,28 @@ class MollieVendor implements VendorInterface {
$amount = $payment->amount;
$order_id = $payment->metadata->order_id ?? null;
$mapper->get_repository( TransactionEntity::class );
/** @var TransactionEntity $transaction */
$transaction = $mapper->get_one_by( [
'order_id' => $order_id,
'status' => 'open',
] );
if ( $transaction ) {
if($order_id) {
/**
* Find existing transaction.
* @var TransactionEntity $transaction
*/
$transaction = $mapper->get_one_by( [
'order_id' => $order_id,
] );
// Add new transaction if none found.
if ( ! $transaction ) {
$transaction = new TransactionEntity( [
'order_id' => $order_id,
] );
} else {
$transaction->set_fields([
'created' => $payment->createdAt
]);
}
$transaction->set_fields(
[
'status' => $payment->status,
......@@ -747,6 +763,7 @@ class MollieVendor implements VendorInterface {
'method' => $payment->method,
'mode' => $payment->mode,
'subscription_id' => $payment->subscriptionId,
'campaign_id' => $payment->metadata ? $payment->metadata->campaign_id : null,
]
);
$mapper->save( $transaction );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment