woocommerce / woocommerce-gateway-amazon-pay

Amazon Pay Gateway
20 stars 23 forks source link

Set Amazon Pay as the payment method of a subscription when saving the payment meta #284

Open mattallan opened 5 months ago

mattallan commented 5 months ago

All Submissions:

Changes proposed in this Pull Request:

In WooCommerce Subscriptions we have a setting that allows customers to purchase $0 subscription products (i.e. subscriptions that have a trial period) without entering a payment method on the checkout: image

After the free trial ends, when the customer pays for the first renewal order with Amazon Pay, the new payment method is not set on the subscription resulting in the subscription remaining as requiring manual renewal, instead of automatically renewing with Amazon Pay.

I recorded my screen to showcase the issue:

https://github.com/woocommerce/woocommerce-gateway-amazon-pay/assets/2275145/3c849770-2ed9-4d83-a175-f68fad375987

This PR fixes this issue by making sure Amazon Pay is also set as the payment method of the subscription when also copying over the payment method meta from the order.

Closes #283

How to test the changes in this Pull Request:

  1. Install and activate the latest WooCommerce Subscriptions extension
  2. Enable the $0 checkout setting in WooCommerce > Settings >Subscriptions
  3. Create a subscription product with a 7-day free trial
  4. Purchase the subscription with no payment method.
  5. You will see the trial and next payment date. The subscription will be in "manual payment" mode which is expected.
  6. Manually trigger the subscription renewal using the "Process renewal" subscription action: image
  7. Now pay for the new pending renewal order from My Account page and complete the payment with Amazon Pay
  8. Check the subscription on the My Account page and confirm the payment method is set to Amazon Pay: image
  9. Process another renewal and confirm Amazon pay processing the renewal automatically.

Other information:

Changelog entry

Fix - Paying for a manual renewal after a free trial doesn't save Amazon Pay as the payment method