Fix ajax URLs on multisite

This commit is contained in:
Alex P 2022-03-09 16:24:11 +02:00
parent 3afb73d34c
commit 1a9fbc1303
5 changed files with 10 additions and 10 deletions

View file

@ -50,7 +50,7 @@ class ApplicationContextRepository {
$landingpage = $this->settings->has( 'landing_page' ) ? $landingpage = $this->settings->has( 'landing_page' ) ?
$this->settings->get( 'landing_page' ) : ApplicationContext::LANDING_PAGE_NO_PREFERENCE; $this->settings->get( 'landing_page' ) : ApplicationContext::LANDING_PAGE_NO_PREFERENCE;
$context = new ApplicationContext( $context = new ApplicationContext(
(string) home_url( \WC_AJAX::get_endpoint( ReturnUrlEndpoint::ENDPOINT ) ), \WC_AJAX::get_endpoint( ReturnUrlEndpoint::ENDPOINT ),
(string) wc_get_checkout_url(), (string) wc_get_checkout_url(),
(string) $brand_name, (string) $brand_name,
$locale, $locale,

View file

@ -664,7 +664,7 @@ class SmartButton implements SmartButtonInterface {
'script_attributes' => $this->attributes(), 'script_attributes' => $this->attributes(),
'data_client_id' => array( 'data_client_id' => array(
'set_attribute' => ( is_checkout() && $this->dcc_is_enabled() ) || $this->can_save_vault_token(), 'set_attribute' => ( is_checkout() && $this->dcc_is_enabled() ) || $this->can_save_vault_token(),
'endpoint' => home_url( \WC_AJAX::get_endpoint( DataClientIdEndpoint::ENDPOINT ) ), 'endpoint' => \WC_AJAX::get_endpoint( DataClientIdEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( DataClientIdEndpoint::nonce() ), 'nonce' => wp_create_nonce( DataClientIdEndpoint::nonce() ),
'user' => get_current_user_id(), 'user' => get_current_user_id(),
'has_subscriptions' => $this->has_subscriptions(), 'has_subscriptions' => $this->has_subscriptions(),
@ -673,15 +673,15 @@ class SmartButton implements SmartButtonInterface {
'context' => $this->context(), 'context' => $this->context(),
'ajax' => array( 'ajax' => array(
'change_cart' => array( 'change_cart' => array(
'endpoint' => home_url( \WC_AJAX::get_endpoint( ChangeCartEndpoint::ENDPOINT ) ), 'endpoint' => \WC_AJAX::get_endpoint( ChangeCartEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( ChangeCartEndpoint::nonce() ), 'nonce' => wp_create_nonce( ChangeCartEndpoint::nonce() ),
), ),
'create_order' => array( 'create_order' => array(
'endpoint' => home_url( \WC_AJAX::get_endpoint( CreateOrderEndpoint::ENDPOINT ) ), 'endpoint' => \WC_AJAX::get_endpoint( CreateOrderEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( CreateOrderEndpoint::nonce() ), 'nonce' => wp_create_nonce( CreateOrderEndpoint::nonce() ),
), ),
'approve_order' => array( 'approve_order' => array(
'endpoint' => home_url( \WC_AJAX::get_endpoint( ApproveOrderEndpoint::ENDPOINT ) ), 'endpoint' => \WC_AJAX::get_endpoint( ApproveOrderEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( ApproveOrderEndpoint::nonce() ), 'nonce' => wp_create_nonce( ApproveOrderEndpoint::nonce() ),
), ),
), ),

View file

@ -135,7 +135,7 @@ class OnboardingAssets {
*/ */
public function get_script_data() { public function get_script_data() {
return array( return array(
'endpoint' => home_url( \WC_AJAX::get_endpoint( LoginSellerEndpoint::ENDPOINT ) ), 'endpoint' => \WC_AJAX::get_endpoint( LoginSellerEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( $this->login_seller_endpoint::nonce() ), 'nonce' => wp_create_nonce( $this->login_seller_endpoint::nonce() ),
'paypal_js_url' => 'https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js', 'paypal_js_url' => 'https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js',
'sandbox_state' => State::get_state_name( $this->state->sandbox_state() ), 'sandbox_state' => State::get_state_name( $this->state->sandbox_state() ),

View file

@ -68,7 +68,7 @@ class MyAccountPaymentsAssets {
'PayPalCommerceGatewayVaulting', 'PayPalCommerceGatewayVaulting',
array( array(
'delete' => array( 'delete' => array(
'endpoint' => home_url( \WC_AJAX::get_endpoint( DeletePaymentTokenEndpoint::ENDPOINT ) ), 'endpoint' => \WC_AJAX::get_endpoint( DeletePaymentTokenEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( DeletePaymentTokenEndpoint::nonce() ), 'nonce' => wp_create_nonce( DeletePaymentTokenEndpoint::nonce() ),
), ),
) )

View file

@ -83,20 +83,20 @@ class WebhooksStatusPageAssets {
public function get_script_data() { public function get_script_data() {
return array( return array(
'resubscribe' => array( 'resubscribe' => array(
'endpoint' => home_url( \WC_AJAX::get_endpoint( ResubscribeEndpoint::ENDPOINT ) ), 'endpoint' => \WC_AJAX::get_endpoint( ResubscribeEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( ResubscribeEndpoint::nonce() ), 'nonce' => wp_create_nonce( ResubscribeEndpoint::nonce() ),
'button' => '.ppcp-webhooks-resubscribe', 'button' => '.ppcp-webhooks-resubscribe',
'failureMessage' => __( 'Operation failed. Check WooCommerce logs for more details.', 'woocommerce-paypal-payments' ), 'failureMessage' => __( 'Operation failed. Check WooCommerce logs for more details.', 'woocommerce-paypal-payments' ),
), ),
'simulation' => array( 'simulation' => array(
'start' => array( 'start' => array(
'endpoint' => home_url( \WC_AJAX::get_endpoint( SimulateEndpoint::ENDPOINT ) ), 'endpoint' => \WC_AJAX::get_endpoint( SimulateEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( SimulateEndpoint::nonce() ), 'nonce' => wp_create_nonce( SimulateEndpoint::nonce() ),
'button' => '.ppcp-webhooks-simulate', 'button' => '.ppcp-webhooks-simulate',
'failureMessage' => __( 'Operation failed. Check WooCommerce logs for more details.', 'woocommerce-paypal-payments' ), 'failureMessage' => __( 'Operation failed. Check WooCommerce logs for more details.', 'woocommerce-paypal-payments' ),
), ),
'state' => array( 'state' => array(
'endpoint' => home_url( \WC_AJAX::get_endpoint( SimulationStateEndpoint::ENDPOINT ) ), 'endpoint' => \WC_AJAX::get_endpoint( SimulationStateEndpoint::ENDPOINT ),
'successState' => WebhookSimulation::STATE_RECEIVED, 'successState' => WebhookSimulation::STATE_RECEIVED,
'waitingMessage' => __( 'Waiting for the webhook to arrive...', 'woocommerce-paypal-payments' ), 'waitingMessage' => __( 'Waiting for the webhook to arrive...', 'woocommerce-paypal-payments' ),
'successMessage' => __( 'The webhook was received successfully.', 'woocommerce-paypal-payments' ), 'successMessage' => __( 'The webhook was received successfully.', 'woocommerce-paypal-payments' ),