Skip to content

Commit

Permalink
Bugfix: Make sure every new tid is stored in the open orders table
Browse files Browse the repository at this point in the history
  • Loading branch information
georgmaisser committed Feb 18, 2025
1 parent a22bf63 commit ff3d7ad
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion classes/external/get_config_for_js.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function execute(string $component, string $paymentarea, int $item
$record->timemodified = time();

// Check for duplicate.
if (!$existingrecord = $DB->get_record('paygw_mpay24_openorders', ['itemid' => $itemid, 'userid' => $USER->id])) {
if (!$existingrecord = $DB->get_record('paygw_mpay24_openorders', ['itemid' => $itemid, 'userid' => $USER->id, 'tid' => $record->tid])) {
$id = $DB->insert_record('paygw_mpay24_openorders', $record);

// We trigger the payment_added event.
Expand All @@ -127,6 +127,20 @@ public static function execute(string $component, string $paymentarea, int $item
} else {
// If we already have an entry with the exact same itemid and userid, we actually will use the same merchant id.
// This will prevent a successful payment and we thus avoid duplicate entries in DB.

// There is one case where price could have changed (because of changes in credit application eg.
if ($amount != $existingrecord->price) {
// We need to update the open Orders table accordingly.
$DB->update_record(
'paygw_qenta_openorders',
[
'id' => $existingrecord->id,
'price' => $amount,
'timemodified' => time(),
]
);
}

$merchanttransactionid = $existingrecord->tid;
}

Expand Down

0 comments on commit ff3d7ad

Please sign in to comment.