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
12 changes: 12 additions & 0 deletions src/Payment/Application/Service/TransactionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
namespace Paymentic\Sdk\Payment\Application\Service;

use Exception;
use JsonException;
use Paymentic\Sdk\Payment\Application\Contract\TransactionServiceContract;
use Paymentic\Sdk\Payment\Application\DTO\CreateTransactionRequest;
use Paymentic\Sdk\Payment\Application\DTO\CreateTransactionResponse;
use Paymentic\Sdk\Payment\Application\Mapper\TransactionMapper;
use Paymentic\Sdk\Payment\Domain\Entity\Transaction;
use Paymentic\Sdk\Shared\Exception\PaymenticException;
use Paymentic\Sdk\Shared\Http\HttpClient;

final readonly class TransactionService implements TransactionServiceContract
Expand All @@ -19,6 +21,10 @@ public function __construct(
) {
}

/**
* @throws PaymenticException
* @throws JsonException
*/
public function create(string $pointId, CreateTransactionRequest $request): CreateTransactionResponse
{
$response = $this->httpClient->post(
Expand All @@ -30,6 +36,8 @@ public function create(string $pointId, CreateTransactionRequest $request): Crea
}

/**
* @throws PaymenticException
* @throws JsonException
* @throws Exception
*/
public function get(string $pointId, string $transactionId): Transaction
Expand All @@ -41,6 +49,10 @@ public function get(string $pointId, string $transactionId): Transaction
return TransactionMapper::fromArray($response['data']);
}

/**
* @throws PaymenticException
* @throws JsonException
*/
public function capture(string $pointId, string $transactionId): void
{
$this->httpClient->patch(
Expand Down
6 changes: 6 additions & 0 deletions src/Shared/Http/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public function __construct(
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
* @throws JsonException
* @throws PaymenticException
*/
public function post(string $uri, array $data = []): array
{
Expand All @@ -32,6 +34,8 @@ public function post(string $uri, array $data = []): array

/**
* @return array<string, mixed>
* @throws JsonException
* @throws PaymenticException
*/
public function get(string $uri): array
{
Expand All @@ -41,6 +45,8 @@ public function get(string $uri): array
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
* @throws JsonException
* @throws PaymenticException
*/
public function patch(string $uri, array $data = []): array
{
Expand Down