-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
87 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Dto; | ||
|
||
use App\Payment\Common\Message\ResponseInterface; | ||
use Symfony\Component\Serializer\Attribute\SerializedName; | ||
use OpenApi\Attributes as OA; | ||
|
||
#[OA\Schema( | ||
description: 'Payment status object.', | ||
)] | ||
final readonly class PaymentStatusDto | ||
{ | ||
public function __construct( | ||
|
||
#[OA\Property(description: 'Payment gateway id.')] | ||
#[SerializedName('payment_gateway')] public string $paymentGatewayId, | ||
|
||
#[OA\Property(description: 'Transaction result.')] | ||
#[SerializedName('success')] public bool $isSuccess, | ||
|
||
#[OA\Property(description: 'Transaction id from the payment gateway side.')] | ||
#[SerializedName('transaction_id')] public string $transactionId, | ||
|
||
#[OA\Property(description: 'An error message.')] | ||
public string $message, | ||
|
||
#[OA\Property(description: 'An error code.')] | ||
public string $code, | ||
|
||
#[OA\Property(description: 'A payment status transaction as it was received from the payment gateway.')] | ||
public array $data, | ||
) { | ||
} | ||
|
||
public static function makeFromResponse( | ||
string $paymentGatewayId, | ||
ResponseInterface $response, | ||
): self { | ||
return new self( | ||
paymentGatewayId: $paymentGatewayId, | ||
isSuccess: $response->isSuccessful(), | ||
transactionId: $response->getTransactionId(), | ||
message: $response->getMessage(), | ||
code: $response->getCode(), | ||
data: $response->getRawData(), | ||
); | ||
} | ||
} |