Skip to content

Common errors

Niklas Gutberlet edited this page Dec 18, 2023 · 13 revisions

These errors have been reported over time and may have occurred for different users for various reasons. The error message may be the same for two different users, but the cause of it can be quite different. The cause often cannot be determined by the error alone.

Please get in touch with the support team when it is not clear how the error you experience could be resolved.

Something went wrong. Please try again or choose another payment source.

This generic error can be caused by various factors, including but not limited to:

  • negative PayPal API responses (e.g. currency not supported or invalid characters)
  • potential plugin/theme conflicts
  • REST endpoint blocked
  • other web server configuration

These kinds of errors may be caused by a compatibility issue with a third-party plugin, an invalid plugin configuration, or temporary service disruptions at PayPal.

Usually, following advanced troubleshooting steps helps to isolate the cause of the problem.

Could not retrieve order.

The error message Could not retrieve order may manifest due to various reasons. However, a common cause is a malfunction of the smart button replacement on the Checkout page, which can inadvertently lead the buyer to use the traditional "Place order" button. This issue arises because PayPal Payments is designed to process orders through the PayPal smart buttons, creating a failed order scenario if the regular "Place order" button is used instead.

When the PayPal buttons are enabled on a specific page, such as the Checkout page, the plugin loads the button.js file. This script is responsible for a range of tasks, including concealing the standard "Place order" button, displaying a loading spinner, and initiating the PayPal button script.

Occasionally, the button.js might not be correctly enqueued due to various factors, such as caching or minification conflicts. The button.js should not be cached, minified, or delivered via CDN to avoid such problems. Similarly, issues like passing invalid data to PayPal (like an unsupported currency) can prevent the proper loading of the PayPal buttons. If the "Place order" button is present on the PayPal gateway and a buyer clicks it, it triggers the Could not retrieve order error. Technically, the "Place order" button isn't designed to work under such conditions.

To troubleshoot and rectify this issue, follow these steps:

  • From the Network tab in the browser console, verify the button.js script is loaded
  • The button.js script should result in the PayPal script js?client-id= loading:
  • When the PayPal button script loads, verify if the PayPal smart buttons are visible on your Checkout page.
  • If they are, test if the error occurs when clicking the PayPal button or completing a PayPal payment.
  • If the regular "Place order" button appears instead of the PayPal button, there might be an error on your site causing this issue.

Potential causes to investigate include:

  • JavaScript console errors present on the Checkout page.
  • Conflicts with other plugins or themes, particularly those involving caching, minification, or security plugins.
  • Utilization of an unsupported browser, such as outdated mobile Safari versions or IE11.
  • Disabled JavaScript in the browser (as PayPal requires JavaScript for operation).
  • For sporadic error occurrences, suggest to buyers the use of modern browsers like Chrome or Firefox.

Things to try if the above information did not help:

  • remove/add any entry to the Hide Funding Source(s) setting in the Standard Payments tab and save the settings, visit Checkout again
  • change any button style setting (e.g. Layout or Color)

By following these steps, you should generally be able to figure out the cause of the error and deploy an appropriate solution.

Should you still face difficulties in diagnosing the issue, please contact our support team for further assistance.

The payee does not have a PayPal account.

This error can occur either when the API credentials are invalid, or the merchant’s PayPal account is not verified.

In some cases, disconnecting and reconnecting the account using the onboarding wizard may be sufficient to resolve the error. Other times, the merchant may need to reach out to the PayPal Merchant Support to clarify the account verification status before payments can be received.

DUPLICATE_INVOICE_ID

The error DUPLICATE_INVOICE_ID error is a security feature from PayPal to prevent accidental double payments.

PayPal Payments automatically sets an "invoice prefix" and then sends the WooCommerce order numbers in the pattern "invoice prefix + ordernumber" to PayPal. When the prefix is set to cfbdg- and the order number is 123, PayPal Payments sends the invoice ID cfbdg-123 to PayPal.

Under certain circumstances, PayPal Payments may send an invoice ID that already exists at PayPal and the transaction would fail. This can happen, for example, when an older backup from the website is restored, as the most recent WooCommerce orders may not exist anymore after the restore. As soon as WooCommerce attempts to create a new order with the number 123 and the same invoice prefix, PayPal would throw this error to prevent accidental double payments because there is already a payment at PayPal with the same invoice ID.

This feature can be disabled at PayPal, though the recommendation is to keep it enabled. Please ensure that every site using PayPal Payments with your account has a unique invoice prefix.

But to disable this feature at PayPal, follow these steps:

  1. Log in to your Business PayPal account (https://www.paypal.com/businessmanage/preferences/payments)
  2. Go to the Payments Preferences section
  3. Under the "Block accidental payments:" section, select the option "No, allow multiple payments per invoice ID"

With this feature disabled, PayPal no longer throws an error when an invoice number that already exists in the system is submitted.

Custom field not validated when clicking the PayPal button

Imagine you have a custom code on your page, which verifies if certain conditions are met in the ordered items when clicking “Place order”. The hook woocommerce_checkout_process is frequently used for this. If the conditions are not met, it does not allow the order to be placed and displays an error message. Here is an example code snippet to add a checkbox to the checkout page, validate it, and add it to the order meta. The validation step is where the problem occurs:

/**
 * Add checkbox field to the checkout
 **/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
 
function my_custom_checkout_field( $checkout ) {
 
    echo '<div id="my-new-field"><h3>'.__('My Checkbox: ').'</h3>';
 
    woocommerce_form_field( 'my_checkbox', array(
        'type'          => 'checkbox',
        'class'         => array('input-checkbox'),
        'label'         => __('I have read and agreed.'),
        'required'  => true,
        ), $checkout->get_value( 'my_checkbox' ));
 
    echo '</div>';
}
 
/**
 * Process the checkout
 **/
add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
 
function my_custom_checkout_field_process() {
    global $woocommerce;
 
    // Check if set, if its not set add an error.
    if (!$_POST['my_checkbox'])
         $woocommerce->add_error( __('Please agree to my checkbox.') );
}
 
/**
 * Update the order meta with field value
 **/
add_action('woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta');
 
function my_custom_checkout_field_update_order_meta( $order_id ) {
    if ($_POST['my_checkbox']) update_post_meta( $order_id, 'My Checkbox', esc_attr($_POST['my_checkbox']));
}

Q: What happens? This code works with most payment methods, but the PayPal popup window opens despite the box not being checked.

A: The hook woocommerce_checkout_process is called only after creating the PayPal order (when closing the popup), so it would not be considered when clicking the PayPal button.

To solve this problem, you can use the hook woocommerce_after_checkout_validation because validate_checkout is called before opening the popup window.

Clone this wiki locally