<?php


require_once __DIR__ . "/MTNPayment.php";


class Payment
{


    private $gateway;



    public function __construct()
    {

    }



    /**
     * Generic Payment Function
     */
    public function pay(
        string $provider,
        string $phone,
        float $amount
    ): array
    {

        switch(strtoupper($provider))
        {


            case "MTN":


                $this->gateway = new MTNPayment();


                return $this->gateway->pay(
                    $phone,
                    $amount
                );



            case "AIRTEL":


                return [

                    "success" => false,
                    "message" => "Airtel Money not implemented yet."

                ];



            default:


                return [

                    "success" => false,
                    "message" => "Unsupported payment provider."

                ];

        }


    }



    /**
     * Check Payment Status
     */
    public function status(
        string $provider,
        string $referenceId
    ): array
    {


        switch(strtoupper($provider))
        {


            case "MTN":


                $this->gateway = new MTNPayment();


                return $this->gateway->status(
                    $referenceId
                );



            default:


                return [

                    "success" => false,
                    "message" => "Unsupported provider."

                ];

        }


    }



}