@@ -101,7 +101,6 @@ protected function valid_submission() {
101101 return false ;
102102 }
103103
104-
105104 if ( ! isset ( $ _POST ['pf-id ' ] ) || '' == trim ( sanitize_text_field ( wp_unslash ( $ _POST ['pf-id ' ] ) ) ) ) {
106105 $ this ->response ['result ' ] = 'failed ' ;
107106 $ this ->response ['message ' ] = __ ( 'A form ID is required ' , 'pff-paystack ' );
@@ -249,9 +248,6 @@ public function process_images() {
249248 }
250249
251250 public function submit_action () {
252- /**
253- * TODO - Needs better security checks - NONCE
254- */
255251 if ( ! $ this ->valid_submission () ) {
256252 // Exit here, for not processing further because of the error
257253 exit ( wp_json_encode ( $ this ->response ) );
@@ -299,14 +295,10 @@ public function submit_action() {
299295 * This function will exit early if one of the images is too large to be uploaded.
300296 */
301297 $ this ->process_images ();
302-
303298 $ this ->process_recurring_plans ( $ amount );
304-
305299 $ this ->fixed_metadata = json_decode ( wp_json_encode ( $ this ->fixed_metadata , JSON_NUMERIC_CHECK ), true );
306300 $ this ->fixed_metadata = array_merge ( $ this ->untouched , $ this ->fixed_metadata );
307301
308-
309-
310302 $ insert = array (
311303 'post_id ' => $ this ->form_data ['pf-id ' ],
312304 'email ' => $ this ->form_data ['pf-pemail ' ],
@@ -400,10 +392,11 @@ public function submit_action() {
400392 'transaction_charge ' => $ transaction_charge ,
401393 );
402394
403- //-------------------------------------------------------------------------------------------
404-
405- // $pstk_logger = new paystack_plugin_tracker('pff-paystack', Kkd_Pff_Paystack_Public::fetchPublicKey());
406- // $pstk_logger->log_transaction_attempt($code);*/
395+ // We create 2 nonces here
396+ // 1 incase the payment fails, and the user needs to try again.
397+ // 2 if the payment is successful and the confirmation ajax needs to run.
398+ $ response ['invoiceNonce ' ] = wp_create_nonce ( 'pff-paystack-invoice ' );
399+ $ response ['confirmNonce ' ] = wp_create_nonce ( 'pff-paystack-confirm ' );
407400
408401 echo wp_json_encode ( $ response );
409402 die ();
0 commit comments