File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff 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 ();
You can’t perform that action at this time.
0 commit comments