@@ -16,32 +16,32 @@ |
||
16 | 16 | */ |
17 | 17 | class getUpdates extends receiver { |
18 | 18 | #[NoReturn] |
19 | - public static function init () { |
|
19 | + public static function init() { |
|
20 | 20 | $last_update_id = self::loadData(); |
21 | 21 | lock::set('getUpdateHook'); |
22 | - while(true) { |
|
22 | + while (true) { |
|
23 | 23 | if (!lock::exist('getUpdateHook')) { |
24 | - logger::write('getUpdateHook deleted, loop ended.',loggerTypes::INFO); |
|
24 | + logger::write('getUpdateHook deleted, loop ended.', loggerTypes::INFO); |
|
25 | 25 | break; |
26 | 26 | } |
27 | - $updates = telegram::getUpdates($last_update_id,allowed_updates: settings::$allowed_updates); |
|
27 | + $updates = telegram::getUpdates($last_update_id, allowed_updates: settings::$allowed_updates); |
|
28 | 28 | if (!telegram::$status) { |
29 | - logger::write("There is some problem happened , telegram response : \n".json_encode($updates),loggerTypes::ERROR); |
|
30 | - BPT::exit(print_r($updates,true)); |
|
29 | + logger::write("There is some problem happened , telegram response : \n".json_encode($updates), loggerTypes::ERROR); |
|
30 | + BPT::exit(print_r($updates, true)); |
|
31 | 31 | } |
32 | 32 | self::handleUpdates($updates); |
33 | - $last_update_id = BPT::$update->update_id+1; |
|
34 | - lock::save('getUpdate',$last_update_id); |
|
33 | + $last_update_id = BPT::$update->update_id + 1; |
|
34 | + lock::save('getUpdate', $last_update_id); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | - private static function loadData(): bool|int|string { |
|
38 | + private static function loadData(): bool | int | string { |
|
39 | 39 | if (lock::exist('getUpdate')) { |
40 | 40 | return lock::read('getUpdate'); |
41 | 41 | } |
42 | 42 | self::deleteOldLocks(); |
43 | 43 | telegram::deleteWebhook(); |
44 | - lock::save('getUpdate',0); |
|
44 | + lock::save('getUpdate', 0); |
|
45 | 45 | return 0; |
46 | 46 | } |
47 | 47 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | private static CurlHandle $session; |
26 | 26 | |
27 | - public static function init (string $merchant_id = '', bool $sandbox = false, bool $zarin_gate = false): void { |
|
27 | + public static function init(string $merchant_id = '', bool $sandbox = false, bool $zarin_gate = false): void { |
|
28 | 28 | self::$sandbox = $sandbox; |
29 | 29 | self::$zarin_gate = $zarin_gate; |
30 | 30 | self::$merchant_id = $merchant_id; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | curl_setopt(self::$session, CURLOPT_POST, true); |
40 | 40 | } |
41 | 41 | |
42 | - private static function getUrl (string $endpoint, bool $pay = false): string { |
|
42 | + private static function getUrl(string $endpoint, bool $pay = false): string { |
|
43 | 43 | if ($pay) { |
44 | 44 | $url = self::$sandbox ? self::SANDBOX_PAY_BASE : self::PAY_BASE; |
45 | 45 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | return $url; |
54 | 54 | } |
55 | 55 | |
56 | - private static function execute (string $endpoint, array $params = []): object { |
|
56 | + private static function execute(string $endpoint, array $params = []): object { |
|
57 | 57 | foreach ($params as $key => $value) { |
58 | 58 | if (empty($value)) { |
59 | 59 | unset($params[$key]); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | /** |
88 | 88 | * @return object|requestInterface |
89 | 89 | */ |
90 | - public static function request (int $amount, string $description, string $callback_url, array $metadata = [], string $mobile = '', string $email = '', array $wages = [], int $card_pan = null, string $currency = ''): object { |
|
90 | + public static function request(int $amount, string $description, string $callback_url, array $metadata = [], string $mobile = '', string $email = '', array $wages = [], int $card_pan = null, string $currency = ''): object { |
|
91 | 91 | return self::execute('/request.json', [ |
92 | 92 | 'amount' => $amount, |
93 | 93 | 'description' => $description, |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | ]); |
102 | 102 | } |
103 | 103 | |
104 | - public static function payURL (string|array $authority): bool|string { |
|
104 | + public static function payURL(string | array $authority): bool | string { |
|
105 | 105 | if (is_array($authority)) { |
106 | 106 | if (!isset($authority->authority)) { |
107 | 107 | return false; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * @return object|verifyInterface |
116 | 116 | */ |
117 | - public static function verify (int $amount, string $authority): object { |
|
117 | + public static function verify(int $amount, string $authority): object { |
|
118 | 118 | return self::execute('/verify.json', [ |
119 | 119 | 'amount' => $amount, |
120 | 120 | 'authority' => $authority |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * @return object|unverifiedInterface |
126 | 126 | */ |
127 | - public static function unVerified (): object { |
|
127 | + public static function unVerified(): object { |
|
128 | 128 | return self::execute('/unVerified.json'); |
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | 132 | * @return object|refundInterface |
133 | 133 | */ |
134 | - public static function refund (string $authorization, string $authority): object { |
|
134 | + public static function refund(string $authorization, string $authority): object { |
|
135 | 135 | return self::execute('/refund.json', [ |
136 | 136 | 'authorization' => $authorization, |
137 | 137 | 'authority' => $authority |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | #[NoReturn] |
142 | - public static function redirect (string $url): void { |
|
143 | - @header('Location: ' . $url); |
|
142 | + public static function redirect(string $url): void { |
|
143 | + @header('Location: '.$url); |
|
144 | 144 | die("<meta http-equiv='refresh' content='0; url=$url' /><script>window.location.href = '$url';</script>"); |
145 | 145 | } |
146 | 146 | |
147 | - public static function processCallback (int $amount): object|bool|int { |
|
147 | + public static function processCallback(int $amount): object | bool | int { |
|
148 | 148 | if (!isset($_GET['Authority']) || !isset($_GET['Status'])) { |
149 | 149 | return false; |
150 | 150 | } |
@@ -13,20 +13,20 @@ discard block |
||
13 | 13 | |
14 | 14 | private static CurlHandle $session; |
15 | 15 | |
16 | - public static function init (string $api_key = '', bool $sandbox = false): void { |
|
16 | + public static function init(string $api_key = '', bool $sandbox = false): void { |
|
17 | 17 | self::$session = curl_init(); |
18 | 18 | curl_setopt(self::$session, CURLOPT_RETURNTRANSFER, true); |
19 | 19 | curl_setopt(self::$session, CURLOPT_SSL_VERIFYPEER, 1); |
20 | 20 | curl_setopt(self::$session, CURLOPT_SSL_VERIFYHOST, 2); |
21 | 21 | curl_setopt(self::$session, CURLOPT_HTTPHEADER, [ |
22 | 22 | 'Content-Type: application/json', |
23 | - 'X-API-KEY: ' . $api_key, |
|
24 | - 'X-SANDBOX: ' . (int) ($sandbox), |
|
23 | + 'X-API-KEY: '.$api_key, |
|
24 | + 'X-SANDBOX: '.(int) ($sandbox), |
|
25 | 25 | ]); |
26 | 26 | curl_setopt(self::$session, CURLOPT_POST, true); |
27 | 27 | } |
28 | 28 | |
29 | - private static function execute (string $endpoint, array $params) { |
|
29 | + private static function execute(string $endpoint, array $params) { |
|
30 | 30 | foreach ($params as $key => $value) { |
31 | 31 | if (empty($value)) { |
32 | 32 | unset($params[$key]); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $session = self::$session; |
37 | 37 | |
38 | 38 | curl_setopt($session, CURLOPT_POSTFIELDS, json_encode($params)); |
39 | - curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint); |
|
39 | + curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint); |
|
40 | 40 | |
41 | 41 | return json_decode(curl_exec($session)); |
42 | 42 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * @return paymentCreateInterface|errorInterface|object|bool |
46 | 46 | */ |
47 | - public static function createPayment (string $order_id, int $amount, string $name = '', string $phone = '', string $mail = '', string $desc = '', string $callback = ''): object|bool { |
|
47 | + public static function createPayment(string $order_id, int $amount, string $name = '', string $phone = '', string $mail = '', string $desc = '', string $callback = ''): object | bool { |
|
48 | 48 | return self::execute('payment', [ |
49 | 49 | 'order_id' => $order_id, |
50 | 50 | 'amount' => $amount, |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * @return paymentInterface|errorInterface|object|bool |
61 | 61 | */ |
62 | - public static function paymentDetail (string $id, string $order_id): object { |
|
62 | + public static function paymentDetail(string $id, string $order_id): object { |
|
63 | 63 | return self::execute('payment/inquiry', [ |
64 | 64 | 'order_id' => $order_id, |
65 | 65 | 'id' => $id |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * @return paymentInterface|errorInterface|object|bool |
71 | 71 | */ |
72 | - public static function paymentConfirm (string $id, string $order_id): object { |
|
72 | + public static function paymentConfirm(string $id, string $order_id): object { |
|
73 | 73 | return self::execute('payment/verify', [ |
74 | 74 | 'order_id' => $order_id, |
75 | 75 | 'id' => $id |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * @return paymentListInterface|errorInterface|object|bool |
81 | 81 | */ |
82 | - public static function paymentList (int $page = 0, int $page_size = 25): object { |
|
82 | + public static function paymentList(int $page = 0, int $page_size = 25): object { |
|
83 | 83 | return self::execute('payment/transactions', [ |
84 | 84 | 'page' => $page, |
85 | 85 | 'page_size' => $page_size |
86 | 86 | ]); |
87 | 87 | } |
88 | 88 | |
89 | - public static function processCallback (): bool|int { |
|
89 | + public static function processCallback(): bool | int { |
|
90 | 90 | if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
91 | 91 | $response = $_POST; |
92 | 92 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | private static CurlHandle $session; |
37 | 37 | |
38 | - public static function init (string $api_key = '', string $ipn_secret = '', int $round_decimal = 4): void { |
|
38 | + public static function init(string $api_key = '', string $ipn_secret = '', int $round_decimal = 4): void { |
|
39 | 39 | self::$ipn_secret = $ipn_secret; |
40 | 40 | self::$round_decimal = $round_decimal; |
41 | 41 | self::$session = curl_init(); |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | curl_setopt(self::$session, CURLOPT_SSL_VERIFYPEER, 1); |
44 | 44 | curl_setopt(self::$session, CURLOPT_SSL_VERIFYHOST, 2); |
45 | 45 | curl_setopt(self::$session, CURLOPT_HTTPHEADER, [ |
46 | - 'X-API-KEY: ' . $api_key, |
|
46 | + 'X-API-KEY: '.$api_key, |
|
47 | 47 | 'Content-Type: application/json' |
48 | 48 | ]); |
49 | 49 | } |
50 | 50 | |
51 | - private static function execute (string $method, string $endpoint, string|array $data = '') { |
|
51 | + private static function execute(string $method, string $endpoint, string | array $data = '') { |
|
52 | 52 | if (is_array($data)) { |
53 | 53 | foreach ($data as $key => $value) { |
54 | 54 | if (empty($value)) { |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | |
62 | 62 | switch ($method) { |
63 | 63 | case 'GET': |
64 | - curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint . (!empty($data) && is_array($data) ? ('?' . http_build_query($data)) : '')); |
|
64 | + curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint.(!empty($data) && is_array($data) ? ('?'.http_build_query($data)) : '')); |
|
65 | 65 | break; |
66 | 66 | case 'POST': |
67 | 67 | curl_setopt($session, CURLOPT_POST, true); |
68 | 68 | curl_setopt($session, CURLOPT_POSTFIELDS, json_encode($data)); |
69 | - curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint); |
|
69 | + curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint); |
|
70 | 70 | break; |
71 | 71 | default: |
72 | 72 | return false; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * This is a method to get information about the current state of the API. Receive true if its ok and false in otherwise |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public static function status (): bool { |
|
81 | + public static function status(): bool { |
|
82 | 82 | return self::execute('GET', 'status')->message === 'OK'; |
83 | 83 | } |
84 | 84 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return estimatePriceInterface|errorResponseInterface|mixed |
95 | 95 | */ |
96 | - public static function getEstimatePrice (int|float $amount, string $currency_from, string $currency_to) { |
|
96 | + public static function getEstimatePrice(int | float $amount, string $currency_from, string $currency_to) { |
|
97 | 97 | return self::execute('GET', 'estimate', [ |
98 | 98 | 'amount' => $amount, |
99 | 99 | 'currency_from' => $currency_from, |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return invoicePaymentInterface|errorResponseInterface|mixed |
122 | 122 | */ |
123 | - public static function createPayment (int|float $price_amount, string $price_currency, string $pay_currency, int|float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $purchase_id = null, string $payout_address = null, string $payout_currency = null, string $payout_extra_id = null, bool $fixed_rate = null, bool $is_fee_paid_by_user = null) { |
|
123 | + public static function createPayment(int | float $price_amount, string $price_currency, string $pay_currency, int | float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $purchase_id = null, string $payout_address = null, string $payout_currency = null, string $payout_extra_id = null, bool $fixed_rate = null, bool $is_fee_paid_by_user = null) { |
|
124 | 124 | return self::execute('POST', 'payment', [ |
125 | 125 | 'price_amount' => $price_amount, |
126 | 126 | 'price_currency' => $price_currency, |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return invoicePaymentInterface|errorResponseInterface|mixed |
154 | 154 | */ |
155 | - public static function createInvoicePayment (string $iid, string $pay_currency, string $purchase_id = null, string $order_description = null, string $customer_email = null, string $payout_address = null, string $payout_extra_id = null, string $payout_currency = null) { |
|
155 | + public static function createInvoicePayment(string $iid, string $pay_currency, string $purchase_id = null, string $order_description = null, string $customer_email = null, string $payout_address = null, string $payout_extra_id = null, string $payout_currency = null) { |
|
156 | 156 | return self::execute('POST', 'invoice-payment', [ |
157 | 157 | 'iid' => $iid, |
158 | 158 | 'pay_currency' => $pay_currency, |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return estimateUpdateInterface|errorResponseInterface|mixed |
175 | 175 | */ |
176 | - public static function updateEstimatePrice (int $paymentID) { |
|
177 | - return self::execute('POST', 'payment/' . $paymentID . '/update-merchant-estimate'); |
|
176 | + public static function updateEstimatePrice(int $paymentID) { |
|
177 | + return self::execute('POST', 'payment/'.$paymentID.'/update-merchant-estimate'); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @return paymentInterface|errorResponseInterface|mixed |
186 | 186 | */ |
187 | - public static function getPaymentStatus (int $paymentID) { |
|
188 | - return self::execute('GET', 'payment/' . $paymentID); |
|
187 | + public static function getPaymentStatus(int $paymentID) { |
|
188 | + return self::execute('GET', 'payment/'.$paymentID); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return float |
198 | 198 | */ |
199 | - public static function getMinimumPaymentAmount (string $currency_from, string $currency_to): float { |
|
199 | + public static function getMinimumPaymentAmount(string $currency_from, string $currency_to): float { |
|
200 | 200 | return self::execute('GET', 'min-amount', [ |
201 | 201 | 'currency_from' => $currency_from, |
202 | 202 | 'currency_to' => $currency_to |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return invoiceResponseInterface|errorResponseInterface|mixed |
219 | 219 | */ |
220 | - public static function createInvoice (int|float $price_amount, string $price_currency, string $pay_currency = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $success_url = null, string $cancel_url = null) { |
|
220 | + public static function createInvoice(int | float $price_amount, string $price_currency, string $pay_currency = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $success_url = null, string $cancel_url = null) { |
|
221 | 221 | return self::execute('POST', 'invoice', [ |
222 | 222 | 'price_amount' => $price_amount, |
223 | 223 | 'price_currency' => $price_currency, |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return array |
237 | 237 | */ |
238 | - public static function getCurrencies (): array { |
|
238 | + public static function getCurrencies(): array { |
|
239 | 239 | return self::execute('GET', 'currencies')->currencies; |
240 | 240 | } |
241 | 241 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return array |
246 | 246 | */ |
247 | - public static function getFullCurrencies (): array { |
|
247 | + public static function getFullCurrencies(): array { |
|
248 | 248 | return self::execute('GET', 'full-currencies')->currencies; |
249 | 249 | } |
250 | 250 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return array |
256 | 256 | */ |
257 | - public static function getAvailableCheckedCurrencies (): array { |
|
257 | + public static function getAvailableCheckedCurrencies(): array { |
|
258 | 258 | return self::execute('GET', 'merchant/coins')->currencies; |
259 | 259 | } |
260 | 260 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return bool |
274 | 274 | */ |
275 | - public static function isIPNRequestValid (): bool { |
|
275 | + public static function isIPNRequestValid(): bool { |
|
276 | 276 | if (empty($_SERVER['HTTP_X_NOWPAYMENTS_SIG'])) { |
277 | 277 | return false; |
278 | 278 | } |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return ipnDataInterface|mixed |
296 | 296 | */ |
297 | - public static function getIPN () { |
|
297 | + public static function getIPN() { |
|
298 | 298 | if (!self::isIPNRequestValid()) { |
299 | 299 | return false; |
300 | 300 | } |
301 | 301 | return json_decode(file_get_contents('php://input')); |
302 | 302 | } |
303 | 303 | |
304 | - protected static function createOrder (float|int $amount, int $user_id, string $description): int|string { |
|
304 | + protected static function createOrder(float | int $amount, int $user_id, string $description): int | string { |
|
305 | 305 | if (!mysql::getMysqli()) { |
306 | 306 | logger::write("crypto::ezPay function used\ncreating order needed mysql connection in our mysql class", loggerTypes::ERROR); |
307 | 307 | throw new bptException('MYSQL_CONNECTION_NEEDED'); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | return mysql::insertId(); |
313 | 313 | } |
314 | 314 | |
315 | - protected static function getOrder (int $order_id): bool|object { |
|
315 | + protected static function getOrder(int $order_id): bool | object { |
|
316 | 316 | if (!mysql::getMysqli()) { |
317 | 317 | logger::write("crypto::ezPay function used\ncreating order needed mysql connection in our mysql class", loggerTypes::ERROR); |
318 | 318 | throw new bptException('MYSQL_CONNECTION_NEEDED'); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @return bool|string |
344 | 344 | * @throws bptException |
345 | 345 | */ |
346 | - public static function ezPay (float|int $amount, int $user_id = null, string $currency = 'usd', string $description = 'Invoice created by BPT library', bool $direct_url = false, bool $one_time_url = true): bool|string { |
|
346 | + public static function ezPay(float | int $amount, int $user_id = null, string $currency = 'usd', string $description = 'Invoice created by BPT library', bool $direct_url = false, bool $one_time_url = true): bool | string { |
|
347 | 347 | if (empty(self::$ipn_secret)) { |
348 | 348 | logger::write("crypto::ezPay function used\nyou must set ipn_secret to use this", loggerTypes::ERROR); |
349 | 349 | return false; |
@@ -355,10 +355,10 @@ discard block |
||
355 | 355 | $user_id = $user_id ?? request::catchFields(fields::USER_ID); |
356 | 356 | $order_id = self::createOrder($amount, $user_id, $description); |
357 | 357 | $data = ['type' => callbackTypes::CRYPTO, 'action_type' => cryptoCallbackActionTypes::CALLBACK, 'amount' => $amount, 'currency' => $currency, 'user_id' => $user_id, 'order_id' => $order_id]; |
358 | - $callback_url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '?data='.urlencode(callback::encodeData($data)); |
|
358 | + $callback_url = 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'?data='.urlencode(callback::encodeData($data)); |
|
359 | 359 | |
360 | 360 | $data = ['type' => callbackTypes::CRYPTO, 'action_type' => cryptoCallbackActionTypes::SUCCESS, 'amount' => $amount, 'currency' => $currency, 'user_id' => $user_id, 'order_id' => $order_id]; |
361 | - $success_url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '?data='.urlencode(callback::encodeData($data)); |
|
361 | + $success_url = 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'?data='.urlencode(callback::encodeData($data)); |
|
362 | 362 | |
363 | 363 | $invoice_id = self::createInvoice($amount, $currency, null, $callback_url, $order_id, $description, $success_url)->id; |
364 | 364 | |
@@ -377,17 +377,17 @@ discard block |
||
377 | 377 | ], ['id' => $order_id], 1); |
378 | 378 | |
379 | 379 | if ($direct_url) { |
380 | - return 'https://nowpayments.io/payment/?iid='. $invoice_id; |
|
380 | + return 'https://nowpayments.io/payment/?iid='.$invoice_id; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | $data = ['type' => callbackTypes::CRYPTO, 'action_type' => cryptoCallbackActionTypes::REDIRECT, 'amount' => $amount, 'currency' => $currency, 'user_id' => $user_id, 'order_id' => $order_id]; |
384 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '?data='.urlencode(callback::encodeData($data)); |
|
384 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'?data='.urlencode(callback::encodeData($data)); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
388 | 388 | * @internal Only for BPT self usage , Don't use it in your source! |
389 | 389 | */ |
390 | - public static function callbackProcess (array $data) { |
|
390 | + public static function callbackProcess(array $data) { |
|
391 | 391 | if (!isset($data['action_type'])) { |
392 | 392 | return false; |
393 | 393 | } |
@@ -407,16 +407,16 @@ discard block |
||
407 | 407 | BPT::exit('This link is one time only, Receive another link'); |
408 | 408 | } |
409 | 409 | } |
410 | - $url = 'https://nowpayments.io/payment/?iid='. $extra_info->invoice_id; |
|
410 | + $url = 'https://nowpayments.io/payment/?iid='.$extra_info->invoice_id; |
|
411 | 411 | |
412 | - @header('Location: ' . $url); |
|
412 | + @header('Location: '.$url); |
|
413 | 413 | die("<meta http-equiv='refresh' content='0; url=$url' /><script>window.location.href = '$url';</script>"); |
414 | 414 | } |
415 | 415 | |
416 | 416 | if ($action_type === cryptoCallbackActionTypes::CALLBACK) { |
417 | 417 | $ipn = self::getIPN(); |
418 | 418 | |
419 | - if ($ipn->payment_status !== cryptoStatus::FINISHED && $ipn->payment_status !== cryptoStatus::PARTIALLY_PAID ) { |
|
419 | + if ($ipn->payment_status !== cryptoStatus::FINISHED && $ipn->payment_status !== cryptoStatus::PARTIALLY_PAID) { |
|
420 | 420 | die(); |
421 | 421 | } |
422 | 422 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | die(); |
439 | 439 | } |
440 | 440 | |
441 | - $paid = round(isset($payment->actually_paid_at_fiat) && $payment->actually_paid_at_fiat > 0 ? $payment->actually_paid_at_fiat : $payment->actually_paid/$payment->pay_amount*$payment->price_amount, self::$round_decimal); |
|
441 | + $paid = round(isset($payment->actually_paid_at_fiat) && $payment->actually_paid_at_fiat > 0 ? $payment->actually_paid_at_fiat : $payment->actually_paid / $payment->pay_amount * $payment->price_amount, self::$round_decimal); |
|
442 | 442 | $extra_info['related_payments'][$payment_id] = $paid; |
443 | 443 | $extra_info['total_paid'] += $paid; |
444 | 444 | mysql::update('orders', ['extra_info' => json_encode($extra_info)], ['id' => $order_id], 1); |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | 'description' => $order->description, |
501 | 501 | 'real_amount' => $order->amount, |
502 | 502 | 'currency' => $extra_info->currency, |
503 | - 'paid_amount' => round(isset($payment->actually_paid_at_fiat) && $payment->actually_paid_at_fiat > 0 ? $payment->actually_paid_at_fiat : $payment->actually_paid/$payment->pay_amount*$payment->price_amount, self::$round_decimal), |
|
503 | + 'paid_amount' => round(isset($payment->actually_paid_at_fiat) && $payment->actually_paid_at_fiat > 0 ? $payment->actually_paid_at_fiat : $payment->actually_paid / $payment->pay_amount * $payment->price_amount, self::$round_decimal), |
|
504 | 504 | 'total_paid' => $extra_info->total_paid |
505 | 505 | ]; |
506 | 506 | $callback_data = object(...$callback_data); |
@@ -5,7 +5,7 @@ |
||
5 | 5 | use BPT\settings; |
6 | 6 | |
7 | 7 | class pay { |
8 | - public static function init (): void { |
|
8 | + public static function init(): void { |
|
9 | 9 | if (isset(settings::$pay['crypto'])) { |
10 | 10 | $settings = [ |
11 | 11 | 'api_key' => settings::$pay['crypto']['api_key'] ?? null, |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
19 | 19 | */ |
20 | - public static function init (string $bot_name, int $log_size = 10): void { |
|
20 | + public static function init(string $bot_name, int $log_size = 10): void { |
|
21 | 21 | self::$log_size = $log_size; |
22 | 22 | $log_file = realpath($bot_name.'BPT.log'); |
23 | 23 | $mode = file_exists($log_file) && self::$log_size * 1024 * 1024 > filesize($log_file) ? 'a' : 'w'; |
24 | 24 | self::$handler = fopen($bot_name.'BPT.log', $mode); |
25 | 25 | if ($mode === 'w') { |
26 | - fwrite(self::$handler,"♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
26 | + fwrite(self::$handler, "♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
27 | 27 | } |
28 | 28 | if (self::$waited_logs != []) { |
29 | 29 | foreach (self::$waited_logs as $log) { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return void |
44 | 44 | */ |
45 | 45 | public static function write(string $data, string $type = loggerTypes::NONE): void { |
46 | - $text = date('Y/m/d H:i:s') . ($type !== loggerTypes::NONE ? " : ⤵\n$type" : '') . " : $data\n\n"; |
|
46 | + $text = date('Y/m/d H:i:s').($type !== loggerTypes::NONE ? " : ⤵\n$type" : '')." : $data\n\n"; |
|
47 | 47 | if (!is_null(self::$handler)) { |
48 | 48 | fwrite(self::$handler, $text); |
49 | 49 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public array $user_ids; |
28 | 28 | |
29 | 29 | |
30 | - public function __construct(stdClass|null $object = null) { |
|
30 | + public function __construct(stdClass | null $object = null) { |
|
31 | 31 | if ($object != null) { |
32 | 32 | parent::__construct($object, self::subs); |
33 | 33 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param bool|null $answer |
40 | 40 | */ |
41 | - public function getInfo (bool $answer = null): array { |
|
41 | + public function getInfo(bool $answer = null): array { |
|
42 | 42 | $result = []; |
43 | 43 | foreach ($this->user_ids as $user_id) { |
44 | 44 | $result[$user_id] = telegram::getChat($user_id, answer: $answer); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * spoiler, and custom_emoji entities are kept in quotes. |
20 | 20 | * @var messageEntity[] |
21 | 21 | */ |
22 | - public null|array $entities = null; |
|
22 | + public null | array $entities = null; |
|
23 | 23 | |
24 | 24 | /** Approximate quote position in the original message in UTF-16 code units as specified by the sender */ |
25 | 25 | public int $position; |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | * Optional. True, if the quote was chosen manually by the message sender. Otherwise, the quote was added |
29 | 29 | * automatically by the server. |
30 | 30 | */ |
31 | - public null|bool $is_manual = null; |
|
31 | + public null | bool $is_manual = null; |
|
32 | 32 | |
33 | 33 | |
34 | - public function __construct(stdClass|null $object = null) { |
|
34 | + public function __construct(stdClass | null $object = null) { |
|
35 | 35 | if ($object != null) { |
36 | 36 | parent::__construct($object, self::subs); |
37 | 37 | } |
@@ -18,51 +18,51 @@ discard block |
||
18 | 18 | public user $user; |
19 | 19 | |
20 | 20 | /** `creator` and `administrator` only. True, if the user's presence in the chat is hidden */ |
21 | - public null|bool $is_anonymous = null; |
|
21 | + public null | bool $is_anonymous = null; |
|
22 | 22 | |
23 | 23 | /** `creator` and `administrator` only. Custom title for this user */ |
24 | - public null|string $custom_title = null; |
|
24 | + public null | string $custom_title = null; |
|
25 | 25 | |
26 | 26 | /** `administrator` only. True, if the bot is allowed to edit administrator privileges of that user */ |
27 | - public null|bool $can_be_edited = null; |
|
27 | + public null | bool $can_be_edited = null; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * `administrator` only. True, if the administrator can access the chat event log, chat statistics, message statistics in |
31 | 31 | * channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other |
32 | 32 | * administrator privilege |
33 | 33 | */ |
34 | - public null|bool $can_manage_chat = null; |
|
34 | + public null | bool $can_manage_chat = null; |
|
35 | 35 | |
36 | 36 | /** `administrator` only. True, if the administrator can delete messages of other users */ |
37 | - public null|bool $can_delete_messages = null; |
|
37 | + public null | bool $can_delete_messages = null; |
|
38 | 38 | |
39 | 39 | /** `administrator` only. True, if the administrator can manage video chats */ |
40 | - public null|bool $can_manage_video_chats = null; |
|
40 | + public null | bool $can_manage_video_chats = null; |
|
41 | 41 | |
42 | 42 | /** `administrator` only. True, if the administrator can restrict, ban or unban chat members */ |
43 | - public null|bool $can_restrict_members = null; |
|
43 | + public null | bool $can_restrict_members = null; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * `administrator` only. if the administrator can add new administrators with a subset of their own privileges or demote |
47 | 47 | * administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by |
48 | 48 | * the user) |
49 | 49 | */ |
50 | - public null|bool $can_promote_members = null; |
|
50 | + public null | bool $can_promote_members = null; |
|
51 | 51 | |
52 | 52 | /** `administrator` and `restricted` only. True, if the user is allowed to change the chat title, photo and other settings */ |
53 | - public null|bool $can_change_info = null; |
|
53 | + public null | bool $can_change_info = null; |
|
54 | 54 | |
55 | 55 | /** `administrator` and `restricted` only. True, if the user is allowed to invite new users to the chat */ |
56 | - public null|bool $can_invite_users = null; |
|
56 | + public null | bool $can_invite_users = null; |
|
57 | 57 | |
58 | 58 | /** `administrator` only. Optional. True, if the administrator can post in the channel; channels only */ |
59 | - public null|bool $can_post_messages = null; |
|
59 | + public null | bool $can_post_messages = null; |
|
60 | 60 | |
61 | 61 | /** `administrator` only. Optional. True, if the administrator can edit messages of other users and can pin messages; channels only */ |
62 | - public null|bool $can_edit_messages = null; |
|
62 | + public null | bool $can_edit_messages = null; |
|
63 | 63 | |
64 | 64 | /** `administrator` and `restricted` only. Optional. True, if the user is allowed to pin messages; groups and supergroups only */ |
65 | - public null|bool $can_pin_messages = null; |
|
65 | + public null | bool $can_pin_messages = null; |
|
66 | 66 | |
67 | 67 | /** administrator` only. Optional. True, if the administrator can post stories in the channel; channels only */ |
68 | 68 | public bool $can_post_stories; |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | * |
79 | 79 | * `restricted` : True, if the user is allowed to create forum topics |
80 | 80 | */ |
81 | - public null|bool $can_manage_topics = null; |
|
81 | + public null | bool $can_manage_topics = null; |
|
82 | 82 | |
83 | 83 | /** `restricted` only. True, if the user is a member of the chat at the moment of the request */ |
84 | - public null|bool $is_member = null; |
|
84 | + public null | bool $is_member = null; |
|
85 | 85 | |
86 | 86 | /** `restricted` only. True, if the user is allowed to send text messages, contacts, locations and venues */ |
87 | - public null|bool $can_send_messages = null; |
|
87 | + public null | bool $can_send_messages = null; |
|
88 | 88 | |
89 | 89 | /** `restricted` only. Optional. True, if the user is allowed to send audios */ |
90 | 90 | public bool $can_send_audios; |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | public bool $can_send_voice_notes; |
106 | 106 | |
107 | 107 | /** `restricted` only. True, if the user is allowed to send polls */ |
108 | - public null|bool $can_send_polls = null; |
|
108 | + public null | bool $can_send_polls = null; |
|
109 | 109 | |
110 | 110 | /** `restricted` only. True, if the user is allowed to send animations, games, stickers and use inline bots */ |
111 | - public null|bool $can_send_other_messages = null; |
|
111 | + public null | bool $can_send_other_messages = null; |
|
112 | 112 | |
113 | 113 | /** `restricted` only. True, if the user is allowed to add web page previews to their messages */ |
114 | - public null|bool $can_add_web_page_previews = null; |
|
114 | + public null | bool $can_add_web_page_previews = null; |
|
115 | 115 | |
116 | 116 | /** `kicked` and `restricted` only. Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever */ |
117 | - public null|int $until_date = null; |
|
117 | + public null | int $until_date = null; |
|
118 | 118 | |
119 | 119 | |
120 | 120 | public function __construct(stdClass $object) { |