Automattic / woocommerce-services

WooCommerce Services is a feature plugin that integrates hosted services into WooCommerce (3.0+), and currently includes automated tax rates and the ability to purchase and print USPS shipping labels.
GNU General Public License v2.0
108 stars 20 forks source link

Load sift js snippet #2689

Closed harriswong closed 1 year ago

harriswong commented 1 year ago

Description

This PR adds the Sift.js snippet. It follows the documentation here https://sift.com/developers/docs/php/javascript-api/overview.

The logic is very similar to WooCommerce Payments https://github.com/Automattic/woocommerce-payments/blob/c7b5b934684cc8c3d256e2ec84bc4ddf1071edac/includes/class-wc-payments-fraud-service.php#L170-L205

Related issue(s)

273-gh-Automattic/woocommerce-shipping-issues 2246-gh-Automattic/woocommerce-connect-server

Steps to reproduce & screenshots/GIFs

  1. You will need this PR to accompany the test. 2247-gh-Automattic/woocommerce-connect-server
  2. Go to label printing page. Open up your browser's network tab
  3. Confirm that you see a request made to s.js, and Request URL is https://cdn.sift.com/s.js.
  4. If you have access to the Sift dashboard, you should see something like this: pNPgK-6DZ-p2#comment-25368

Checklist

harriswong commented 1 year ago

Tested the scenario where the server is not ready to provide sift's configuration. I did this by triggering an error thrown by get_sift_configuration(). I confirmed that the plugin will function as if sift is not loaded.