Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
Snickser committed May 15, 2024
1 parent 0b61288 commit 7bdb307
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
$operationid = required_param('MNT_OPERATION_ID', PARAM_TEXT);
$subscriberid = required_param('MNT_SUBSCRIBER_ID', PARAM_TEXT);
$signature = required_param('MNT_SIGNATURE', PARAM_TEXT);
$amount = required_param('MNT_AMOUNT', PARAM_FLOAT);
$currency = required_param('MNT_CURRENCY_CODE', PARAM_TEXT);

if (!$payanywaytx = $DB->get_record('paygw_payanyway', ['paymentid' => $transactionid])) {
die('FAIL. Not a valid transaction id');
Expand All @@ -53,16 +55,21 @@
$config = (object) helper::get_gateway_configuration($component, $paymentarea, $itemid, 'payanyway');

// Use the same rounding of floats as on the paygw form.
$cost = number_format($payment->amount, 2, '.', '');
$cost = number_format($amount, 2, '.', '');

// Build crc.
$crc = md5($config->mntid . $paymentid . $operationid . $cost . $payment->currency . $subscriberid .
$config->mnttestmode . $config->mntdataintegritycode);

// Check signature.
if ($crc !== $signature) {
die('FAIL. Signature does not match.');
}

// Update payment.
$payment->amount = $amount;
$DB->update_record('payments', $payment);

// Deliver.
helper::deliver_order($component, $paymentarea, $itemid, $paymentid, $userid);

Expand Down
2 changes: 1 addition & 1 deletion pay.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
$paymentarea,
$itemid,
$userid,
$cost,
0,
$payable->get_currency(),
'payanyway'
);
Expand Down

0 comments on commit 7bdb307

Please sign in to comment.