HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/shoetique/wp-content/plugins/facebook-for-woocommerce/assets/js/admin/whatsapp-finish.js
/**
 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
 *
 * This source code is licensed under the license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @package FacebookCommerce
 */

jQuery( document ).ready( function( $ ) {
    // handle the whatsapp finish button click
	$( '#wc-whatsapp-onboarding-finish' ).click( function( event ) {
        // call the connect API to create configs and check payment
        $.post( facebook_for_woocommerce_whatsapp_finish.ajax_url, {
			action: 'wc_facebook_whatsapp_finish_onboarding',
			nonce:  facebook_for_woocommerce_whatsapp_finish.nonce
		}, function ( response ) {
            if ( response.success ) {
                // If success, redirect to utility settings page
                 let url = new URL(window.location.href);
                 let params = new URLSearchParams(url.search);
                 params.set('view', 'utility_settings');
                 url.search = params.toString();
                 window.location.href = url.toString();
                 console.log( 'Whatsapp Connect Success', response );
			} else {
                var message;
                const error = response.data;
                console.log( 'Whatsapp Connect Failure', response );

                switch (error) {
                    case "Incorrect payment setup":
                        message = facebook_for_woocommerce_whatsapp_finish.i18n.payment_setup_error;
                        break;
                    case "Onboarding is not complete or has failed.":
                        message = facebook_for_woocommerce_whatsapp_finish.i18n.onboarding_incomplete_error;
                        break;
                    default:
                        message = facebook_for_woocommerce_whatsapp_finish.i18n.generic_error;
                }


                const errorNoticeHtml = `
                      <div class="notice-error">
                        <p>${message}</p>
                      </div>
                    `;
                $( '#payment-method-error-notice' ).html( errorNoticeHtml ).show();
            }
		} );
    });

} );