Feat add payment with gateway of montify
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();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user