Changeset 3151743
- Timestamp:
- 09/14/2024 11:21:04 AM (19 months ago)
- Location:
- payping-donate/trunk
- Files:
-
- 3 edited
-
assets/js/script.js (modified) (1 diff)
-
payping-donate.php (modified) (7 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
payping-donate/trunk/assets/js/script.js
r3151688 r3151743 28 28 mobile: $('input[name="mobile"]').val(), 29 29 email: $('input[name="email"]').val(), 30 payPingDonate_Description: $(' input[name="payPingDonate_Description"]').val(),30 payPingDonate_Description: $('.payping_description_input').val(), 31 31 page_url: returnPageUrl 32 32 }; -
payping-donate/trunk/payping-donate.php
r3151688 r3151743 2 2 /* 3 3 Plugin Name: Payping Donate 4 Version: 1. 34 Version: 1.4.0 5 5 Description: افزونه دریافت حمایت مالی وردپرس 6 6 Plugin URI: https://payping.io/ … … 106 106 } 107 107 108 $SendDescription = $Name . ' | ' . $Mobile . ' | ' . $Email . ' | ' . $Description;109 110 108 // Insert the donation record into the database 111 109 global $wpdb; … … 119 117 'Status' => 'SEND' 120 118 )); 121 119 122 120 $code = $wpdb->insert_id; 123 121 124 122 $data = array( 125 'payerName' => $Name,126 123 'Amount' => $SendAmount, 127 'payerIdentity' => $Mobile, 128 'returnUrl' => $returnUrl, 129 'Description' => $SendDescription, 130 'clientRefId' => $code 124 'ReturnUrl' => $returnUrl, 125 'PayerIdentity' => $Mobile, 126 'PayerName' => $Name, 127 'Description' => $Description, 128 'ClientRefId' => "{$code}", 129 'NationalCode' => '' 131 130 ); 132 $response = wp_remote_post('https://api.payping.ir/v 1/pay', array(131 $response = wp_remote_post('https://api.payping.ir/v3/pay', array( 133 132 'body' => wp_json_encode($data), 134 133 'headers' => array( … … 141 140 'redirection' => 10, 142 141 )); 143 144 142 if (is_wp_error($response)) { 145 143 wp_send_json_error($response->get_error_message()); … … 147 145 $status_code = wp_remote_retrieve_response_code($response); 148 146 $response_body = wp_remote_retrieve_body($response); 149 150 147 if ($status_code == 200) { 151 148 $response_data = json_decode($response_body, true); 152 if (isset($response_data[' code']) && $response_data['code'] != '') {153 $url = sprintf('https://api.payping.ir/v 1/pay/gotoipg/%s', $response_data['code']);149 if (isset($response_data['paymentCode']) && $response_data['paymentCode'] != '') { 150 $url = sprintf('https://api.payping.ir/v3/pay/start/%s', $response_data['paymentCode']); 154 151 wp_send_json_success($url); 155 152 } else { … … 187 184 //////////////////////////////////////////////////// 188 185 /// RESPONSE 189 if (isset($_GET['clientrefid'])) { 190 // Sanitize input 191 $id = filter_input(INPUT_GET, 'clientrefid', FILTER_SANITIZE_STRING); 192 $refid = filter_input(INPUT_GET, 'refid', FILTER_SANITIZE_STRING); 193 194 $Record = payPingDonate_GetDonate($id); 195 if ($Record === false) { 196 $error .= 'چنین تراکنشی در سایت ثبت نشده است' . "<br>\r\n"; 197 } else { 198 $data = array('refId' => $refid, 'amount' => $Record['AmountTomaan']); 199 try { 200 $response = wp_remote_post('https://api.payping.ir/v1/pay/verify', array( 201 'body' => wp_json_encode($data), 202 'headers' => array( 203 'Accept' => 'application/json', 204 'Authorization' => 'Bearer ' . esc_attr($Token), 205 'Cache-Control' => 'no-cache', 206 'Content-Type' => 'application/json' 207 ), 208 'timeout' => 30, 209 'redirection' => 10, 210 )); 211 212 if (is_wp_error($response)) { 213 $error_message = $response->get_error_message(); 214 payPingDonate_ChangeStatus($id, 'ERROR'); 215 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 216 $error .= 'خطا در ارتباط به پیپینگ : شرح خطا ' . esc_html($error_message) . "<br>\r\n"; 217 payPingDonate_SetAuthority($id, $refid); 218 } else { 219 $status_code = wp_remote_retrieve_response_code($response); 220 $response_body = wp_remote_retrieve_body($response); 221 222 if ($status_code == 200) { 223 $response_data = json_decode($response_body, true); 224 if (!empty($_GET["refid"])) { 225 payPingDonate_ChangeStatus($id, 'OK'); 226 payPingDonate_SetAuthority($id, $refid); 227 $message .= esc_html(get_option('payPingDonate_IsOk')) . "<br>\r\n"; 228 $message .= 'کد پیگیری تراکنش: ' . esc_html($refid) . "<br>\r\n"; 229 $payPingDonate_TotalAmount = get_option("payPingDonate_TotalAmount"); 230 update_option("payPingDonate_TotalAmount", $payPingDonate_TotalAmount + $Record['AmountTomaan']); 231 } else { 232 payPingDonate_ChangeStatus($id, 'ERROR'); 233 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 234 payPingDonate_SetAuthority($id, $refid); 235 $error .= 'متاسفانه سامانه قادر به دریافت کد پیگیری نمی باشد! نتیجه درخواست : ' . esc_html(payPingDonate_GetResaultStatusString($status_code)) . '(' . esc_html($status_code) . ')' . "<br>\r\n"; 236 } 237 } elseif ($status_code == 400) { 238 payPingDonate_ChangeStatus($id, 'ERROR'); 239 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 240 payPingDonate_SetAuthority($id, $refid); 241 $error .= 'تراکنش ناموفق بود- شرح خطا : ' . esc_html(implode('. ', array_values(json_decode($response_body, true)))) . "<br>\r\n"; 242 } else { 243 payPingDonate_ChangeStatus($id, 'ERROR'); 244 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 245 payPingDonate_SetAuthority($id, $refid); 246 $error .= ' تراکنش ناموفق بود- شرح خطا : ' . esc_html(payPingDonate_GetResaultStatusString($status_code)) . '(' . esc_html($status_code) . ')' . "<br>\r\n"; 247 } 248 } 249 } catch (Exception $e) { 250 payPingDonate_ChangeStatus($id, 'ERROR'); 251 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 252 payPingDonate_SetAuthority($id, $refid); 253 $error .= ' تراکنش ناموفق بود- شرح خطا سمت برنامه شما : ' . esc_html($e->getMessage()) . "<br>\r\n"; 254 } 255 } 186 if (isset($_REQUEST['Status'])) { 187 $id = $_REQUEST['ClientRefId']; 188 $status = $_REQUEST['Status']; 189 190 if ($status == -1) { 191 payPingDonate_ChangeStatus($id, 'ERROR'); 192 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 193 $error .= 'پرداخت توسط کاربر لغو شد!'; 194 payPingDonate_SetAuthority($id, $status); 195 } else { 196 $refid = $_REQUEST['PaymentRefId']; 197 $Record = payPingDonate_GetDonate($id); 198 if ($Record === false) { 199 $error .= 'چنین تراکنشی در سایت ثبت نشده است' . "<br>\r\n"; 200 } else { 201 $data = array('PaymentRefId' => $refid, 'Amount' => $_REQUEST['Amount']); 202 try { 203 $response = wp_remote_post('https://api.payping.ir/v3/pay/verify', array( 204 'body' => wp_json_encode($data), 205 'headers' => array( 206 'Accept' => 'application/json', 207 'Authorization' => 'Bearer ' . esc_attr($Token), 208 'Cache-Control' => 'no-cache', 209 'Content-Type' => 'application/json' 210 ), 211 'timeout' => 30, 212 'redirection' => 10, 213 )); 214 215 if (is_wp_error($response)) { 216 $error_message = $response->get_error_message(); 217 payPingDonate_ChangeStatus($id, 'ERROR'); 218 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 219 $error .= 'خطا در ارتباط به پیپینگ : شرح خطا ' . esc_html($error_message) . "<br>\r\n"; 220 payPingDonate_SetAuthority($id, $refid); 221 } else { 222 $status_code = wp_remote_retrieve_response_code($response); 223 $response_body = wp_remote_retrieve_body($response); 224 225 if ($status_code == 200) { 226 $response_data = json_decode($response_body, true); 227 if (!empty($_REQUEST["PaymentRefId"])) { 228 payPingDonate_ChangeStatus($id, 'OK'); 229 payPingDonate_SetAuthority($id, $refid); 230 $message .= esc_html(get_option('payPingDonate_IsOk')) . "<br>\r\n"; 231 $message .= 'کد پیگیری تراکنش: ' . esc_html($refid) . "<br>\r\n"; 232 $payPingDonate_TotalAmount = get_option("payPingDonate_TotalAmount"); 233 update_option("payPingDonate_TotalAmount", $payPingDonate_TotalAmount + $_REQUEST['Amount']); 234 } else { 235 payPingDonate_ChangeStatus($id, 'ERROR'); 236 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 237 payPingDonate_SetAuthority($id, $refid); 238 $error .= 'متاسفانه سامانه قادر به دریافت کد پیگیری نمی باشد! نتیجه درخواست : ' . esc_html(payPingDonate_GetResaultStatusString($status_code)) . '(' . esc_html($status_code) . ')' . "<br>\r\n"; 239 } 240 } elseif ($status_code == 400) { 241 payPingDonate_ChangeStatus($id, 'ERROR'); 242 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 243 payPingDonate_SetAuthority($id, $refid); 244 $error .= 'تراکنش ناموفق بود- شرح خطا : ' . esc_html(implode('. ', array_values(json_decode($response_body, true)))) . "<br>\r\n"; 245 } else { 246 payPingDonate_ChangeStatus($id, 'ERROR'); 247 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 248 payPingDonate_SetAuthority($id, $refid); 249 $error .= ' تراکنش ناموفق بود- شرح خطا : ' . esc_html(payPingDonate_GetResaultStatusString($status_code)) . '(' . esc_html($status_code) . ')' . "<br>\r\n"; 250 } 251 } 252 } catch (Exception $e) { 253 payPingDonate_ChangeStatus($id, 'ERROR'); 254 $error .= esc_html(get_option('payPingDonate_IsError')) . "<br>\r\n"; 255 payPingDonate_SetAuthority($id, $refid); 256 $error .= ' تراکنش ناموفق بود- شرح خطا سمت برنامه شما : ' . esc_html($e->getMessage()) . "<br>\r\n"; 257 } 258 } 259 } 260 261 262 256 263 } 257 264 … … 292 299 <div class="payPingDonate_FormItem"> 293 300 <label class="payPingDonate_FormLabel">توضیحات :</label> 294 <div class="payPingDonate_ItemInput"><textarea type="text" class="payPingDonate_input " name="payPingDonate_Description" value="' . esc_attr($Description) . '" /></textarea></div>301 <div class="payPingDonate_ItemInput"><textarea type="text" class="payPingDonate_input payping_description_input" name="payPingDonate_Description" value="' . esc_attr($Description) . '" /></textarea></div> 295 302 </div> 296 303 <div class="payPingDonate_FormItem"> -
payping-donate/trunk/readme.txt
r3151688 r3151743 5 5 Tested up to: 6.6.0 6 6 Requires PHP: 7.0.0 7 Stable tag: 1. 37 Stable tag: 1.4.0 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 24 24 This plugin leverages the following third-party services: 25 25 26 1. api.payping.ir/v 1/pay/verify: To verify payments in our plugin.27 2. api.payping.ir/v 1/pay: For create order in our plugin and send user to gateway.26 1. api.payping.ir/v3/pay/verify: To verify payments in our plugin. 27 2. api.payping.ir/v3/pay: For create order in our plugin and send user to gateway. 28 28 29 29 … … 35 35 == 1.3 == 36 36 Add Custom CSS feature 37 38 == 1.4.0 == 39 Compatibility with PayPing v3
Note: See TracChangeset
for help on using the changeset viewer.