mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Refactoring
This commit is contained in:
parent
65b97f63c5
commit
96d154a856
3 changed files with 6 additions and 6 deletions
|
@ -90,7 +90,7 @@ class IdentityToken {
|
|||
* @return Token
|
||||
* @throws RuntimeException If the request fails.
|
||||
*/
|
||||
public function generate_for_customer( int $user_id ): Token {
|
||||
public function generate_for_user( int $user_id ): Token {
|
||||
|
||||
$bearer = $this->bearer->bearer();
|
||||
$url = trailingslashit( $this->host ) . 'v1/identity/generate-token';
|
||||
|
@ -105,7 +105,7 @@ class IdentityToken {
|
|||
( $this->settings->has( 'vault_enabled' ) && $this->settings->get( 'vault_enabled' ) )
|
||||
&& defined( 'PPCP_FLAG_SUBSCRIPTION' ) && PPCP_FLAG_SUBSCRIPTION
|
||||
) {
|
||||
$customer_id = $this->customer_repository->customer_id_for_user(($user_id));
|
||||
$customer_id = $this->customer_repository->customer_id_for_user( ( $user_id ) );
|
||||
|
||||
if ( 0 === $user_id ) {
|
||||
$customer_id = uniqid();
|
||||
|
|
|
@ -80,7 +80,7 @@ class DataClientIdEndpoint implements EndpointInterface {
|
|||
try {
|
||||
$this->request_data->read_request( $this->nonce() );
|
||||
$user_id = get_current_user_id();
|
||||
$token = $this->identity_token->generate_for_customer( $user_id );
|
||||
$token = $this->identity_token->generate_for_user( $user_id );
|
||||
wp_send_json(
|
||||
array(
|
||||
'token' => $token->token(),
|
||||
|
|
|
@ -92,7 +92,7 @@ class IdentityTokenTest extends TestCase
|
|||
when('wc_print_r')->returnArg();
|
||||
when('get_user_meta')->justReturn('');
|
||||
|
||||
$result = $this->sut->generate_for_customer(1);
|
||||
$result = $this->sut->generate_for_user(1);
|
||||
$this->assertInstanceOf(Token::class, $result);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class IdentityTokenTest extends TestCase
|
|||
$this->customer_repository->shouldReceive('customer_id_for_user');
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->sut->generate_for_customer(1);
|
||||
$this->sut->generate_for_user(1);
|
||||
}
|
||||
|
||||
public function testGenerateForCustomerFailsBecauseResponseCodeIsNot200()
|
||||
|
@ -143,6 +143,6 @@ class IdentityTokenTest extends TestCase
|
|||
$this->customer_repository->shouldReceive('customer_id_for_user');
|
||||
|
||||
$this->expectException(PayPalApiException::class);
|
||||
$this->sut->generate_for_customer(1);
|
||||
$this->sut->generate_for_user(1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue