<?php
namespace Database\Seeders\Admin;
use Exception;
use Illuminate\Database\Seeder;
use App\Models\Admin\BasicSettings;
class FreshBasicSettingsSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$data = [
'site_name' => "NFCPay",
'site_title' => "Contactless Payment System",
'base_color' => "#00B98E",
'secondary_color' => "#262626",
'otp_exp_seconds' => "3600",
'timezone' => "Asia/Dhaka",
'user_registration' => 1,
'agree_policy' => 1,
'broadcast_config' => [
"method" => "",
"app_id" => "",
"primary_key" => "",
"secret_key" => "",
"cluster" => ""
],
'push_notification_config' => [
"method" => "",
"instance_id" => "",
"primary_key" => ""
],
'kyc_verification' => true,
'mail_config' => [
"method" => "",
"host" => "",
"port" => "",
"encryption" => "",
"username" => "",
"password" => "",
"from" => "",
"mail_address" => "",
"app_name" => "",
],
'email_verification' => true,
'site_logo_dark' => "seeder/logo.png",
'site_logo' => "seeder/logo.png",
'site_fav_dark' => "seeder/favicon.png",
'site_fav' => "seeder/favicon.png",
'app_launcher_dark' => "seeder/app-launcher.png",
'app_launcher' => "seeder/app-launcher.png",
'web_version' => "1.0.0",
];
try{
$basic_data = BasicSettings::firstOrCreate($data);
$env_modify_keys = [
"MAIL_MAILER" => $basic_data->mail_config->method,
"MAIL_HOST" => $basic_data->mail_config->host,
"MAIL_PORT" => $basic_data->mail_config->port,
"MAIL_USERNAME" => $basic_data->mail_config->username,
"MAIL_PASSWORD" => $basic_data->mail_config->password,
"MAIL_ENCRYPTION" => $basic_data->mail_config->encryption,
"MAIL_FROM_ADDRESS" => $basic_data->mail_config->mail_address,
"MAIL_FROM_NAME" => $basic_data->mail_config->app_name,
"PUSHER_APP_ID" => $basic_data->broadcast_config->app_id,
"PUSHER_APP_KEY" => $basic_data->broadcast_config->primary_key,
"PUSHER_APP_SECRET" => $basic_data->broadcast_config->secret_key,
];
modifyEnv($env_modify_keys);
}catch(Exception $e){}
}
}
Initiates a new payment transaction.
create-order
| Parameter | Type | Details |
|---|---|---|
| amount | decimal | Your Amount , Must be rounded at 2 precision. |
| currency | string | Currency Code, Must be in Upper Case (Alpha-3 code) |
| success_url | string | Enter your return or success URL |
| cancel_url | string (optional) | Enter your cancel or failed URL |
Request Example (guzzle)
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', $base_url.'create-order', [
'headers' => [
'Authorization' => 'Bearer '. $authorizationToken,
'accept' => 'application/json',
'content-type' => 'application/json',
],
'form_params' => [
'amount' => '$amount',
'currency' => 'currency',
'success_url' => 'success_url',
'cancel_url' => 'cancel_url',
],
]);
echo $response->getBody();
**Response: SUCCESS (200 OK)**
{
"message": {
"success": [
"Order created successfully."
]
},
"data": {
"redirect_url":"https://example.com/login/OISADFDFSDFSF",
"order_details":{
"amount" : "10",
"fixed_charge" : 2,
"percent_charge" : 1,
"total_charge" : 3,
"total_payable" : 13,
"currency" : "USD",
"expiry_time": "2024-04-25T06:48:35.984285Z",
"success_url": "http://127.0.0.1/nfcpay/user/transaction/success",
"cancel_url": "http://127.0.0.1/nfcpay/user/transaction/cancel"
}
},
"type": "success"
}
**Response: ERROR (400 FAILED)**
{
"message": {
"error": [
"Invalid token."
]
},
"data": null,
"type": "error"
}