godaddy-wordpress / wc-plugin-framework

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

Add methods to work with the payment processing context #657

Closed itambek-godaddy closed 8 months ago

itambek-godaddy commented 8 months ago

Summary

In the 5.12.0 release, we added "context" to the payment data, both in shortcode and block checkout. However, we did not add any methods that plugins could use to determine the context easily.

This PR adds a few helper methods to the gateway class to determine the current processing context.

Details

We did have a SV_WC_Payment_Gateway::is_block_checkout() method, which used a POST value that we were using while developing 5.12.0. However, at some point we changed the POST data, and forgot to update to work with the new context field.

I renamed the existing SV_WC_Payment_Gateway::is_block_checkout() method, because it's only used in one plugin, which hasn't been released yet.

I used the term "processing context" because "payment context" could easily be confused with the PaymentContext passed to Gateway_Checkout_Block_Integration::prepare_payment_data(). Also, "checkout context" did not seem precise enough, because "checkout" can either refer to the checkout page or the action of checking out.