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 { ...@@ -731,12 +731,28 @@ class MollieVendor implements VendorInterface {
$amount = $payment->amount; $amount = $payment->amount;
$order_id = $payment->metadata->order_id ?? null; $order_id = $payment->metadata->order_id ?? null;
$mapper->get_repository( TransactionEntity::class ); $mapper->get_repository( TransactionEntity::class );
/** @var TransactionEntity $transaction */
$transaction = $mapper->get_one_by( [ if($order_id) {
'order_id' => $order_id,
'status' => 'open', /**
] ); * Find existing transaction.
if ( $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( $transaction->set_fields(
[ [
'status' => $payment->status, 'status' => $payment->status,
...@@ -747,6 +763,7 @@ class MollieVendor implements VendorInterface { ...@@ -747,6 +763,7 @@ class MollieVendor implements VendorInterface {
'method' => $payment->method, 'method' => $payment->method,
'mode' => $payment->mode, 'mode' => $payment->mode,
'subscription_id' => $payment->subscriptionId, 'subscription_id' => $payment->subscriptionId,
'campaign_id' => $payment->metadata ? $payment->metadata->campaign_id : null,
] ]
); );
$mapper->save( $transaction ); $mapper->save( $transaction );
......
Supports Markdown
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