@@ -261,6 +261,38 @@ public function delete_data() {
261261 return $ status ;
262262 }
263263
264+ /**
265+ * Save merchant data to database.
266+ *
267+ * @since 5.1.9
268+ *
269+ * @return bool
270+ */
271+ public function save () {
272+ error_log ( 'Merchant Save: needs_save = ' . ( $ this ->needs_save () ? 'TRUE ' : 'FALSE ' ) );
273+
274+ if ( ! $ this ->needs_save () ) {
275+ error_log ( 'Merchant Save: No changes to save, returning true ' );
276+ return true ; // No changes to save
277+ }
278+
279+ $ data = $ this ->to_array ();
280+ $ account_key = $ this ->get_account_key ();
281+
282+ error_log ( 'Merchant Save: account_key = ' . $ account_key );
283+ error_log ( 'Merchant Save: data = ' . print_r ( $ data , true ) );
284+
285+ $ result = update_option ( $ account_key , $ data );
286+
287+ error_log ( 'Merchant Save: update_option result = ' . ( $ result ? 'SUCCESS ' : 'FAILED ' ) );
288+
289+ if ( $ result ) {
290+ $ this ->needs_save = false ; // Reset the flag after successful save
291+ }
292+
293+ return $ result ;
294+ }
295+
264296 /**
265297 * Disconnects the merchant completely.
266298 *
@@ -341,26 +373,19 @@ public function get_locale() {
341373 }
342374
343375 /**
344- * Save merchant data to WordPress options .
376+ * Gets the client secret for merchant .
345377 *
346- * @since 5.1.9
378+ * @since 5.24.0
347379 *
348- * @return bool Whether the save was successful.
380+ * @return ?string
349381 */
350- public function save () {
351- if ( ! $ this ->needs_save () ) {
352- return true ; // No changes to save
353- }
354-
355- $ data = $ this ->to_array ();
356- $ account_key = $ this ->get_account_key ();
357-
358- $ result = update_option ( $ account_key , $ data );
359-
360- if ( $ result ) {
361- $ this ->needs_save = false ; // Reset the flag after successful save
382+ public function get_client_secret (): ?string {
383+ if ( 'test ' === $ this ->paystack_mode ) {
384+ return $ this ->secret_key_test ?: null ;
385+ } elseif ( 'live ' === $ this ->paystack_mode ) {
386+ return $ this ->secret_key_live ?: null ;
362387 }
363388
364- return $ result ;
389+ return null ;
365390 }
366391}
0 commit comments