main
This commit is contained in:
+166
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Pay;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str; // For UUID generation
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
|
||||
class PaymanController extends Controller
|
||||
{
|
||||
protected $accessToken = 'b71c3737-7b89-4f2c-9301-767439079407';
|
||||
|
||||
/**
|
||||
* Get access token from Payman API.
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
$response = Http::withHeaders(['Cookie' => 'cookiesession1=678A8C341A085F7AF93FECC7B44ACDFF'])
|
||||
->asForm()
|
||||
->post('https://payman2.sandbox.faraboom.co/oauth/token', [
|
||||
'Client_id' => 'demopayman',
|
||||
'Client_secret' => '!8cr?40V',
|
||||
'Grant_type' => 'client_credentials',
|
||||
]);
|
||||
|
||||
$this->accessToken = $response->json()['access_token'];
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Payman account.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$t = Uuid::uuid4()->toString();
|
||||
$response = Http::withHeaders([
|
||||
'app-key' => 'demopayman',
|
||||
'Client-Ip-Address' => '127.0.0.1',
|
||||
'Client-Platform-Type' => 'web',
|
||||
'Client-Device-Id' => '169.254.75.178',
|
||||
'Client-User-Id' => '09352673656',
|
||||
'Client-User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36',
|
||||
'Content-Type' => 'application/json',
|
||||
'Mobile-no' => '09352673656',
|
||||
'National-code' => '0082205388',
|
||||
'Authorization' => 'Bearer b71c3737-7b89-4f2c-9301-767439079407',
|
||||
'Cookie' => 'cookiesession1=678A8C341A085F7AF93FECC7B44ACDFF',
|
||||
])
|
||||
->post('https://payman2.sandbox.faraboom.co/v1/payman/create', [
|
||||
'payman' => [
|
||||
'bank_code' => 'SINAIR',
|
||||
'user_id' => 'demopayman',
|
||||
'permission_ids' => [1],
|
||||
'contract' => [
|
||||
'expiration_date' => '2026-01-15T01:28:09.5662061+04:30',
|
||||
'max_daily_transaction_count' => 50,
|
||||
'max_monthly_transaction_count' => 100,
|
||||
'max_transaction_amount' => 500000,
|
||||
],
|
||||
],
|
||||
'redirect_url' => 'http://localhost',
|
||||
'trace_id' => $t,
|
||||
]);
|
||||
// دریافت پاسخ از API
|
||||
$statusCode = $response->status(); // وضعیت HTTP
|
||||
$responseBody = $response->json(); // بدنه پاسخ به صورت JSON
|
||||
$responseHeaders = $response->headers(); // هدرهای پاسخ
|
||||
$responseBodyRaw = $response->body(); // بدنه خام پاسخ (به صورت متن)
|
||||
|
||||
// برگشت وضعیت و بدنه پاسخ
|
||||
return response()->json([
|
||||
'status' => $statusCode,
|
||||
'json' => $response->json(),
|
||||
'headers' => $response->headers(),
|
||||
'body' => $response->body(),
|
||||
]);
|
||||
$response = Http::timeout(4)->withHeaders([
|
||||
'Cookie' => 'cookiesession1=678A8C341A085F7AF93FECC7B44ACDFO',
|
||||
'app-key' => 'demopayman',
|
||||
'Client-Ip-Address' => $_SERVER['REMOTE_ADDR'],
|
||||
'Client-Platform-Type' => 'web',
|
||||
'Client-Device-Id' => '169.254.75.178',
|
||||
'Client-User-Id' => '09352673656',
|
||||
'Client-User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36',
|
||||
'Content-Type' => 'application/json',
|
||||
'Mobile-no' => '09352673656',
|
||||
'National-code' => '0082205388',
|
||||
'Authorization' => 'Bearer b71c3737-7b89-4f2c-9301-767439079407',
|
||||
])->post('https://payman2.sandbox.faraboom.co/v1/payman/create', [
|
||||
'payman' => [
|
||||
'bank_code' => 'SINAIR',
|
||||
'user_id' => 'demopayman',
|
||||
'permission_ids' => [1],
|
||||
'contract' => [
|
||||
'expiration_date' => '2026-01-15T01:28:09.5662061+04:30', // Updated expiration date
|
||||
'max_daily_transaction_count' => 50,
|
||||
'max_monthly_transaction_count' => 100,
|
||||
'max_transaction_amount' => 500000,
|
||||
'start_date' => '2025-01-15T08:28:09.5662061+04:30',
|
||||
'Daily_max_transaction_amount' => 500000000,
|
||||
]
|
||||
],
|
||||
'redirect_url' => 'https://api.gholaktala.ir/',
|
||||
'trace_id' => $t,
|
||||
]);
|
||||
|
||||
return $response->getStatusCode().$t.$response;
|
||||
/*{
|
||||
"access_token": "b71c3737-7b89-4f2c-9301-767439079407",
|
||||
"token_type": "bearer",
|
||||
"scope": "all",
|
||||
"expires_in": 28954155
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve details for a specific trace ID.
|
||||
*/
|
||||
public function createTrace()
|
||||
{
|
||||
$traceId = Str::uuid()->toString();
|
||||
|
||||
$response = Http::timeout(4)->withHeaders([
|
||||
'Cookie' => 'cookiesession1=678A8C341A085F7AF93FECC7B44ACDFO',
|
||||
'Authorization' => 'Bearer ' . $this->accessToken, // Using stored access token
|
||||
])->get('https://payman2.sandbox.faraboom.co/v1/payman/create/trace', [
|
||||
'trace_id' => $traceId,
|
||||
'redirect_url' => 'https://api.gholaktala.ir/',
|
||||
]);
|
||||
|
||||
if ($response->status() === 302) {
|
||||
$location = $response->header('Location');
|
||||
return redirect()->away($location);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'headers' => $response->headers(),
|
||||
'body' => $response->body(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Payman account ID by payman_code.
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
$url = 'https://payman2.sandbox.faraboom.co/v1/payman/getId';
|
||||
$paymanCode = '2gZ04Yx9iHEP'; // You may want to dynamically set this value
|
||||
|
||||
return $response = Http::timeout(4)
|
||||
->withHeaders([
|
||||
'Authorization' => 'Bearer ' . $this->accessToken, // Using stored access token
|
||||
'App-Key' => 'demopayman',
|
||||
'Cookie' => 'cookiesession1=678A8C341A085F7AF93FECC7B44ACDFF',
|
||||
])
|
||||
->get($url, [
|
||||
'payman_code' => $paymanCode // pass the payman_code as a query parameter
|
||||
])->json();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\pay;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Customer;
|
||||
use App\Models\User;
|
||||
use App\Models\Withdraw;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Rooyesh\Wallet\interfaces\TransactionInterface;
|
||||
use Rooyesh\Wallet\interfaces\WalletInterface;
|
||||
|
||||
class paypingController extends Controller
|
||||
{
|
||||
public function startTransation(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$finalPriseP = $request->value;
|
||||
if ($user->id ==4){
|
||||
$finalPriseP =10700;
|
||||
}
|
||||
$Withdraw = Withdraw::create([
|
||||
'customer_id' => auth('customer')->id(),
|
||||
"cash" => $finalPriseP,
|
||||
"note" => "واریز ریالی",
|
||||
'sts' => 1,
|
||||
]);
|
||||
try {
|
||||
$response = Http::withHeaders([
|
||||
'payping' => '@XOKcNveJ$wpqYy%rdpb78oBh31Aos*bIdQemiUeeq9e9G!oey23SMXp40Ew2fodjx9J5buKNW0M4@nYMr1PR6d0KtuqhLQlx*K$', // Custom header with 'payping' value
|
||||
])->post("https://payping.limangold.ir/payment/start", [
|
||||
"amount" => $finalPriseP/10, // Payment amount
|
||||
"user_name" => $user->name, // User name
|
||||
"user_id" => $user->id, // User ID
|
||||
"user" => $user, // User ID
|
||||
"title" => $this->Config('name_fa'), // Title of the payment
|
||||
"return_url" => "https://".$this->Config('app_url')."/transactions", // Callback URL
|
||||
"server_call_url" => url("/customer/charge_account_verify/".$Withdraw->id), // Callback URL
|
||||
"item" => "gp1Q", // Item identifier
|
||||
])->json();
|
||||
|
||||
}catch (\Exception $exception){
|
||||
return response()->json(["message"=>"مشکل در ارتباط با درگاه","R"=>$response??$exception,], 422);
|
||||
}
|
||||
|
||||
$Withdraw->tracked_number = $response['id'];
|
||||
$Withdraw->save();
|
||||
return $response['url'];
|
||||
return response()->json(["res"=>$response], 422);
|
||||
}
|
||||
public function verifyTransationByID(Request $request ,$id)
|
||||
{
|
||||
if ($request->header('payping') !== '@XOKcNveJ$wpqYy%rdpb78oBh31Aos*bIdQemiUeeq9e9G!oey23SMXp40Ew2fodjx9J5buKNW0M4@nYMr1PR6d0KtuqhLQlx*K$') {
|
||||
return response()->json(['auth needed'], 401);
|
||||
}
|
||||
$Withdraw = Withdraw::with('customer')->where('id',$id)->first();
|
||||
$app_url = $this->Config('app_url');
|
||||
$User = Customer::where('id', $Withdraw->customer_id)->first();
|
||||
$GTransaction = Http::withHeaders([
|
||||
'payping' => '@XOKcNveJ$wpqYy%rdpb78oBh31Aos*bIdQemiUeeq9e9G!oey23SMXp40Ew2fodjx9J5buKNW0M4@nYMr1PR6d0KtuqhLQlx*K$', // Custom header with 'payping' value
|
||||
])->post("https://payping.limangold.ir/payment/verify", [
|
||||
"id" => "$Withdraw->tracked_number",
|
||||
])->json();
|
||||
if (isset( $GTransaction['active']) and $GTransaction['active'] == 5) {
|
||||
if ($Withdraw->cash == $GTransaction['amount'] * 10) {
|
||||
$Withdraw->zify_code = $Withdraw->tracked_number;
|
||||
$Withdraw->tracked_number = $GTransaction['invoiceNo'];//ok
|
||||
$Withdraw->sts = 2;//ok
|
||||
$Withdraw->save();
|
||||
|
||||
$wallet_interface_fund = new WalletInterface($User->id, $User->type);
|
||||
$transaction = new TransactionInterface($wallet_interface_fund, $_inp = [
|
||||
"cash" => $GTransaction['amount'] * 10,
|
||||
'expire_at' => now(),
|
||||
'withdraw_id' => $Withdraw->id,
|
||||
'active' => true
|
||||
], 3, false, true);
|
||||
//----------sms
|
||||
$userMobile = $Withdraw->customer->mobile; // User's mobile number
|
||||
$userName = $Withdraw->customer->name; // User's name
|
||||
$chargedAmount = $Withdraw->cash; // Charged amount
|
||||
$companyName = $this->Config('name_fa'); // Company name from configuration
|
||||
$message = "کاربر $userName با شماره موبایل $userMobile حساب خود را به مقدار " . number_format($chargedAmount) . " ریال شارژ کرد. با تشکر، $companyName";
|
||||
User::where('send_sms', 1)->get()->each(function($admin) use ($message) {
|
||||
$this->Send($admin->mobile, $message);
|
||||
});
|
||||
return view('showTransactionReport', compact('Withdraw','app_url'));
|
||||
return redirect('https://app.gholaktala.ir/transactions');
|
||||
}
|
||||
return "مبلغ پرداختی دستکاری شده !";
|
||||
} else {
|
||||
$Withdraw->tracked_number;
|
||||
$Withdraw->sts = 3;//no
|
||||
$Withdraw->save();
|
||||
return view('showTransactionReport', compact('Withdraw','app_url'));
|
||||
}
|
||||
}
|
||||
public function verifyTransation()
|
||||
{
|
||||
$Withdraw = Withdraw::with('customer')->where('id', $_GET['clientrefid'])->first();
|
||||
$app_url = $this->Config('app_url');
|
||||
$User = Customer::where('id', $Withdraw->customer_id)->first();
|
||||
$url = 'https://zify.ir/api/order/v2/verify';
|
||||
$payload = [
|
||||
"order" => "$Withdraw->tracked_number",
|
||||
];
|
||||
$verifyResponse = Http::withToken("cf09ee0187335f173c786e7660d778d2dd71ab582d282999f751427f5923d525")
|
||||
->post($url, $payload);
|
||||
$decodedResponse = json_decode($verifyResponse, true);
|
||||
$verifyMessage = $decodedResponse['message'];
|
||||
// return $decodedResponse['data'];
|
||||
|
||||
if (isset($decodedResponse['data']['refid']) || $verifyMessage == []) {
|
||||
if ($Withdraw->cash == $decodedResponse['data']['amount'] * 10) {
|
||||
$Withdraw->zify_code = $Withdraw->tracked_number;//ok
|
||||
$Withdraw->tracked_number = $decodedResponse['data']['refid'];//ok
|
||||
$Withdraw->sts = 2;//ok
|
||||
$Withdraw->save();
|
||||
|
||||
$wallet_interface_fund = new WalletInterface($User->id, $User->type);
|
||||
$transaction = new TransactionInterface($wallet_interface_fund, $_inp = [
|
||||
"cash" => $decodedResponse['data']['amount'] * 10,
|
||||
'expire_at' => now(),
|
||||
'withdraw_id' => $_GET['clientrefid'],
|
||||
'active' => true
|
||||
], 3, false, true);
|
||||
|
||||
$User = Customer::where('id', $Withdraw->customer_id)->first();
|
||||
$url = 'https://limangold.ir/kernel/admin/fin';
|
||||
$payload = [
|
||||
"amount" => $decodedResponse['data']['amount'] * 10,
|
||||
"customer_id" => "23",
|
||||
"date_at" => \Carbon\Carbon::today()->format('Y/m/d'),
|
||||
"receive_account_number" => "000",
|
||||
"receive_bank" => "پیپینگ",
|
||||
"receive_name" => "لیمان گلد",
|
||||
"send_account_number" => "000",
|
||||
"send_bank" => " زیفای کد $Withdraw->zify_code",
|
||||
"send_name" => $User->name,
|
||||
"track_number" => $decodedResponse['data']['refid'],
|
||||
"type" => 1,
|
||||
];
|
||||
$verifyResponse = Http::withToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvbGltYW5nb2xkLmlyXC9rZXJuZWxcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNzI3NTMwNjA0LCJleHAiOjE3MzAxMjI2MDQsIm5iZiI6MTcyNzUzMDYwNCwianRpIjoiYXBINmlPZXlGTE9oTUhRdyIsInN1YiI6MiwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.IrO6icD-EXjgZ3mYyeEAP4aqG7q35yJTCU_hQhEDGwk")
|
||||
->post($url, $payload);
|
||||
//----------sms
|
||||
// User information
|
||||
$userMobile = $Withdraw->customer->mobile; // User's mobile number
|
||||
$userName = $Withdraw->customer->name; // User's name
|
||||
$chargedAmount = $Withdraw->cash; // Charged amount
|
||||
// Company name
|
||||
$companyName = $this->Config('name_fa'); // Company name from configuration
|
||||
|
||||
// Constructing the SMS message
|
||||
$message = "کاربر $userName با شماره موبایل $userMobile حساب خود را به مقدار " . number_format($chargedAmount) . " ریال شارژ کرد. با تشکر، $companyName";
|
||||
|
||||
// Getting admin mobile numbers and sending the SMS
|
||||
User::where('send_sms', 1)->get()->each(function($admin) use ($message) {
|
||||
$this->Send($admin->mobile, $message);
|
||||
});
|
||||
|
||||
|
||||
|
||||
return view('showTransactionReport', compact('Withdraw','app_url'));
|
||||
return redirect('https://app.gholaktala.ir/transactions');
|
||||
|
||||
}
|
||||
return "مبلغ پرداختی دستکاری شده !";
|
||||
} else {
|
||||
|
||||
$Withdraw->tracked_number;
|
||||
$Withdraw->sts = 3;//no
|
||||
$Withdraw->save();
|
||||
return view('showTransactionReport', compact('Withdraw','app_url'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user