Add Payment module: contracts, payments/refunds tables, KBZ gateway, factory, orchestrator (T5.1-T5.7)

- T5.1 PaymentGatewayInterface, DTOs, PaymentMethod/PaymentStatus/RefundStatus enums
- T5.2 payments/refunds tables, models, factories
- T5.3-T5.5 KbzMiniAppGateway: initiate()/verify()/refund(), ported KBZ signing scheme,
  wired refund_amount through for partial refunds, mTLS options for refund
- T5.6 PaymentGatewayFactory resolving gateways by PaymentMethod
- T5.7 PaymentService orchestrator delegating to the resolved gateway
This commit is contained in:
Nyan Lin Paing
2026-08-08 22:42:16 +07:00
parent e0bcc5f81a
commit 4737838021
28 changed files with 1407 additions and 1 deletions
@@ -0,0 +1,36 @@
<?php
namespace Modules\Payment\Services;
use Modules\Payment\Data\PaymentRequestData;
use Modules\Payment\Data\PaymentResultData;
use Modules\Payment\Data\RefundResultData;
use Modules\Payment\Enums\PaymentMethod;
use Modules\Payment\Factories\PaymentGatewayFactory;
/**
* Thin orchestrator delegating to the gateway resolved by
* PaymentGatewayFactory the single call site every Payment Action goes
* through, so no Action ever depends on a concrete gateway class.
*/
class PaymentService
{
public function __construct(
private readonly PaymentGatewayFactory $gateways,
) {}
public function initiate(PaymentRequestData $data): PaymentResultData
{
return $this->gateways->make($data->method)->initiate($data);
}
public function verify(PaymentMethod $method, string $gatewayTransactionId): PaymentResultData
{
return $this->gateways->make($method)->verify($gatewayTransactionId);
}
public function refund(PaymentMethod $method, string $gatewayTransactionId, string $amount, string $reason): RefundResultData
{
return $this->gateways->make($method)->refund($gatewayTransactionId, $amount, $reason);
}
}