App\Http\Controllers\OnlinePaymentController::handlePaymentWebhook PHP Method

handlePaymentWebhook() public method

public handlePaymentWebhook ( $accountKey, $gatewayId ) : Illuminate\Http\JsonResponse
$accountKey
$gatewayId
return Illuminate\Http\JsonResponse
    public function handlePaymentWebhook($accountKey, $gatewayId)
    {
        $gatewayId = intval($gatewayId);
        $account = Account::where('accounts.account_key', '=', $accountKey)->first();
        if (!$account) {
            return response()->json(['message' => 'Unknown account'], 404);
        }
        $accountGateway = $account->getGatewayConfig(intval($gatewayId));
        if (!$accountGateway) {
            return response()->json(['message' => 'Unknown gateway'], 404);
        }
        $paymentDriver = $accountGateway->paymentDriver();
        try {
            $result = $paymentDriver->handleWebHook(Input::all());
            return response()->json(['message' => $result]);
        } catch (Exception $exception) {
            Utils::logError($exception->getMessage(), 'PHP');
            return response()->json(['message' => $exception->getMessage()], 500);
        }
    }