mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
♻️ Consolidate authentication name: OAuth, not ISU
This commit is contained in:
parent
ec029dd4c5
commit
30ab1bd51f
3 changed files with 11 additions and 10 deletions
|
@ -46,14 +46,15 @@ export const REST_DIRECT_AUTHENTICATION_PATH =
|
||||||
'/wc/v3/wc_paypal/authenticate/direct';
|
'/wc/v3/wc_paypal/authenticate/direct';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* REST path to perform the ISU authentication check, using shared ID and authCode.
|
* REST path to perform the OAuth authentication check, using shared ID and authCode.
|
||||||
*
|
*
|
||||||
* Used by: Controls
|
* Used by: Controls
|
||||||
* See: AuthenticateRestEndpoint.php
|
* See: AuthenticateRestEndpoint.php
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
export const REST_ISU_AUTHENTICATION_PATH = '/wc/v3/wc_paypal/authenticate/isu';
|
export const REST_OAUTH_AUTHENTICATION_PATH =
|
||||||
|
'/wc/v3/wc_paypal/authenticate/oauth';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* REST path to generate an ISU URL for the PayPal-login.
|
* REST path to generate an ISU URL for the PayPal-login.
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {
|
||||||
REST_CONNECTION_URL_PATH,
|
REST_CONNECTION_URL_PATH,
|
||||||
REST_HYDRATE_MERCHANT_PATH,
|
REST_HYDRATE_MERCHANT_PATH,
|
||||||
REST_REFRESH_FEATURES_PATH,
|
REST_REFRESH_FEATURES_PATH,
|
||||||
REST_ISU_AUTHENTICATION_PATH,
|
REST_OAUTH_AUTHENTICATION_PATH,
|
||||||
REST_WEBHOOKS,
|
REST_WEBHOOKS,
|
||||||
REST_WEBHOOKS_SIMULATE,
|
REST_WEBHOOKS_SIMULATE,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
@ -82,7 +82,7 @@ export const controls = {
|
||||||
} ) {
|
} ) {
|
||||||
try {
|
try {
|
||||||
return await apiFetch( {
|
return await apiFetch( {
|
||||||
path: REST_ISU_AUTHENTICATION_PATH,
|
path: REST_OAUTH_AUTHENTICATION_PATH,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {
|
data: {
|
||||||
sharedId,
|
sharedId,
|
||||||
|
|
|
@ -106,7 +106,7 @@ class AuthenticationRestEndpoint extends RestEndpoint {
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /wp-json/wc/v3/wc_paypal/authenticate/isu
|
* POST /wp-json/wc/v3/wc_paypal/authenticate/oauth
|
||||||
* {
|
* {
|
||||||
* sharedId
|
* sharedId
|
||||||
* authCode
|
* authCode
|
||||||
|
@ -115,10 +115,10 @@ class AuthenticationRestEndpoint extends RestEndpoint {
|
||||||
*/
|
*/
|
||||||
register_rest_route(
|
register_rest_route(
|
||||||
$this->namespace,
|
$this->namespace,
|
||||||
'/' . $this->rest_base . '/isu',
|
'/' . $this->rest_base . '/oauth',
|
||||||
array(
|
array(
|
||||||
'methods' => WP_REST_Server::EDITABLE,
|
'methods' => WP_REST_Server::EDITABLE,
|
||||||
'callback' => array( $this, 'connect_isu' ),
|
'callback' => array( $this, 'connect_oauth' ),
|
||||||
'permission_callback' => array( $this, 'check_permission' ),
|
'permission_callback' => array( $this, 'check_permission' ),
|
||||||
'args' => array(
|
'args' => array(
|
||||||
'sharedId' => array(
|
'sharedId' => array(
|
||||||
|
@ -181,14 +181,14 @@ class AuthenticationRestEndpoint extends RestEndpoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ISU login: Retrieves clientId and clientSecret using a sharedId and authCode.
|
* OAuth login: Retrieves clientId and clientSecret using a sharedId and authCode.
|
||||||
*
|
*
|
||||||
* This is the final step in the UI-driven login via the ISU popup, which
|
* This is the final step in the UI-driven login via the OAuth popup, which
|
||||||
* is triggered by the LoginLinkRestEndpoint URL.
|
* is triggered by the LoginLinkRestEndpoint URL.
|
||||||
*
|
*
|
||||||
* @param WP_REST_Request $request Full data about the request.
|
* @param WP_REST_Request $request Full data about the request.
|
||||||
*/
|
*/
|
||||||
public function connect_isu( WP_REST_Request $request ) : WP_REST_Response {
|
public function connect_oauth( WP_REST_Request $request ) : WP_REST_Response {
|
||||||
$shared_id = $request->get_param( 'sharedId' );
|
$shared_id = $request->get_param( 'sharedId' );
|
||||||
$auth_code = $request->get_param( 'authCode' );
|
$auth_code = $request->get_param( 'authCode' );
|
||||||
$use_sandbox = $request->get_param( 'useSandbox' );
|
$use_sandbox = $request->get_param( 'useSandbox' );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue