KoryHub
Payments · @moussa

@moussa/mobile-money-resilient

Encaissement Mobile Money résistant aux coupures réseau, sans double débit.

Published · 1.2.0
Verified in Prod
MIT
php
src/PaymentService.php 1 KB · SHA-256 8790b5c730e6…
<?php

final class PaymentService
{
    public function __construct(private PaymentGateway $gateway, private PendingPaymentQueue $queue) {}

    public function pay(string $phone, int $amountXaf, string $orderId): PaymentStatus
    {
        // La clé dépend de la commande, pas du moment : un nouvel essai réutilise la même.
        $key = 'order-'.$orderId;

        return $this->gateway->charge($phone, $amountXaf, $key)->status();
    }
}