- Refactor PaymentController to delegate payment processing to PaymentManager. - Add findByOrderIdForUpdate method in PaymentRepository for pessimistic locking. - Create PaymentLog entity and repository for auditing payment actions. - Implement startGatewayHandoff and processCallback methods in PaymentManager. - Introduce transaction handling and logging for payment verification. - Update payment flow to ensure idempotency and prevent race conditions. - Enhance security by logging sensitive actions without exposing credentials. - Update database schema with migration for payment_logs table. - Document changes in payment flow architecture.
30 lines
962 B
PHP
30 lines
962 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Auto-generated Migration: Please modify to your needs!
|
|
*/
|
|
final class Version20260702115209 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Create payment_logs audit table';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('CREATE TABLE payment_logs (id INT AUTO_INCREMENT NOT NULL, payment_id INT NOT NULL, action VARCHAR(20) NOT NULL, gateway VARCHAR(20) NOT NULL, result VARCHAR(20) NOT NULL, authority VARCHAR(255) DEFAULT NULL, client_ip VARCHAR(45) DEFAULT NULL, payload JSON DEFAULT NULL, created_at INT NOT NULL, INDEX idx_payment_logs_payment (payment_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('DROP TABLE payment_logs');
|
|
}
|
|
}
|