@@ -28,7 +28,7 @@ |
||
28 | 28 | public bool $user_is_premium; |
29 | 29 | |
30 | 30 | |
31 | - public function __construct(stdClass|null $object = null) { |
|
31 | + public function __construct(stdClass | null $object = null) { |
|
32 | 32 | if ($object != null) { |
33 | 33 | parent::__construct($object, self::subs); |
34 | 34 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | public bool $bot_is_member; |
57 | 57 | |
58 | 58 | |
59 | - public function __construct(stdClass|null $object = null) { |
|
59 | + public function __construct(stdClass | null $object = null) { |
|
60 | 60 | if ($object != null) { |
61 | 61 | parent::__construct($object, self::subs); |
62 | 62 | } |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return bool|int |
37 | 37 | */ |
38 | - public static function save(string $name, string $data): bool|int { |
|
39 | - return file_put_contents(settings::$name."$name.lock", $data) && chmod(settings::$name."$name.lock",0640); |
|
38 | + public static function save(string $name, string $data): bool | int { |
|
39 | + return file_put_contents(settings::$name."$name.lock", $data) && chmod(settings::$name."$name.lock", 0640); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return bool|string |
48 | 48 | */ |
49 | - public static function read(string $name): bool|string { |
|
49 | + public static function read(string $name): bool | string { |
|
50 | 50 | return file_get_contents(realpath(settings::$name."$name.lock")); |
51 | 51 | } |
52 | 52 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return bool|int |
59 | 59 | */ |
60 | - public static function mtime(string $name): bool|int { |
|
60 | + public static function mtime(string $name): bool | int { |
|
61 | 61 | return filemtime(realpath(settings::$name."$name.lock")); |
62 | 62 | } |
63 | 63 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return bool |
81 | 81 | */ |
82 | - public static function deleteIfExist (string|array $names): bool { |
|
82 | + public static function deleteIfExist(string | array $names): bool { |
|
83 | 83 | if (is_string($names)) { |
84 | 84 | $names = [$names]; |
85 | 85 | } |
@@ -16,31 +16,31 @@ |
||
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 | 24 | break; |
25 | 25 | } |
26 | - $updates = telegram::getUpdates($last_update_id,allowed_updates: settings::$allowed_updates); |
|
26 | + $updates = telegram::getUpdates($last_update_id, allowed_updates: settings::$allowed_updates); |
|
27 | 27 | if (!telegram::$status) { |
28 | - logger::write("There is some problem happened , telegram response : \n".json_encode($updates),loggerTypes::ERROR); |
|
29 | - BPT::exit(print_r($updates,true)); |
|
28 | + logger::write("There is some problem happened , telegram response : \n".json_encode($updates), loggerTypes::ERROR); |
|
29 | + BPT::exit(print_r($updates, true)); |
|
30 | 30 | } |
31 | 31 | self::handleUpdates($updates); |
32 | - $last_update_id = BPT::$update->update_id+1; |
|
33 | - lock::save('getUpdate',$last_update_id); |
|
32 | + $last_update_id = BPT::$update->update_id + 1; |
|
33 | + lock::save('getUpdate', $last_update_id); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | - private static function loadData(): bool|int|string { |
|
37 | + private static function loadData(): bool | int | string { |
|
38 | 38 | if (lock::exist('getUpdate')) { |
39 | 39 | return lock::read('getUpdate'); |
40 | 40 | } |
41 | 41 | self::deleteOldLocks(); |
42 | 42 | telegram::deleteWebhook(); |
43 | - lock::save('getUpdate',0); |
|
43 | + lock::save('getUpdate', 0); |
|
44 | 44 | return 0; |
45 | 45 | } |
46 | 46 |
@@ -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 | crypto::init(); |
11 | 11 | } |
@@ -16,20 +16,20 @@ discard block |
||
16 | 16 | |
17 | 17 | private static CurlHandle $session; |
18 | 18 | |
19 | - public static function init (string $api_key = '', bool $sandbox = false): void { |
|
19 | + public static function init(string $api_key = '', bool $sandbox = false): void { |
|
20 | 20 | self::$session = curl_init(); |
21 | 21 | curl_setopt(self::$session, CURLOPT_RETURNTRANSFER, true); |
22 | 22 | curl_setopt(self::$session, CURLOPT_SSL_VERIFYPEER, 1); |
23 | 23 | curl_setopt(self::$session, CURLOPT_SSL_VERIFYHOST, 2); |
24 | 24 | curl_setopt(self::$session, CURLOPT_HTTPHEADER, [ |
25 | 25 | 'Content-Type: application/json', |
26 | - 'X-API-KEY: ' . settings::$pay['idpay']['api_key'] ?? $api_key, |
|
27 | - 'X-SANDBOX: ' . (int) (settings::$pay['idpay']['sandbox'] ?? $sandbox), |
|
26 | + 'X-API-KEY: '.settings::$pay['idpay']['api_key'] ?? $api_key, |
|
27 | + 'X-SANDBOX: '.(int) (settings::$pay['idpay']['sandbox'] ?? $sandbox), |
|
28 | 28 | ]); |
29 | 29 | curl_setopt(self::$session, CURLOPT_POST, true); |
30 | 30 | } |
31 | 31 | |
32 | - private static function execute (string $endpoint, array $params) { |
|
32 | + private static function execute(string $endpoint, array $params) { |
|
33 | 33 | foreach ($params as $key => $value) { |
34 | 34 | if (empty($value)) { |
35 | 35 | unset($params[$key]); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $session = self::$session; |
40 | 40 | |
41 | 41 | curl_setopt($session, CURLOPT_POSTFIELDS, json_encode($params)); |
42 | - curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint); |
|
42 | + curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint); |
|
43 | 43 | |
44 | 44 | return json_decode(curl_exec($session)); |
45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @return paymentCreateInterface|errorInterface|object|bool |
49 | 49 | */ |
50 | - public static function createPayment (string $order_id, int $amount, string $name = '', string $phone = '', string $mail = '', string $desc = '', string $callback = ''): object|bool { |
|
50 | + public static function createPayment(string $order_id, int $amount, string $name = '', string $phone = '', string $mail = '', string $desc = '', string $callback = ''): object | bool { |
|
51 | 51 | return self::execute('payment', [ |
52 | 52 | 'order_id' => $order_id, |
53 | 53 | 'amount' => $amount, |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * @return paymentInterface|errorInterface|object|bool |
64 | 64 | */ |
65 | - public static function paymentDetail (string $id, string $order_id): object { |
|
65 | + public static function paymentDetail(string $id, string $order_id): object { |
|
66 | 66 | return self::execute('payment/inquiry', [ |
67 | 67 | 'order_id' => $order_id, |
68 | 68 | 'id' => $id |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @return paymentInterface|errorInterface|object|bool |
74 | 74 | */ |
75 | - public static function paymentConfirm (string $id, string $order_id): object { |
|
75 | + public static function paymentConfirm(string $id, string $order_id): object { |
|
76 | 76 | return self::execute('payment/verify', [ |
77 | 77 | 'order_id' => $order_id, |
78 | 78 | 'id' => $id |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * @return paymentListInterface|errorInterface|object|bool |
84 | 84 | */ |
85 | - public static function paymentList (int $page = 0, int $page_size = 25): object { |
|
85 | + public static function paymentList(int $page = 0, int $page_size = 25): object { |
|
86 | 86 | return self::execute('payment/transactions', [ |
87 | 87 | 'page' => $page, |
88 | 88 | 'page_size' => $page_size |
89 | 89 | ]); |
90 | 90 | } |
91 | 91 | |
92 | - public static function processCallback (): bool|int { |
|
92 | + public static function processCallback(): bool | int { |
|
93 | 93 | if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
94 | 94 | $response = $_POST; |
95 | 95 | } |
@@ -92,11 +92,9 @@ |
||
92 | 92 | public static function processCallback (): bool|int { |
93 | 93 | if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
94 | 94 | $response = $_POST; |
95 | - } |
|
96 | - elseif ($_SERVER['REQUEST_METHOD'] === 'GET') { |
|
95 | + } elseif ($_SERVER['REQUEST_METHOD'] === 'GET') { |
|
97 | 96 | $response = $_GET; |
98 | - } |
|
99 | - else { |
|
97 | + } else { |
|
100 | 98 | return false; |
101 | 99 | } |
102 | 100 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | private static CurlHandle $session; |
27 | 27 | |
28 | - public static function init (string $merchant_id = '', bool $sandbox = false, bool $zarin_gate = false): void { |
|
28 | + public static function init(string $merchant_id = '', bool $sandbox = false, bool $zarin_gate = false): void { |
|
29 | 29 | self::$sandbox = settings::$pay['zarinpal']['sandbox'] ?? $sandbox; |
30 | 30 | self::$zarin_gate = settings::$pay['zarinpal']['zarin_gate'] ?? settings::$pay['zarinpal']['zaringate'] ?? $zarin_gate; |
31 | 31 | self::$merchant_id = settings::$pay['zarinpal']['merchant_id'] ?? $merchant_id; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | curl_setopt(self::$session, CURLOPT_POST, true); |
41 | 41 | } |
42 | 42 | |
43 | - private static function getUrl (string $endpoint, bool $pay = false): string { |
|
43 | + private static function getUrl(string $endpoint, bool $pay = false): string { |
|
44 | 44 | if ($pay) { |
45 | 45 | $url = self::$sandbox ? self::SANDBOX_PAY_BASE : self::PAY_BASE; |
46 | 46 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | return $url; |
55 | 55 | } |
56 | 56 | |
57 | - private static function execute (string $endpoint, array $params = []): object { |
|
57 | + private static function execute(string $endpoint, array $params = []): object { |
|
58 | 58 | foreach ($params as $key => $value) { |
59 | 59 | if (empty($value)) { |
60 | 60 | unset($params[$key]); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * @return object|requestInterface |
90 | 90 | */ |
91 | - 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 | + 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 { |
|
92 | 92 | return self::execute('/request.json', [ |
93 | 93 | 'amount' => $amount, |
94 | 94 | 'description' => $description, |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | ]); |
103 | 103 | } |
104 | 104 | |
105 | - public static function payURL (string|array $authority): bool|string { |
|
105 | + public static function payURL(string | array $authority): bool | string { |
|
106 | 106 | if (is_array($authority)) { |
107 | 107 | if (!isset($authority->authority)) { |
108 | 108 | return false; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | /** |
116 | 116 | * @return object|verifyInterface |
117 | 117 | */ |
118 | - public static function verify (int $amount, string $authority): object { |
|
118 | + public static function verify(int $amount, string $authority): object { |
|
119 | 119 | return self::execute('/verify.json', [ |
120 | 120 | 'amount' => $amount, |
121 | 121 | 'authority' => $authority |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | /** |
126 | 126 | * @return object|unverifiedInterface |
127 | 127 | */ |
128 | - public static function unVerified (): object { |
|
128 | + public static function unVerified(): object { |
|
129 | 129 | return self::execute('/unVerified.json'); |
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | 133 | * @return object|refundInterface |
134 | 134 | */ |
135 | - public static function refund (string $authorization, string $authority): object { |
|
135 | + public static function refund(string $authorization, string $authority): object { |
|
136 | 136 | return self::execute('/refund.json', [ |
137 | 137 | 'authorization' => $authorization, |
138 | 138 | 'authority' => $authority |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | #[NoReturn] |
143 | - public static function redirect (string $url): void { |
|
144 | - @header('Location: ' . $url); |
|
143 | + public static function redirect(string $url): void { |
|
144 | + @header('Location: '.$url); |
|
145 | 145 | die("<meta http-equiv='refresh' content='0; url=$url' /><script>window.location.href = '$url';</script>"); |
146 | 146 | } |
147 | 147 | |
148 | - public static function processCallback (int $amount): object|bool|int { |
|
148 | + public static function processCallback(int $amount): object | bool | int { |
|
149 | 149 | if (!isset($_GET['Authority']) || !isset($_GET['Status'])) { |
150 | 150 | return false; |
151 | 151 | } |
@@ -43,8 +43,7 @@ |
||
43 | 43 | private static function getUrl (string $endpoint, bool $pay = false): string { |
44 | 44 | if ($pay) { |
45 | 45 | $url = self::$sandbox ? self::SANDBOX_PAY_BASE : self::PAY_BASE; |
46 | - } |
|
47 | - else { |
|
46 | + } else { |
|
48 | 47 | $url = self::$sandbox ? self::SANDBOX_API_BASE : self::API_BASE; |
49 | 48 | } |
50 | 49 | $url .= $endpoint; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the |
57 | 57 | * thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
58 | 58 | */ |
59 | - public CURLFile|string $thumbnail; |
|
59 | + public CURLFile | string $thumbnail; |
|
60 | 60 | |
61 | 61 | /** `video` and `animation` only. width */ |
62 | 62 | public int $width; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public bool $disable_content_type_detection; |
84 | 84 | |
85 | 85 | |
86 | - public function __construct(stdClass|null $object = null) { |
|
86 | + public function __construct(stdClass | null $object = null) { |
|
87 | 87 | if ($object != null) { |
88 | 88 | parent::__construct($object, self::subs); |
89 | 89 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | public string $short_description; |
16 | 16 | |
17 | 17 | |
18 | - public function __construct(stdClass|null $object = null) { |
|
18 | + public function __construct(stdClass | null $object = null) { |
|
19 | 19 | if ($object != null) { |
20 | 20 | parent::__construct($object, self::subs); |
21 | 21 | } |