godaddy-wordpress / wc-plugin-framework

The official SkyVerge WooCommerce plugin framework
Other
137 stars 42 forks source link

Disable order saving when we're on the payment method page #685

Closed agibson-godaddy closed 3 months ago

agibson-godaddy commented 3 months ago

Summary

This prevents us from saving the order object when we're on the "add payment method" page. We do this by ensuring we don't call any save methods if the order doesn't already have an ID number. When on the payment method page, we expect to be working with a WC_Order object that has a 0 ID which is why this works.

Issue: MWC-16645 & MWC-16316

Details

The initial $order->save() method has been removed. This was added to avoid potential errors, but thus far we haven't been able to reproduce any errors with that line removed.

Using authorize.net I tested the following:

In both cases the order was created successfully and the charge went through.

QA

Authorize.net

See https://github.com/gdcorp-partners/woocommerce-gateway-authorize-net-cim/pull/98

  1. Ensure you have authorize.net set up.
  2. Add a product to your cart and proceed through to checkout.
  3. Select the authorize.net payment gateway and add a new payment method. Complete the checkout.
    • [ ] A new order is created with all appropriate information.
    • [ ] Payment is taken successfully.
  4. Go to your account area on the front-end and to the "payment methods" page. Click through to add a new payment method and complete the process.
  5. Once added, log in as an admin and check the WooCommerce > Orders.
    • [ ] No new order has been created.

Elavon

See https://github.com/gdcorp-partners/woocommerce-gateway-elavon/pull/94

  1. Ensure you have Elavon set up and enabled.
  2. Visit any page on the front end.
    • [ ] No new order is created.
  3. Add a product to your cart and proceed through to checkout.
  4. Select the Elavon payment gateway and complete your payment.
    • [ ] One new order is created with all appropriate information.
    • [ ] Payment is taken successfully.
  5. Go to your account area on the front-end and to the "payment methods" page. Click through to add a new payment method and complete the process.
  6. Once added, log in as an admin and check the WooCommerce > Orders.
    • [ ] No new order has been created.

Before Merge

agibson-godaddy commented 3 months ago

QA done here: https://godaddy.slack.com/archives/C04L7S7JJE9/p1718716914136279?thread_ts=1718233890.103419&cid=C04L7S7JJE9