Skip to content

Conversation

@iamdharmesh
Copy link
Collaborator

All Submissions:

  • Does your code follow the WooCommerce Sniffs variant of WordPress coding standards?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Will this change require new documentation or changes to existing documentation?

Changes proposed in this Pull Request:

This PR introduces changes to prevent the order from being marked as "On Hold" when the order amount is successfully charged but card tokenization fails on Square’s side. This situation occurs when a customer completes checkout with the "Save payment method" option selected.
Currently, the plugin marks the order as "On Hold" to draw the merchant’s attention to the card tokenization failure. This PR updates that behavior by skipping the order status update and instead only adding an order note to report the tokenization failure.

Note

For subscriptions, if card saving/tokenization fails, future renewal payments will fail because the card details are not stored. The customer will need to add or update the payment method for the subscription at that time.

Closes https://linear.app/a8c/issue/SQUARE-208/store-then-charge-cards

Steps to test the changes in this Pull Request:

This issue cannot be reproduced directly and must be simulated based on the steps provided below:

  1. Add a product to the cart.
  2. Manually apply the plugin changes as suggested.
  3. Place an order using a Square credit card and select the "Save payment method" option while entering card details.
  4. Verify that:
    • An order note is added for the failed card data save attempt.
    • The order remains in Processing status.

Changelog entry

Fix - Ensure that the order is not marked as 'On Hold' when saving the card fails after a successful payment.

@iamdharmesh iamdharmesh self-assigned this Dec 1, 2025
@iamdharmesh iamdharmesh requested a review from Copilot December 1, 2025 13:26
Copilot finished reviewing on behalf of iamdharmesh December 1, 2025 13:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses an edge case in the Square payment gateway where orders were incorrectly marked as "On Hold" when payment succeeded but subsequent card tokenization failed. The fix adds a condition to skip the on-hold status update for tokenize_after_sale() scenarios, instead only adding an informational order note about the tokenization failure.

Key changes:

  • Modified error handling in maybe_tokenize() to exclude tokenize_after_sale() cases from marking orders as on-hold
  • Added comprehensive documentation explaining the tokenization failure handling strategy
  • Ensures successfully paid orders maintain their correct processing status even when card saving fails

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@iamdharmesh iamdharmesh requested a review from dkotter December 1, 2025 13:33
@iamdharmesh
Copy link
Collaborator Author

Note: E2E failure is known and already handled in other PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants