Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant Pinterest API error handlers #1087

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

message-dimke
Copy link
Contributor

@message-dimke message-dimke commented Nov 18, 2024

Changes proposed in this Pull Request:

Removing the Action Scheduler (AS) action failure hook to disconnect the extension on the Pinterest API call failures from inside the AS actions.

Customers complain about this issue when saying that after a while of the successful connection, the extension gets disconnected.

This is a requested feature that did not work out. Users prefer to stay connected even if the application is not partially working.

Detailed test instructions:

  1. Download the extension and connect to your Pinterest account.
  2. Edit the code lines below by adding a filter to emulate the request failure

public static function create_feed( array $data, string $ad_account_id ): array {
return self::make_request(
"catalogs/feeds?ad_account_id={$ad_account_id}",
'POST',
$data
);
}

add exactly before the return statement:

add_filter(
	'pre_http_request',
	function ( $response, $parsed_args, $url ) use ( $ad_account_id ) {
		if ( "https://api.pinterest.com/v5/catalogs/feeds?ad_account_id={$ad_account_id}" === $url ) {
			return array(
				'headers'  => array(
					'content-type' => 'application/json',
				),
				'body'     => json_encode(
					array(
						'code'    => 2625,
						'message' => 'Sorry, you cannot perform this action as your account has been disapproved. Please see business hub for more details. https://www.pinterest.com/business/hub/',
					)
				),
				'response' => array(
					'code'    => 403,
					'message' => 'Forbidden',
				),
				'cookies'  => array(),
				'filename' => '',
			);
		}
	},
	10,
	3
);
  1. Go to WooCommerce - Status - Scheduler Actions - Pending
WooCommerce_status_‹_WordPress_Pinterest_—_WordPress
  1. Force run the pinterest-for-woocommerce-handle-feed-registration action.
  2. Observe that the extension stayed connected and did not reset back to the onboarding flow.

Changelog entry

Update - Do not disconnect on the Action Scheduler action failure.

… Having 403 as the reason of disconnection was causing Pinterest account to disconnect due to account status change and feed actions returning 403 http responses.
…tion handler. Action scheduler uses Pinterest APIs exceptions from which are handled by APIV5 class, no need in doubling the handling effort, making multiple disconnects per a single API failure.
@github-actions github-actions bot added the changelog: update Big changes to something that wasn't broken. label Nov 18, 2024
@message-dimke message-dimke self-assigned this Nov 18, 2024
@message-dimke message-dimke requested a review from a team November 21, 2024 07:17
@message-dimke message-dimke marked this pull request as ready for review November 21, 2024 07:17
Copy link
Contributor

@rawdreeg rawdreeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @message-dimke. The changes test well. The interest connection is not removed on failed pinterest-for-woocommerce-handle-feed-registration action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: update Big changes to something that wasn't broken.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants