Created
June 27, 2024 14:09
-
-
Save ggrachdev/4f70a7938090c427c10f6065b427dd3d to your computer and use it in GitHub Desktop.
PaymentController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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