Skip to content

Commit 2acc6cd

Browse files
committed
feat: add secure payment confirmation classes and update payment handling logic
1 parent 699233d commit 2acc6cd

File tree

6 files changed

+94
-1
lines changed

6 files changed

+94
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Webauthn\AuthenticationExtensions;
6+
7+
use Webauthn\SecurePaymentConfirmation\PaymentCredentialInstrument;
8+
use Webauthn\SecurePaymentConfirmation\PaymentCurrencyAmount;
9+
10+
final class PaymentExtension extends AuthenticationExtension
11+
{
12+
public static function register(string $rpId, string $topOrigin, string $payeeName, string $payeeOrigin, PaymentCurrencyAmount $amount, PaymentCredentialInstrument $instrument): AuthenticationExtension
13+
{
14+
return self::create('payment', [
15+
'isPayment' => true,
16+
'rpId' => $rpId,
17+
'topOrigin' => $topOrigin,
18+
'payeeName' => $payeeName,
19+
'payeeOrigin' => $payeeOrigin,
20+
'currencyAmount' => $amount,
21+
'credentialInstrument' => $instrument,
22+
]);
23+
}
24+
25+
public static function authenticate(): AuthenticationExtension
26+
{
27+
return self::create('payment', ['isPayment' => true]);
28+
}
29+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Webauthn\SecurePaymentConfirmation;
6+
7+
class CollectedClientAdditionalPaymentData
8+
{
9+
public function __construct(
10+
public string $rpId,
11+
public string $topOrigin,
12+
public string $payeeName,
13+
public string $payeeOrigin,
14+
public PaymentCurrencyAmount $total,
15+
public PaymentCredentialInstrument $instrument,
16+
){
17+
}
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Webauthn\SecurePaymentConfirmation;
6+
7+
class CollectedClientPaymentData
8+
{
9+
10+
public function __construct(
11+
public CollectedClientAdditionalPaymentData $payment,
12+
)
13+
{
14+
}
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Webauthn\SecurePaymentConfirmation;
6+
7+
class PaymentCredentialInstrument
8+
{
9+
public function __construct(
10+
public string $displayName,
11+
public string $icon,
12+
public bool $iconMustBeShown = true,
13+
)
14+
{
15+
}
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Webauthn\SecurePaymentConfirmation;
6+
7+
class PaymentCurrencyAmount
8+
{
9+
public function __construct(
10+
public string $currency,
11+
public string $value,
12+
)
13+
{
14+
}
15+
}

tests/library/Functional/AssertionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public function previouslyFixedKeyCanBeVerified(): void
226226
$source,
227227
$publicKeyCredential->response,
228228
$publicKeyCredentialRequestOptions,
229-
'tuleap-web.tuleap-aio-dev.docker',
229+
'webauthn.spomky-labs.com',
230230
'101'
231231
);
232232
}

0 commit comments

Comments
 (0)