mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-10 23:42:39 +08:00
🚧 First steps for the final ISU authentication
This commit is contained in:
parent
ef0e7e756c
commit
565ee96bb6
2 changed files with 56 additions and 0 deletions
|
@ -45,6 +45,16 @@ export const REST_PERSIST_PATH = '/wc/v3/wc_paypal/common';
|
|||
export const REST_DIRECT_AUTHENTICATION_PATH =
|
||||
'/wc/v3/wc_paypal/authenticate/direct';
|
||||
|
||||
/**
|
||||
* REST path to perform the ISU authentication check, using shared ID and authCode.
|
||||
*
|
||||
* Used by: Controls
|
||||
* See: AuthenticateRestEndpoint.php
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
export const REST_ISU_AUTHENTICATION_PATH = '/wc/v3/wc_paypal/authenticate/isu';
|
||||
|
||||
/**
|
||||
* REST path to generate an ISU URL for the PayPal-login.
|
||||
*
|
||||
|
|
|
@ -96,6 +96,34 @@ class AuthenticationRestEndpoint extends RestEndpoint {
|
|||
),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/isu',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'connect_isu' ),
|
||||
'permission_callback' => array( $this, 'check_permission' ),
|
||||
'args' => array(
|
||||
'sharedId' => array(
|
||||
'requires' => true,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
),
|
||||
'authCode' => array(
|
||||
'requires' => true,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
),
|
||||
'useSandbox' => array(
|
||||
'requires' => false,
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'sanitize_callback' => array( $this, 'to_boolean' ),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,4 +151,22 @@ class AuthenticationRestEndpoint extends RestEndpoint {
|
|||
|
||||
return $this->return_success( $response );
|
||||
}
|
||||
|
||||
/**
|
||||
* ISU 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
|
||||
* is triggered by the LoginLinkRestEndpoint URL.
|
||||
*
|
||||
* @param WP_REST_Request $request Full data about the request.
|
||||
*/
|
||||
public function connect_isu( WP_REST_Request $request ) : WP_REST_Response {
|
||||
$shared_id = $request->get_param( 'sharedId' );
|
||||
$auth_code = $request->get_param( 'authCode' );
|
||||
$use_sandbox = $request->get_param( 'useSandbox' );
|
||||
|
||||
// TODO.
|
||||
|
||||
return $this->return_error( 'NOT IMPLEMENTED' );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue