Merge remote-tracking branch 'origin/montify' into Abshode_Khanegi
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$now = now();
|
||||
$rows = [
|
||||
[
|
||||
'key' => 'external_payment_enabled',
|
||||
'value' => 'false',
|
||||
'title_fa' => 'شارژ آنلاین کیف پول (درگاه خارجی)',
|
||||
'type' => 'switch',
|
||||
'can_edit' => 1,
|
||||
'is_active' => 1,
|
||||
'description' => 'روشن: دکمه پرداخت آنلاین در راهنمای شارژ کیف پول نمایش داده میشود و اتصال به درگاه خارجی فعال است. خاموش: فقط واریز دستی.',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_base_url',
|
||||
'value' => '',
|
||||
'title_fa' => 'آدرس API درگاه خارجی',
|
||||
'type' => 'text',
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
'description' => 'BASE_URL سرویس Montify (بدون اسلش انتهایی)، مثلاً https://node.example.com',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_client_id',
|
||||
'value' => '',
|
||||
'title_fa' => 'شناسه کلاینت درگاه خارجی',
|
||||
'type' => 'text',
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
'description' => 'client_id دریافتی از ادمین Montify',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_client_secret',
|
||||
'value' => '',
|
||||
'title_fa' => 'رمز کلاینت درگاه خارجی',
|
||||
'type' => 'text',
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
'description' => 'client_secret دریافتی از ادمین Montify. فقط روی سرور نگه دارید؛ در فرانت استفاده نشود.',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_gateway',
|
||||
'value' => 'zarinpall',
|
||||
'title_fa' => 'نام درگاه خارجی',
|
||||
'type' => 'select',
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
'description' => 'یکی از درگاههای فعال در Montify|zarinpall,zibal,payping,sepal',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_return_url',
|
||||
'value' => '',
|
||||
'title_fa' => 'آدرس برگشت از درگاه',
|
||||
'type' => 'text',
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
'description' => 'return_url ثبتشده در whitelist پارتنر. خالی = آدرس پیشفرض سرور (/customer/wallet/external-payment/return)',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_webhook_url',
|
||||
'value' => '',
|
||||
'title_fa' => 'آدرس Webhook درگاه خارجی',
|
||||
'type' => 'text',
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
'description' => 'webhook_url برای اطلاع سرور از پرداخت موفق. خالی = آدرس پیشفرض سرور (/customer/wallet/external-payment/webhook)',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if (DB::table('settings')->where('key', $row['key'])->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DB::table('settings')->insert(array_merge($row, [
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('settings')->whereIn('key', [
|
||||
'external_payment_enabled',
|
||||
'external_payment_base_url',
|
||||
'external_payment_client_id',
|
||||
'external_payment_client_secret',
|
||||
'external_payment_gateway',
|
||||
'external_payment_return_url',
|
||||
'external_payment_webhook_url',
|
||||
])->delete();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! DB::table('settings')->where('key', 'wallet_payment_provider')->exists()) {
|
||||
$legacyEnabled = DB::table('settings')
|
||||
->where('key', 'external_payment_enabled')
|
||||
->value('value');
|
||||
$default = filter_var((string) $legacyEnabled, FILTER_VALIDATE_BOOLEAN) ? 'montify' : 'none';
|
||||
|
||||
DB::table('settings')->insert([
|
||||
'key' => 'wallet_payment_provider',
|
||||
'value' => $default,
|
||||
'title_fa' => 'درگاه شارژ آنلاین کیف پول',
|
||||
'type' => 'select',
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
'description' => 'انتخاب درگاه فعال برای شارژ آنلاین. none=غیرفعال، montify=پارتنر Montify. درگاههای مستقیم بعدی اینجا اضافه میشوند.|none,montify',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('settings')->where('key', 'wallet_payment_provider')->delete();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* کلیدهای درگاه را در پنل تنظیمات عادی قابل ویرایش میکند
|
||||
* و در صورت نبود، ردیفها را میسازد.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$now = now();
|
||||
$rows = [
|
||||
[
|
||||
'key' => 'wallet_payment_provider',
|
||||
'value' => 'none',
|
||||
'title_fa' => 'نوع درگاه شارژ آنلاین',
|
||||
'type' => 'select',
|
||||
'description' => 'none=خاموش، montify=پارتنر Montify|none,montify',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_enabled',
|
||||
'value' => 'false',
|
||||
'title_fa' => 'فعالسازی شارژ آنلاین',
|
||||
'type' => 'switch',
|
||||
'description' => 'روشن: در صورت پیکربندی کامل، دکمه پرداخت آنلاین در اپ نمایش داده میشود. خاموش: فقط واریز دستی.',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_base_url',
|
||||
'value' => '',
|
||||
'title_fa' => 'آدرس API درگاه (BASE_URL)',
|
||||
'type' => 'text',
|
||||
'description' => 'آدرس پایه API Montify بدون اسلش انتهایی، مثلاً https://node.example.com',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_client_id',
|
||||
'value' => '',
|
||||
'title_fa' => 'شناسه کلاینت (client_id)',
|
||||
'type' => 'text',
|
||||
'description' => 'client_id دریافتی از ادمین Montify',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_client_secret',
|
||||
'value' => '',
|
||||
'title_fa' => 'رمز کلاینت (client_secret)',
|
||||
'type' => 'text',
|
||||
'description' => 'client_secret دریافتی از ادمین Montify — فقط روی سرور بماند',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_gateway',
|
||||
'value' => 'zarinpall',
|
||||
'title_fa' => 'نام درگاه داخل Montify',
|
||||
'type' => 'select',
|
||||
'description' => 'یکی از درگاههای فعال در Montify|zarinpall,zibal,payping,sepal',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_return_url',
|
||||
'value' => '',
|
||||
'title_fa' => 'آدرس برگشت (return_url)',
|
||||
'type' => 'text',
|
||||
'description' => 'اختیاری. خالی = پیشفرض سرور /customer/wallet/payment/return/montify',
|
||||
],
|
||||
[
|
||||
'key' => 'external_payment_webhook_url',
|
||||
'value' => '',
|
||||
'title_fa' => 'آدرس Webhook',
|
||||
'type' => 'text',
|
||||
'description' => 'اختیاری. خالی = پیشفرض سرور /customer/wallet/payment/webhook/montify',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$existing = DB::table('settings')->where('key', $row['key'])->first();
|
||||
if ($existing) {
|
||||
DB::table('settings')->where('key', $row['key'])->update([
|
||||
'can_edit' => 1,
|
||||
'is_active' => 1,
|
||||
'title_fa' => $row['title_fa'],
|
||||
'type' => $row['type'],
|
||||
'description' => $row['description'],
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
|
||||
DB::table('settings')->insert([
|
||||
'key' => $row['key'],
|
||||
'value' => $row['value'],
|
||||
'title_fa' => $row['title_fa'],
|
||||
'type' => $row['type'],
|
||||
'can_edit' => 1,
|
||||
'is_active' => 1,
|
||||
'description' => $row['description'],
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('settings')->whereIn('key', [
|
||||
'wallet_payment_provider',
|
||||
'external_payment_base_url',
|
||||
'external_payment_client_id',
|
||||
'external_payment_client_secret',
|
||||
'external_payment_gateway',
|
||||
'external_payment_return_url',
|
||||
'external_payment_webhook_url',
|
||||
])->update([
|
||||
'can_edit' => 0,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* session_id مونتیفای ~۶۴ کاراکتر است؛ tracked_number قبلاً کوتاه بود (مثلاً varchar(50)).
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('withdraws') || ! Schema::hasColumn('withdraws', 'tracked_number')) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::statement('ALTER TABLE `withdraws` MODIFY `tracked_number` VARCHAR(191) NULL');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('withdraws') || ! Schema::hasColumn('withdraws', 'tracked_number')) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::statement('ALTER TABLE `withdraws` MODIFY `tracked_number` VARCHAR(50) NULL');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user