fix some for gateway
This commit is contained in:
@@ -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(),
|
||||
]);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user