<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20241028074517 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add the nepting ePay payment method';
}
public function up(Schema $schema): void
{
$this->addSql("INSERT INTO `gateway_config` (`id`, `config`) VALUES (NULL, '[{\"name\": \"merchantId\", \"value\": \"string\", \"length\": 65, \"private\": true, \"is_global\": false}, {\"name\": \"merchantLabel\", \"value\": \"string\", \"length\": 120, \"private\": true, \"is_global\": false}, {\"name\": \"key\", \"value\": \"string\", \"length\": 100, \"private\": true, \"is_global\": false}, {\"name\": \"errorUrl\", \"value\": \"order/payment\", \"private\": false, \"is_global\": true}, {\"name\": \"successUrl\", \"value\": \"order/payment\", \"private\": false, \"is_global\": true}, {\"name\": \"refusedUrl\", \"value\": \"order/payment\", \"private\": false, \"is_global\": true}, {\"name\": \"cancelUrl\", \"value\": \"order/payment\", \"private\": false, \"is_global\": true}]')");
$this->addSql('INSERT INTO `payment_method_config` (`id`, `gateway_config_id`, `code`, `name`, `enabled`, `type`, `created_at`, `updated_at`) (SELECT NULL, (SELECT MAX(id) FROM gateway_config), "nepting-epay", "Nepting ePay", "1", "online", NOW(), NOW())');
}
public function down(Schema $schema): void
{
$gatewayConfigId = $this->connection->fetchOne('SELECT gateway_config_id FROM payment_method_config pmc WHERE pmc.code = "nepting-epay"');
$this->addSql('DELETE FROM `payment_method_config` WHERE code = "nepting-epay"');
$this->addSql("DELETE FROM `gateway_config` WHERE id = {$gatewayConfigId}");
}
}