first commit

This commit is contained in:
2025-09-10 15:28:46 +03:30
commit 00edec179a
204 changed files with 21024 additions and 0 deletions
@@ -0,0 +1,57 @@
<?php
namespace App\Modules\Gateway\Zarinpal;
use App\Models\Product;
use App\Models\Transaction;
use Illuminate\Support\Facades\Http;
class ZarinpalApi
{
public static function getGateway(Transaction $transaction, $description)
{
$user = auth()->user();
$merchantId = config('zarinpal.merchant_id');
$response = Http::connectTimeout(2)->timeout(2)->retry(3, 500, throw: false)->post(config('zarinpal.url.request'), [
'merchant_id' => $merchantId,
'amount' => $transaction->amount * 10,
'description' => $description,
'callback_url' => 'https://payment.vada.ir/api/zarinpal/check-transaction',
'metadata' => [
'mobile' => $user->mobile
],
]);
if ($response['data'] == []) {
return ["message" => "failed", 'status' => false];
}
return [
'data' => [
'url' => config('zarinpal.url.pay') . $response['data']['authority'],
'authority' => $response['data']['authority']
],
'status' => true
];
}
public static function checkTransaction(Transaction $transaction)
{
$merchantId = config('zarinpal.merchant_id');
$response = Http::retry(3, 500, throw: false)->post(config('zarinpal.url.verify'), [
'merchant_id' => $merchantId,
'amount' => $transaction->amount * 10,
'authority' => $transaction->authority,
]);
if ($response['data'] == [] || $response['data']['code'] == 101) {
return [
'status' => false,
];
}
return [
'status' => true,
];
}
}