Skip to content

Commit 7d82c19

Browse files
authored
Merge pull request #201 from paynl/feature/ajax_nonce
Fix ajax call with nonce
2 parents 15f8257 + d7f8ea5 commit 7d82c19

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

assets/js/payorder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ function doAjaxRequest($, amount, type)
4343
'terminal': terminal,
4444
'order_id': paynl_order.order_id,
4545
'returnUrl': window.location.href,
46-
'type': type
46+
'type': type,
47+
'security': paynl_order.nonce
4748
};
4849

4950
$.ajax({

includes/classes/PPMFWC/Gateways.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,16 @@ public static function ppmfwc_retourpinReturn()
12071207
*/
12081208
public static function ppmfwc_onPinRefund()
12091209
{
1210+
$security = PPMFWC_Helper_Data::getPostTextField('security');
1211+
if ((empty($security) || !wp_verify_nonce($security, 'ajax_nonce')) || (!current_user_can('manage_woocommerce') && !current_user_can('manage_options'))) {
1212+
$returnArray = array(
1213+
'success' => false,
1214+
'message' => __('You do not have permission to perform this action.', PPMFWC_WOOCOMMERCE_TEXTDOMAIN),
1215+
);
1216+
header('Content-Type: application/json;charset=UTF-8');
1217+
die(json_encode($returnArray));
1218+
}
1219+
12101220
try {
12111221
$amount = PPMFWC_Helper_Data::getPostTextField('amount');
12121222
$terminal = PPMFWC_Helper_Data::getPostTextField('terminal');

woocommerce-payment-paynl.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ function ppmfwc_setup_instore_scripts(array $terminals, $texts, $additionalData)
457457
array(
458458
'texts' => $texts,
459459
'terminals' => $terminals,
460+
'nonce' => wp_create_nonce('ajax_nonce')
460461
),
461462
$additionalData
462463
);

0 commit comments

Comments
 (0)