File: /var/www/vhost/disk-apps/teamdemo.sports-crowd.com/app/Http/Controllers/PagopluxController.php
<?php
namespace App\Http\Controllers;
use App\Core\Order\Application\OrderService;
use App\Core\Payment\Application\PaymentTransactionService;
use App\Core\Ticket\Application\TicketService;
use App\Http\Controllers\Interfaces\PaymentGatewayControllerInterface;
use App\Http\Controllers\PaymentGatewayBridgeController;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class PagopluxController extends PaymentGatewayBridgeController implements PaymentGatewayControllerInterface
{
private $util;
private $orderService;
private $ticketService;
private $paymentTransactionService;
public function __construct()
{
$this->util = new UtilController();
$this->orderService = new OrderService();
$this->ticketService = new TicketService();
$this->paymentTransactionService = new PaymentTransactionService();
}
public function payment(Request $request)
{
// no implemented
}
public function responseTransaction(Request $request)
{
// no implemented
}
public function webhooksListener(Request $request)
{
$this->util->logFile($request);
$requestContent = json_decode($request->getContent());
$reference = $requestContent->extras;
$orderPaymentTransaction = $this->orderService->getByReference($reference);
$ticketPaymentTransaction = $this->ticketService->getByReference($reference);
$genericPaymentTransaction = $this->paymentTransactionService->getByReference($reference);
$paymentTransaction = $orderPaymentTransaction ?? $ticketPaymentTransaction ?? $genericPaymentTransaction;
if (!is_null($paymentTransaction)) {
if ($paymentTransaction === $orderPaymentTransaction) {
$this->orderService->validatePayment($paymentTransaction);
}
if ($paymentTransaction === $ticketPaymentTransaction) {
$this->ticketService->validatePayment($paymentTransaction);
}
if ($paymentTransaction === $genericPaymentTransaction) {
$this->paymentTransactionService->validatePayment($paymentTransaction);
}
}
return response('OK', Response::HTTP_OK);
}
public function getTransactionByReference(Request $request)
{
// no implemented
}
public function validatePayment($transactionId, $reference)
{
// no implemented
}
public function getAuthorizationCode($gatewayResponse)
{
return null;
}
public function getPaymentMethod($gatewayResponse){
return null;
}
}