Title: Non user friendly error message
Last modified: September 25, 2026

---

# Non user friendly error message

 *  Resolved [user9876789](https://wordpress.org/support/users/user9876789/)
 * (@user9876789)
 * [2 weeks, 3 days ago](https://wordpress.org/support/topic/non-user-friendly-error-message/)
 * When in test mode on Woopayments and going into My Account > Add Payment method
   and adding the info of card number ‘0000 0000 0000 0000’, any valid expiry, any
   security code, and any country – you get the error “Cannot destructure property‘
   id’ of ‘undefined’ as it is undefined.”
 * Can this be made more user friendly?
 * From researching the error comes from in `plugins/woocommerce-payments/dist/checkout.
   js`, submitting the add-payment-method form does this (de-minified):
 *     ```wp-block-code
       const result = await stripe.createPaymentMethod({ elements, params });
   
       if (result.error) {
           // Save Stripe's error details as hidden inputs on the form
           appendErrorInputs(form, result.error);
       } else {
           appendPaymentMethodInput(form, result.paymentMethod.id);
       }
   
       // ...but then carries on regardless of the error
       await afterCreate(result.paymentMethod, form, api);   // paymentMethod is undefined
       ```
   
 * On the add-payment-method page, `afterCreate` is this function:
 *     ```wp-block-code
       const wt = ({ id }, form, api) => api.setupIntent(id, ...)
       ```
   
 * When Stripe rejects the card, `result.paymentMethod` is `undefined`. Destructuring`{
   id }` from it throws a `TypeError`. The `catch` block then shows that raw JavaScript
   message (`e.message`) to the user.
 * At checkout, the same code works because the step after the error does nothing.
   The form submits, and the server turns the hidden error fields into a proper 
   message. The add-payment-method page runs the setup intent step in the browser,
   so it crashes first. Stripe’s real, friendly message is sitting in a hidden `#
   wcpay-payment-method-error-message` input that nothing reads.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [shahzeen(woo-hc)](https://wordpress.org/support/users/shahzeenfarooq/)
 * (@shahzeenfarooq)
 * [2 weeks, 2 days ago](https://wordpress.org/support/topic/non-user-friendly-error-message/#post-19029940)
 * Hi [@user9876789](https://wordpress.org/support/users/user9876789/)!
 * Thank you for the detailed report and for tracing the behavior through the WooPayments
   code.
 * I’ve reproduced the issue using the test card `0000 0000 0000 0000` and reported
   it to the team that maintains WooPayments. We’ve specifically raised the issue
   with the **My Account → Add Payment Method** flow so that, when Stripe returns
   a payment-method error, the page can surface the appropriate user-friendly error
   message instead of exposing the raw JavaScript error.
 * Your investigation into the `result.paymentMethod` being undefined and the subsequent
   destructuring error was particularly helpful in isolating why this behaves differently
   from the checkout flow.
 * Thank you for taking the time to dig into the source and provide those details.
   This should help the team investigate the issue more efficiently.
   ::
 *  Thread Starter [user9876789](https://wordpress.org/support/users/user9876789/)
 * (@user9876789)
 * [2 weeks, 1 day ago](https://wordpress.org/support/topic/non-user-friendly-error-message/#post-19030517)
 * Thank you
 *  [shahzeen(woo-hc)](https://wordpress.org/support/users/shahzeenfarooq/)
 * (@shahzeenfarooq)
 * [2 weeks ago](https://wordpress.org/support/topic/non-user-friendly-error-message/#post-19030827)
 * Hi [@user9876789](https://wordpress.org/support/users/user9876789/)!
 * You’re very welcome! If you face any issues in the future, we’re always here 
   to help.
 * Please feel free to create a new ticket whenever you need assistance.
 * Thank you, and have a great day!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fnon-user-friendly-error-message%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/woocommerce-payments/assets/icon-256x256.png?rev=3234740)
 * [WooPayments: Integrated WooCommerce Payments](https://wordpress.org/plugins/woocommerce-payments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-payments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-payments/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-payments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-payments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-payments/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [shahzeen(woo-hc)](https://wordpress.org/support/users/shahzeenfarooq/)
 * Last activity: [2 weeks ago](https://wordpress.org/support/topic/non-user-friendly-error-message/#post-19030827)
 * Status: resolved