Remote Specs: Update endpoints to 2.0 (#45298)
This commit is contained in:
parent
e16a644e86
commit
172bbac661
|
@ -8,17 +8,17 @@ composer require woocommerce/remote-specs-validation
|
|||
|
||||
## Available Schemas
|
||||
|
||||
| Filename | Endpoint | Bundle |
|
||||
| ------------- | ------------- | ----------- |
|
||||
| remote-inbox-notification.json | <https://woocommerce.com/wp-json/wccom/inbox-notifications/1.0/notifications.json> | remote-inbox-notification |
|
||||
| payment-gateway-suggestions.json | <https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/1.0/suggestions.json> | payment-gateway-suggestions |
|
||||
| obw-free-extensions.json | <https://woocommerce.com/wp-json/wccom/obw-free-extensions/3.0/extensions.json> | obw-free-extensions |
|
||||
| wc-pay-promotions.json | <https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/1.0/payment-method/promotions.json> | wc-pay-promotions |
|
||||
| shipping-partner-suggestions.json | <https://woocommerce.com/wp-json/wccom/shipping-partner-suggestions/1.0/suggestions.json> | shipping-partner-suggestions |
|
||||
| Filename | Endpoint | Bundle |
|
||||
| --------------------------------- | ------------------------------------------------------------------------------------------------------ | ---------------------------- |
|
||||
| remote-inbox-notification.json | <https://woocommerce.com/wp-json/wccom/inbox-notifications/2.0/notifications.json> | remote-inbox-notification |
|
||||
| payment-gateway-suggestions.json | <https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/2.0/suggestions.json> | payment-gateway-suggestions |
|
||||
| obw-free-extensions.json | <https://woocommerce.com/wp-json/wccom/obw-free-extensions/4.0/extensions.json> | obw-free-extensions |
|
||||
| wc-pay-promotions.json | <https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/2.0/payment-method/promotions.json> | wc-pay-promotions |
|
||||
| shipping-partner-suggestions.json | <https://woocommerce.com/wp-json/wccom/shipping-partner-suggestions/2.0/suggestions.json> | shipping-partner-suggestions |
|
||||
|
||||
## Working with Schema
|
||||
|
||||
If it's your first time working with JSON Schema, we highly recommend reading <https://json-schema.org/learn/getting-started-step-by-step> first.
|
||||
If it's your first time working with JSON Schema, we highly recommend reading <https://json-schema.org/learn/getting-started-step-by-step> first.
|
||||
|
||||
1. Open a schema file from `schemas` directory.
|
||||
2. Make changes.
|
||||
|
@ -41,4 +41,3 @@ if ( !$result->is_valid() ) {
|
|||
var_dump('everyting looks good!');
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: update
|
||||
|
||||
Bump all remote spec endpoints to version `2.0`.
|
|
@ -4,7 +4,7 @@ This feature uses JSON to retrieve the currently recommended payment gateways. T
|
|||
|
||||
After merchants click on a recommendation, plugins from this source will then walk through an installer step, followed by a connection step with the minimum required fields for setup defined by the downloaded plugin.
|
||||
|
||||
### Quick start
|
||||
## Quick start
|
||||
|
||||
Gateway suggestions are retrieved from a REST API and can be added via a remote JSON data source or filtered with the `woocommerce_admin_payment_gateway_suggestion_specs` filter.
|
||||
|
||||
|
@ -12,11 +12,11 @@ To quickly get started with an example plugin, run the following:
|
|||
|
||||
`WC_EXT=payment-gateway-suggestions pnpm example --filter=@woocommerce/admin-library`
|
||||
|
||||
This will create a new plugin that when activated will add two new gateway suggestions. The first is a simple gateway demonstrating how configuration fields can be pulled from the gateway class to create a configuration form. The second gateway shows a more customized approach via SlotFill.
|
||||
This will create a new plugin that when activated will add two new gateway suggestions. The first is a simple gateway demonstrating how configuration fields can be pulled from the gateway class to create a configuration form. The second gateway shows a more customized approach via SlotFill.
|
||||
|
||||
## Data Source Polling
|
||||
|
||||
If a store is opted into marketplace suggestions via `woocommerce_show_marketplace_suggestions` the suggestions by default will be retrieved from `https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/1.0/suggestions.json`.
|
||||
If a store is opted into marketplace suggestions via `woocommerce_show_marketplace_suggestions` the suggestions by default will be retrieved from `https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/2.0/suggestions.json`.
|
||||
|
||||
If a user is not opted into marketplace suggestions or polling fails, the gateway suggestions will fall back to the defaults in the `DefaultPaymentGateways` class.
|
||||
|
||||
|
@ -57,14 +57,13 @@ Additional information is added to the existing payment gateway in the WooCommer
|
|||
| `get_post_install_script_handles()` | array | `[]` | An array of script handles previously registered with `wp_register_script` to enqueue after the payment gateway has been installed. This is primarily used to `SlotFill` the payment connection step, but can allow any script to be added to assist in payment gateway setup. |
|
||||
| `get_setup_help_text()` | string | `null` | Help text to be shown above the connection step's submit button. |
|
||||
|
||||
|
||||
## SlotFill
|
||||
|
||||
By default, the client will generate a payment gateway setup form from the settings fields registered in `get_required_settings_keys()`. However, payment gateway tasks can be SlotFilled to provide custom experiences. This is useful if a gateway cannot follow the generic payment steps to be fully set up.
|
||||
By default, the client will generate a payment gateway setup form from the settings fields registered in `get_required_settings_keys()`. However, payment gateway tasks can be SlotFilled to provide custom experiences. This is useful if a gateway cannot follow the generic payment steps to be fully set up.
|
||||
|
||||
### WooPaymentGatewayConfigure
|
||||
|
||||
To customize the configuration form used in the payment setup, you can use [WooPaymentGatewayConfigure](https://github.com/woocommerce/woocommerce/tree/trunk/packages/js/onboarding/src/components/WooPaymentGatewayConfigure).
|
||||
To customize the configuration form used in the payment setup, you can use [WooPaymentGatewayConfigure](https://github.com/woocommerce/woocommerce/tree/trunk/packages/js/onboarding/src/components/WooPaymentGatewayConfigure).
|
||||
|
||||
This will leave the default gateway installation and stepper in place, but allow the form to be customized as needed.
|
||||
|
||||
|
@ -76,4 +75,4 @@ To completely override the stepper and default installation behavior, the gatewa
|
|||
|
||||
Since plugin installation happens asynchronously, a full page reload will not occur between gateway installation and configuration. This renders functions like `wp_enqueue_script` ineffective.
|
||||
|
||||
To allow for interaction with the newly registered gateway and allow `SlotFill` to work on a newly installed plugin, the gateway can provide a URL to be loaded immediately after installation using `get_post_install_script_handles()`. Registered scripts in this handler will automatically be injected into the page after the gateway has been installed.
|
||||
To allow for interaction with the newly registered gateway and allow `SlotFill` to work on a newly installed plugin, the gateway can provide a URL to be loaded immediately after installation using `get_post_install_script_handles()`. Registered scripts in this handler will automatically be injected into the page after the gateway has been installed.
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: update
|
||||
|
||||
Bump all remote spec endpoints to version `2.0`.
|
|
@ -18,7 +18,7 @@ class PaymentGatewaySuggestionsDataSourcePoller extends DataSourcePoller {
|
|||
* Default data sources array.
|
||||
*/
|
||||
const DATA_SOURCES = array(
|
||||
'https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/1.0/suggestions.json',
|
||||
'https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/2.0/suggestions.json',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ class ShippingPartnerSuggestionsDataSourcePoller extends DataSourcePoller {
|
|||
* Default data sources array.
|
||||
*/
|
||||
const DATA_SOURCES = array(
|
||||
'https://woocommerce.com/wp-json/wccom/shipping-partner-suggestions/1.0/suggestions.json',
|
||||
'https://woocommerce.com/wp-json/wccom/shipping-partner-suggestions/2.0/suggestions.json',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,7 @@ defined( 'ABSPATH' ) || exit;
|
|||
class DataSourcePoller extends \Automattic\WooCommerce\Admin\DataSourcePoller {
|
||||
const ID = 'remote_inbox_notifications';
|
||||
const DATA_SOURCES = array(
|
||||
'https://woocommerce.com/wp-json/wccom/inbox-notifications/1.0/notifications.json',
|
||||
'https://woocommerce.com/wp-json/wccom/inbox-notifications/2.0/notifications.json',
|
||||
);
|
||||
/**
|
||||
* Class instance.
|
||||
|
|
|
@ -10,7 +10,7 @@ class RemoteFreeExtensionsDataSourcePoller extends \Automattic\WooCommerce\Admin
|
|||
const ID = 'remote_free_extensions';
|
||||
|
||||
const DATA_SOURCES = array(
|
||||
'https://woocommerce.com/wp-json/wccom/obw-free-extensions/3.0/extensions.json',
|
||||
'https://woocommerce.com/wp-json/wccom/obw-free-extensions/4.0/extensions.json',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,7 @@ class WCPayPromotionDataSourcePoller extends DataSourcePoller {
|
|||
* Default data sources array.
|
||||
*/
|
||||
const DATA_SOURCES = array(
|
||||
'https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/1.0/payment-method/promotions.json',
|
||||
'https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/2.0/payment-method/promotions.json',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,7 +53,7 @@ class PaymentGatewaySuggestionsTest extends WC_REST_Unit_Test_Case {
|
|||
update_option( 'woocommerce_default_country', 'US:CA' );
|
||||
|
||||
$response_mock_ref = function( $preempt, $parsed_args, $url ) {
|
||||
if ( str_contains( $url, 'https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/1.0/suggestions.json' ) ) {
|
||||
if ( str_contains( $url, 'https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/2.0/suggestions.json' ) ) {
|
||||
return array(
|
||||
'success' => true,
|
||||
'body' => wp_json_encode(
|
||||
|
|
Loading…
Reference in New Issue