Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders\WooPayments
WooPaymentsRestController::register_routes │ public │ WC 1.0
Register the REST API endpoints handled by this controller.
Метод класса: WooPaymentsRestController{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WooPaymentsRestController = new WooPaymentsRestController(); $WooPaymentsRestController->register_routes( $override );
- $override(true|false)
- Whether to override the existing routes. Useful for testing.
По умолчанию:false
Код WooPaymentsRestController::register_routes() WooPaymentsRestController::register routes WC 10.9.4
public function register_routes( bool $override = false ) {
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'get_onboarding_details' ),
'validation_callback' => 'rest_validate_request_arg',
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
'schema' => fn() => $this->get_schema_for_get_onboarding_details(),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/step/(?P<step>[a-zA-Z0-9_-]+)/start',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_onboarding_step_start' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/step/(?P<step>[a-zA-Z0-9_-]+)/save',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_onboarding_step_save' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/step/(?P<step>[a-zA-Z0-9_-]+)/check',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_onboarding_step_check' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/step/(?P<step>[a-zA-Z0-9_-]+)/finish',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_onboarding_step_finish' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/step/(?P<step>[a-zA-Z0-9_-]+)/clean',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_onboarding_step_clean' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
),
),
),
$override
);
// Onboarding step specific routes.
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/step/' . WooPaymentsService::ONBOARDING_STEP_TEST_ACCOUNT . '/init',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_onboarding_test_account_init' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/step/' . WooPaymentsService::ONBOARDING_STEP_TEST_ACCOUNT . '/reset',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_onboarding_test_account_reset' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/step/' . WooPaymentsService::ONBOARDING_STEP_BUSINESS_VERIFICATION . '/kyc_session',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_onboarding_business_verification_kyc_session_init' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/step/' . WooPaymentsService::ONBOARDING_STEP_BUSINESS_VERIFICATION . '/kyc_session/finish',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_onboarding_business_verification_kyc_session_finish' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
),
$override
);
// This is a route to disable test accounts for the native onboarding UX.
// The handler is the same as the one for the non-native onboarding UX.
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/step/' . WooPaymentsService::ONBOARDING_STEP_BUSINESS_VERIFICATION . '/test_account/disable',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_test_account_disable' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'from' => array(
'description' => esc_html__( 'Where from in the onboarding flow this request was triggered.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/preload',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_onboarding_preload' ),
'validation_callback' => 'rest_validate_request_arg',
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/reset',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'reset_onboarding' ),
'validation_callback' => 'rest_validate_request_arg',
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'from' => array(
'description' => esc_html__( 'Where from in the onboarding flow this request was triggered.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/woopay-eligibility',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'get_woopay_eligibility' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
),
),
$override
);
// This is the route to disable test accounts when not in a native in-context UX.
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/onboarding/test_account/disable',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'handle_test_account_disable' ),
'validation_callback' => 'rest_validate_request_arg',
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to the stored providers business location country code.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
'from' => array(
'description' => esc_html__( 'Where from in the onboarding flow this request was triggered.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
'source' => array(
'description' => esc_html__( 'The upmost entry point from where the merchant entered the onboarding flow.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_text_field',
),
),
),
),
$override
);
}