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
24 changes: 24 additions & 0 deletions lib/Checkout/Identities/Entities/AttemptAssetsQueryFilter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Checkout\Identities\Entities;

use Checkout\Common\AbstractQueryFilter;

class AttemptAssetsQueryFilter extends AbstractQueryFilter
{
/**
* The number of assets to skip.
* [Optional]
* Default: 0
* @var int|null $skip
*/
public $skip;

/**
* The maximum number of assets to return.
* [Optional]
* Default: 10
* @var int|null $limit
*/
public $limit;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Checkout\CheckoutApiException;
use Checkout\CheckoutConfiguration;
use Checkout\Client;
use Checkout\Identities\Entities\AttemptAssetsQueryFilter;
use Checkout\Identities\FaceAuthentication\Requests\FaceAuthenticationRequest;
use Checkout\Identities\FaceAuthentication\Requests\FaceAuthenticationAttemptRequest;

Expand All @@ -15,6 +16,7 @@ class FaceAuthenticationClient extends Client
const FACE_AUTHENTICATIONS_PATH = "face-authentications";
const ANONYMIZE_PATH = "anonymize";
const ATTEMPTS_PATH = "attempts";
const ASSETS_PATH = "assets";

public function __construct(ApiClient $apiClient, CheckoutConfiguration $configuration)
{
Expand Down Expand Up @@ -116,4 +118,28 @@ public function getFaceAuthenticationAttempt(string $faceAuthenticationId, strin
$this->sdkAuthorization()
);
}

/**
* Retrieves the assets (face images and videos) captured during a face authentication attempt.
*
* faceAuthenticationId is the face authentication's unique identifier. (Required)
* attemptId is the attempt's unique identifier. (Required)
*
* @param string $faceAuthenticationId
* @param string $attemptId
* @param AttemptAssetsQueryFilter|null $query the pagination query parameters (skip and limit)
* @return array
* @throws CheckoutApiException
*/
public function getFaceAuthenticationAttemptAssets(
string $faceAuthenticationId,
string $attemptId,
?AttemptAssetsQueryFilter $query = null
): array {
return $this->apiClient->query(
$this->buildPath(self::FACE_AUTHENTICATIONS_PATH, $faceAuthenticationId, self::ATTEMPTS_PATH, $attemptId, self::ASSETS_PATH),
$query,
$this->sdkAuthorization()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Checkout\CheckoutApiException;
use Checkout\CheckoutConfiguration;
use Checkout\Client;
use Checkout\Identities\Entities\AttemptAssetsQueryFilter;
use Checkout\Identities\IdentityVerification\Requests\IdentityVerificationRequest;
use Checkout\Identities\IdentityVerification\Requests\IdentityVerificationAndOpenRequest;
use Checkout\Identities\IdentityVerification\Requests\IdentityVerificationAttemptRequest;
Expand All @@ -18,6 +19,7 @@ class IdentityVerificationClient extends Client
const ANONYMIZE_PATH = "anonymize";
const ATTEMPTS_PATH = "attempts";
const PDF_REPORT_PATH = "pdf-report";
const ASSETS_PATH = "assets";

public function __construct(ApiClient $apiClient, CheckoutConfiguration $configuration)
{
Expand Down Expand Up @@ -149,4 +151,28 @@ public function getIdentityVerificationPdfReport(string $identityVerificationId)
$this->sdkAuthorization()
);
}

/**
* Retrieves the assets (face images, videos, and document images) captured during an identity verification attempt.
*
* identityVerificationId is the identity verification's unique identifier. (Required)
* attemptId is the attempt's unique identifier. (Required)
*
* @param string $identityVerificationId
* @param string $attemptId
* @param AttemptAssetsQueryFilter|null $query the pagination query parameters (skip and limit)
* @return array
* @throws CheckoutApiException
*/
public function getIdentityVerificationAttemptAssets(
string $identityVerificationId,
string $attemptId,
?AttemptAssetsQueryFilter $query = null
): array {
return $this->apiClient->query(
$this->buildPath(self::IDENTITY_VERIFICATIONS_PATH, $identityVerificationId, self::ATTEMPTS_PATH, $attemptId, self::ASSETS_PATH),
$query,
$this->sdkAuthorization()
);
}
}
17 changes: 17 additions & 0 deletions lib/Checkout/Payments/Hosted/HostedPaymentsSessionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Checkout\Common\CustomerRequest;
use Checkout\Payments\BillingDescriptor;
use Checkout\Payments\BillingInformation;
use Checkout\Payments\PaymentPlan;
use Checkout\Payments\PaymentRecipient;
use Checkout\Payments\ProcessingSettings;
use Checkout\Payments\Request\PaymentInstruction;
Expand Down Expand Up @@ -174,4 +175,20 @@
* @var array values of AmountAllocations
*/
public $amount_allocations;

/**
* The information to process a recurring payment request. To be used when the payment_type is Recurring.
* [Optional]
* @var PaymentPlan|null $payment_plan
*/
public $payment_plan;

Check warning on line 184 in lib/Checkout/Payments/Hosted/HostedPaymentsSessionRequest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "$payment_plan" 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=AZ7fZb-xis3NAysKFvQe&open=AZ7fZb-xis3NAysKFvQe&pullRequest=342

/**
* The authorization type.
* [Optional]
* Enum: "Final" "Estimated"
* Default: "Final"
* @var string|null $authorization_type value of AuthorizationType
*/
public $authorization_type;

Check warning on line 193 in lib/Checkout/Payments/Hosted/HostedPaymentsSessionRequest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "$authorization_type" 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=AZ7fZb-xis3NAysKFvQf&open=AZ7fZb-xis3NAysKFvQf&pullRequest=342
}
17 changes: 17 additions & 0 deletions lib/Checkout/Payments/Links/PaymentLinkRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Checkout\Common\MarketplaceData;
use Checkout\Payments\BillingDescriptor;
use Checkout\Payments\BillingInformation;
use Checkout\Payments\PaymentPlan;
use Checkout\Payments\PaymentRecipient;
use Checkout\Payments\ProcessingSettings;
use Checkout\Payments\Request\PaymentInstruction;
Expand Down Expand Up @@ -182,4 +183,20 @@
* @var array values of AmountAllocations
*/
public $amount_allocations;

/**
* The information to process a recurring payment request. To be used when the payment_type is Recurring.
* [Optional]
* @var PaymentPlan|null $payment_plan
*/
public $payment_plan;

Check warning on line 192 in lib/Checkout/Payments/Links/PaymentLinkRequest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "$payment_plan" 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=AZ7fZcBlis3NAysKFvQh&open=AZ7fZcBlis3NAysKFvQh&pullRequest=342

/**
* The authorization type.
* [Optional]
* Enum: "Final" "Estimated"
* Default: "Final"
* @var string|null $authorization_type value of AuthorizationType
*/
public $authorization_type;

Check warning on line 201 in lib/Checkout/Payments/Links/PaymentLinkRequest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "$authorization_type" 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=AZ7fZcBlis3NAysKFvQi&open=AZ7fZcBlis3NAysKFvQi&pullRequest=342
}
7 changes: 7 additions & 0 deletions lib/Checkout/Payments/ProcessingSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,11 @@
*/
public $card_type;

/**
* The scheme transaction link identifier.
* [Optional]
* @var string|null $scheme_transaction_link_id
*/
public $scheme_transaction_link_id;

Check warning on line 300 in lib/Checkout/Payments/ProcessingSettings.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "$scheme_transaction_link_id" 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=AZ7fZb_eis3NAysKFvQg&open=AZ7fZb_eis3NAysKFvQg&pullRequest=342

}
17 changes: 17 additions & 0 deletions lib/Checkout/Payments/Sessions/PaymentSessionsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Checkout\Payments\BillingInformation;
use Checkout\Payments\ProcessingSettings;
use Checkout\Payments\PaymentCustomerRequest;
use Checkout\Payments\PaymentPlan;
use Checkout\Payments\ThreeDsRequest;
use DateTime;

Expand Down Expand Up @@ -175,4 +176,20 @@
* @var string
*/
public $ip_address;

/**
* The authorization type.
* [Optional]
* Enum: "Final" "Estimated"
* Default: "Final"
* @var string|null $authorization_type value of AuthorizationType
*/
public $authorization_type;

Check warning on line 187 in lib/Checkout/Payments/Sessions/PaymentSessionsRequest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "$authorization_type" 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=AZ7fZb9fis3NAysKFvQc&open=AZ7fZb9fis3NAysKFvQc&pullRequest=342

/**
* The information to process a recurring payment request. To be used when the payment_type is Recurring.
* [Optional]
* @var PaymentPlan|null $payment_plan
*/
public $payment_plan;

Check warning on line 194 in lib/Checkout/Payments/Sessions/PaymentSessionsRequest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "$payment_plan" 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=AZ7fZb9fis3NAysKFvQd&open=AZ7fZb9fis3NAysKFvQd&pullRequest=342
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Checkout\CheckoutArgumentException;
use Checkout\CheckoutAuthorizationException;
use Checkout\CheckoutException;
use Checkout\Identities\Entities\AttemptAssetsQueryFilter;
use Checkout\Identities\Entities\ClientInformation;
use Checkout\Identities\FaceAuthentication\FaceAuthenticationClient;
use Checkout\Identities\FaceAuthentication\Requests\FaceAuthenticationRequest;
Expand Down Expand Up @@ -142,6 +143,48 @@ public function shouldGetFaceAuthenticationAttempt()
$this->validateFaceAuthenticationAttemptResponse($response);
}

/**
* @test
* @throws CheckoutApiException
*/
public function shouldGetFaceAuthenticationAttemptAssets()
{
$expectedResponse = $this->buildExpectedFaceAuthenticationAttemptAssetsResponse();

$this->apiClient
->method("query")
->willReturn($expectedResponse);

$query = new AttemptAssetsQueryFilter();
$query->skip = 0;
$query->limit = 10;
$response = $this->client->getFaceAuthenticationAttemptAssets("face_auth_12345", "attempt_67890", $query);

$this->assertNotNull($response);
$this->validateFaceAuthenticationAttemptAssetsResponse($response);
}

/**
* @test
* @throws CheckoutApiException
*/
public function shouldCallCorrectApiEndpointForGetFaceAuthenticationAttemptAssets()
{
$faceAuthId = "face_auth_12345";
$attemptId = "attempt_67890";
$expectedResponse = $this->buildExpectedFaceAuthenticationAttemptAssetsResponse();

$this->apiClient
->expects($this->once())
->method("query")
->with("face-authentications/" . $faceAuthId . "/attempts/" . $attemptId . "/assets")
->willReturn($expectedResponse);

$response = $this->client->getFaceAuthenticationAttemptAssets($faceAuthId, $attemptId, new AttemptAssetsQueryFilter());

$this->assertNotNull($response);
}

/**
* @test
* @throws CheckoutApiException
Expand Down Expand Up @@ -376,10 +419,43 @@ private function validateFaceAuthenticationAttemptsResponse(array $response): vo
{
$this->assertArrayHasKey("attempts", $response);
$this->assertArrayHasKey("total_count", $response);

$this->assertNotNull($response["attempts"]);
$this->assertTrue(is_array($response["attempts"]));
$this->assertNotNull($response["total_count"]);
$this->assertTrue(is_numeric($response["total_count"]));
}

private function buildExpectedFaceAuthenticationAttemptAssetsResponse(): array
{
return [
"total_count" => 1,
"skip" => 0,
"limit" => 10,
"data" => [
[
"type" => "face_image",
"_links" => [
"asset_url" => [
"href" => "https://example.com/face-image.jpg"
]
]
]
]
];
}

private function validateFaceAuthenticationAttemptAssetsResponse(array $response): void
{
$this->assertArrayHasKey("total_count", $response);
$this->assertArrayHasKey("skip", $response);
$this->assertArrayHasKey("limit", $response);
$this->assertArrayHasKey("data", $response);

$this->assertTrue(is_array($response["data"]));
if (count($response["data"]) > 0) {
$this->assertNotNull($response["data"][0]["type"]);
$this->assertNotNull($response["data"][0]["_links"]["asset_url"]["href"]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,35 @@ public function shouldGetFaceAuthenticationAttempt()
$this->validateRetrievedFaceAuthenticationAttempt($response, $createdAttempt);
}

/**
* @test
* @throws CheckoutApiException
*/
public function shouldGetFaceAuthenticationAttemptAssets()
{
$this->markTestSkipped("This test requires valid test environment setup");

// Create face authentication first
$faceAuthRequest = $this->buildFaceAuthenticationRequest();
$createdFaceAuthentication = $this->checkoutApi->getFaceAuthenticationClient()
->createFaceAuthentication($faceAuthRequest);

// Create attempt first
$attemptRequest = $this->buildFaceAuthenticationAttemptRequest();
$createdAttempt = $this->checkoutApi->getFaceAuthenticationClient()
->createFaceAuthenticationAttempt($createdFaceAuthentication["id"], $attemptRequest);

// Get attempt assets
$query = new \Checkout\Identities\Entities\AttemptAssetsQueryFilter();
$query->skip = 0;
$query->limit = 10;
$response = $this->checkoutApi->getFaceAuthenticationClient()
->getFaceAuthenticationAttemptAssets($createdFaceAuthentication["id"], $createdAttempt["id"], $query);

$this->assertNotNull($response);
$this->assertArrayHasKey("data", $response);
}

/**
* @test
* @throws CheckoutApiException
Expand Down
Loading
Loading