Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ vendor/*
.cursor
.vscode
composer

.claude/
CLAUDE.md
34 changes: 28 additions & 6 deletions lib/Checkout/CheckoutApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,16 @@ public function __construct(CheckoutConfiguration $configuration)
$this->paymentContextClient = new PaymentContextsClient($baseApiClient, $configuration);
$this->paymentSessionsClient = new PaymentSessionsClient($baseApiClient, $configuration);
$this->paymentSetupsClient = new PaymentSetupsClient($baseApiClient, $configuration);
$this->forwardClient = new ForwardClient($baseApiClient, $configuration);
$this->faceAuthenticationClient = new FaceAuthenticationClient($baseApiClient, $configuration);
$this->idDocumentVerificationClient = new IdDocumentVerificationClient($baseApiClient, $configuration);
$this->identityVerificationClient = new IdentityVerificationClient($baseApiClient, $configuration);
$this->amlScreeningClient = new AmlScreeningClient($baseApiClient, $configuration);
$this->applicantsClient = new ApplicantsClient($baseApiClient, $configuration);
$this->forwardClient = new ForwardClient(
$this->getForwardApiClient($configuration),
$configuration
);
$identityApiClient = $this->getIdentityApiClient($configuration);
$this->faceAuthenticationClient = new FaceAuthenticationClient($identityApiClient, $configuration);
$this->idDocumentVerificationClient = new IdDocumentVerificationClient($identityApiClient, $configuration);
$this->identityVerificationClient = new IdentityVerificationClient($identityApiClient, $configuration);
$this->amlScreeningClient = new AmlScreeningClient($identityApiClient, $configuration);
$this->applicantsClient = new ApplicantsClient($identityApiClient, $configuration);
$this->balancesClient = new BalancesClient(
$this->getBalancesApiClient($configuration),
$configuration
Expand Down Expand Up @@ -465,4 +469,22 @@ private function getBalancesApiClient(CheckoutConfiguration $configuration)
{
return new ApiClient($configuration, $configuration->getEnvironment()->getBalancesUri());
}

/**
* @param CheckoutConfiguration $configuration
* @return ApiClient
*/
private function getForwardApiClient(CheckoutConfiguration $configuration)
{
return new ApiClient($configuration, $configuration->getEnvironment()->getForwardUri());
}

/**
* @param CheckoutConfiguration $configuration
* @return ApiClient
*/
private function getIdentityApiClient(CheckoutConfiguration $configuration)
{
return new ApiClient($configuration, $configuration->getEnvironment()->getIdentityUri());
}
}
28 changes: 28 additions & 0 deletions lib/Checkout/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
private $filesBaseUri;
private $transfersUri;
private $balancesUri;
private $forwardUri;
private $identityUri;
private $isSandbox;

/**
Expand All @@ -17,21 +19,27 @@
* @param string $filesBaseUrl
* @param string $transfersUri
* @param string $balancesUri
* @param string $forwardUri
* @param string $identityUri
* @param bool $isSandbox
*/
private function __construct(
$baseUri,
$authorizationUri,
$filesBaseUrl,
$transfersUri,
$balancesUri,
$forwardUri,
$identityUri,
$isSandbox
) {

Check warning on line 35 in lib/Checkout/Environment.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function has 8 parameters, which is greater than the 7 authorized.

See more on https://sonarcloud.io/project/issues?id=checkout_checkout-sdk-php&issues=AZ4XNT_Peho1aNzZr-Nx&open=AZ4XNT_Peho1aNzZr-Nx&pullRequest=334
$this->baseUri = $baseUri;
$this->authorizationUri = $authorizationUri;
$this->filesBaseUri = $filesBaseUrl;
$this->transfersUri = $transfersUri;
$this->balancesUri = $balancesUri;
$this->forwardUri = $forwardUri;
$this->identityUri = $identityUri;
$this->isSandbox = $isSandbox;
}

Expand All @@ -46,6 +54,8 @@
"https://files.sandbox.checkout.com/",
"https://transfers.sandbox.checkout.com/",
"https://balances.sandbox.checkout.com/",
"https://forward.sandbox.checkout.com/",
"https://identity-verification.sandbox.checkout.com/",
true
);
}
Expand All @@ -62,6 +72,8 @@
"https://files.checkout.com/",
"https://transfers.checkout.com/",
"https://balances.checkout.com/",
"https://forward.checkout.com/",
"https://identity-verification.checkout.com/",
false
);
}
Expand Down Expand Up @@ -113,4 +125,20 @@
{
return $this->balancesUri;
}

/**
* @return string
*/
public function getForwardUri()
{
return $this->forwardUri;
}

/**
* @return string
*/
public function getIdentityUri()
{
return $this->identityUri;
}
}
2 changes: 1 addition & 1 deletion lib/Checkout/EnvironmentSubdomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private function createUrlWithSubdomain($originalUrl, $subdomain)
{
$newEnvironment = $originalUrl;

$regex = '/^[0-9a-z]+$/';
$regex = '/^(?:pl-)?[a-z0-9]+$/';
if (preg_match($regex, $subdomain)) {
$urlParts = parse_url($originalUrl);
$newHost = $subdomain . '.' . $urlParts['host'];
Expand Down
1 change: 1 addition & 0 deletions lib/Checkout/OAuthScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
public static $GatewayPaymentDetails = "gateway:payment-details";
public static $GatewayPaymentRefunds = "gateway:payment-refunds";
public static $GatewayPaymentVoids = "gateway:payment-voids";
public static $IdentityVerification = "identity-verification";

Check warning on line 39 in lib/Checkout/OAuthScope.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "$IdentityVerification" to match the regular expression ^[a-z][a-zA-Z0-9]*$.

See more on https://sonarcloud.io/project/issues?id=checkout_checkout-sdk-php&issues=AZ4bcuomq8eqsR7S95vX&open=AZ4bcuomq8eqsR7S95vX&pullRequest=334
public static $IssuingCardManagementRead = "issuing:card-management-read";
public static $IssuingCardManagementWrite = "issuing:card-management-write";
public static $IssuingCardMgmt = "issuing:card-mgmt";
Expand Down
23 changes: 23 additions & 0 deletions test/Checkout/Tests/CheckoutConfigurationTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public function validSubdomainProvider()
["abc", "https://abc.api.sandbox.checkout.com/", "https://abc.access.sandbox.checkout.com/connect/token"],
["abc1", "https://abc1.api.sandbox.checkout.com/", "https://abc1.access.sandbox.checkout.com/connect/token"],
["12345domain", "https://12345domain.api.sandbox.checkout.com/", "https://12345domain.access.sandbox.checkout.com/connect/token"],
["pl-vkuhvk4v", "https://pl-vkuhvk4v.api.sandbox.checkout.com/", "https://pl-vkuhvk4v.access.sandbox.checkout.com/connect/token"],
["pl-abc123", "https://pl-abc123.api.sandbox.checkout.com/", "https://pl-abc123.access.sandbox.checkout.com/connect/token"],
];
}

Expand All @@ -95,6 +97,12 @@ public function invalidSubdomainProvider()
[" - ", "https://api.sandbox.checkout.com/", "https://access.sandbox.checkout.com/connect/token"],
["a b", "https://api.sandbox.checkout.com/", "https://access.sandbox.checkout.com/connect/token"],
["ab c1.", "https://api.sandbox.checkout.com/", "https://access.sandbox.checkout.com/connect/token"],
["foo-", "https://api.sandbox.checkout.com/", "https://access.sandbox.checkout.com/connect/token"],
["-foo", "https://api.sandbox.checkout.com/", "https://access.sandbox.checkout.com/connect/token"],
["ABC", "https://api.sandbox.checkout.com/", "https://access.sandbox.checkout.com/connect/token"],
["test-123", "https://api.sandbox.checkout.com/", "https://access.sandbox.checkout.com/connect/token"],
["foo-bar", "https://api.sandbox.checkout.com/", "https://access.sandbox.checkout.com/connect/token"],
["pl-", "https://api.sandbox.checkout.com/", "https://access.sandbox.checkout.com/connect/token"],
];
}

Expand Down Expand Up @@ -126,4 +134,19 @@ public function testShouldCreateConfigurationWithSubdomainForProduction()
$this->assertEquals("https://1234prod.api.checkout.com/", $configuration->getEnvironmentSubdomain()->getBaseUri());
$this->assertEquals("https://1234prod.access.checkout.com/connect/token", $configuration->getEnvironmentSubdomain()->getAuthorizationUri());
}

public function testEnvironmentSandboxHasCorrectForwardAndIdentityUrls()
{
$env = Environment::sandbox();
$this->assertEquals("https://forward.sandbox.checkout.com/", $env->getForwardUri());
$this->assertEquals("https://identity-verification.sandbox.checkout.com/", $env->getIdentityUri());
}

public function testEnvironmentProductionHasCorrectForwardAndIdentityUrls()
{
$env = Environment::production();
$this->assertEquals("https://forward.checkout.com/", $env->getForwardUri());
$this->assertEquals("https://identity-verification.checkout.com/", $env->getIdentityUri());
}

}
2 changes: 1 addition & 1 deletion test/Checkout/Tests/CheckoutDefaultSdkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function shouldFailCreatingCheckoutSdks()
public function shouldInstantiateClientWithCustomHttpClient()
{
$httpBuilder = $this->createMock(HttpClientBuilderInterface::class);
$httpBuilder->expects($this->exactly(4))->method("getClient");
$httpBuilder->expects($this->exactly(6))->method("getClient");

$this->assertNotNull(CheckoutSdk::builder()
->staticKeys()
Expand Down
Loading