Skip to content

Instantly share code, notes, and snippets.

@ggrachdev
Created June 27, 2024 14:09
Show Gist options
  • Save ggrachdev/4f70a7938090c427c10f6065b427dd3d to your computer and use it in GitHub Desktop.
Save ggrachdev/4f70a7938090c427c10f6065b427dd3d to your computer and use it in GitHub Desktop.
PaymentController.php
<?php
use App\Integration\AcquiringIntegrationService;
use App\Integration\PaymentDTO;
use App\User\User;
use App\Statistics\CountService;
use App\Contracts\PaymentInterface;
namespace App/Controller/Payment;
class PaymentController extends PaymentInterface
{
public function Go($paymentId, long $sum, $date): void
{
$acquiringIntegration = new AcquiringIntegrationService();
$countService = new CountService();
$countService->increase(1);
$userId = $_GET['userId'];
// Проверяем существование юзера
$stmt = $pdo->query("SELECT * FROM users WHERE id = " . $userId);
$user = new User($stmt->fetch()->id);
$payment = new PaymentDTO();
$payment->id = $paymentId;
$payment->sum = $sum;
$payment->date = $date;
$payment->userId = $userId;
// удалось — массив. Не удалось — эксепшен
$result = $acquiringIntegration->getPayService()->pay($payment);
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment