<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class PaymentGatewayCallbackController extends Controller
{
    public function successCallback($method)
    { 
        $classMap = config('paymentGateway.'.$method);
        if (!$classMap || !class_exists($classMap)) {
            Log::warning('Unknown payment gateway success callback.', ['gateway' => $method]);
            abort(404);
        }
        $new_payment = new $classMap();
        return $new_payment->successCallback();
    }

    public function cancelCallback($method){

        $classMap = config('paymentGateway.'.$method);
        if (!$classMap || !class_exists($classMap)) {
            Log::warning('Unknown payment gateway cancel callback.', ['gateway' => $method]);
            abort(404);
        }

        $new_payment = new $classMap();
        return $new_payment->cancelCallBack();
    }
}
