Skip to content

Commit 52371e6

Browse files
committed
Adding in the last of the nonce validation checks.
1 parent c472865 commit 52371e6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

assets/js/paystack-public.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,9 @@ function PffPaystackFee()
475475
var firstName = names[0] || "";
476476
var lastName = names[1] || "";
477477
var quantity = data.quantity;
478-
// console.log(firstName+ " - "+lastName);
478+
479+
$("#pf-nonce").val(data.retryNonce);
480+
479481
if (data.plan == "none" || data.plan == "" || data.plan == "no") {
480482
var handler = PaystackPop.setup(
481483
{
@@ -499,6 +501,7 @@ function PffPaystackFee()
499501
code: response.trxref,
500502
quantity: quantity,
501503
retry: true,
504+
nonce: data.confirmNonce
502505
},
503506
function (newdata) {
504507
data = JSON.parse(newdata);
@@ -546,6 +549,7 @@ function PffPaystackFee()
546549
action: "pff_paystack_confirm_payment",
547550
code: response.trxref,
548551
retry: true,
552+
nonce: data.confirmNonce
549553
},
550554
function (newdata) {
551555
data = JSON.parse(newdata);

includes/classes/class-retry-submit.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public function retry_action() {
9797
exit( wp_json_encode( $response ) );
9898
}
9999

100+
// False positive, we are using isset() to verify it exists before sanitization.
101+
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput
100102
if ( isset( $_POST['code'] ) && '' !== trim( wp_unslash( $_POST['code'] ) ) ) {
101103
$this->code = sanitize_text_field( wp_unslash( $_POST['code'] ) );
102104
} else {
@@ -158,6 +160,12 @@ public function retry_action() {
158160
'transaction_charge' => $transaction_charge,
159161
);
160162

163+
// We create 2 nonces here
164+
// 1 incase the payment fails, and the user needs to try again.
165+
// 2 if the payment is successful and the confirmation ajax needs to run.
166+
$response['retryNonce'] = wp_create_nonce( 'pff-paystack-retry' );
167+
$response['confirmNonce'] = wp_create_nonce( 'pff-paystack-confirm' );
168+
161169
echo wp_json_encode( $response );
162170

163171
die();

0 commit comments

Comments
 (0)