diff --git a/PayPingDonate.php b/PayPingDonate.php
new file mode 100644
index 0000000..ae45622
--- /dev/null
+++ b/PayPingDonate.php
@@ -0,0 +1,567 @@
+\r\n";
+ }
+
+
+ $Amount = filter_input(INPUT_POST, 'payPingDonate_Amount', FILTER_SANITIZE_SPECIAL_CHARS);
+
+ if(is_numeric($Amount) != false)
+ {
+ //Amount will be based on Toman - Required
+ if($payPingDonate_Unit == 'ریال')
+ $SendAmount = $Amount / 10;
+ else
+ $SendAmount = $Amount;
+ }
+ else
+ {
+ $error .= 'مبلغ به درستی وارد نشده است' . "
\r\n";
+ }
+
+ $Description = filter_input(INPUT_POST, 'payPingDonate_Description', FILTER_SANITIZE_SPECIAL_CHARS); // Required
+ $Name = filter_input(INPUT_POST, 'payPingDonate_Name', FILTER_SANITIZE_SPECIAL_CHARS); // Required
+ $Mobile = filter_input(INPUT_POST, 'mobile', FILTER_SANITIZE_SPECIAL_CHARS); // Optional
+ $Email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_SPECIAL_CHARS); // Optional
+
+ $SendDescription = $Name . ' | ' . $Mobile . ' | ' . $Email . ' | ' . $Description ;
+
+ if($error == '') // اگر خطایی نباشد
+ {
+
+ $code = payPingDonate_AddDonate(array(
+ 'Name' => $Name,
+ 'AmountTomaan' => $SendAmount,
+ 'Mobile' => $Mobile,
+ 'Email' => $Email,
+ 'InputDate' => current_time( 'mysql' ),
+ 'Description' => $Description,
+ 'Status' => 'SEND'
+ ),array(
+ '%s',
+ '%s',
+ '%d',
+ '%s',
+ '%s',
+ '%s',
+ '%s',
+ '%s'
+ ));
+ $CallbackURL = payPingDonate_GetCallBackURL(); // Required
+ $data = array('payerName'=>$Name, 'Amount' => $SendAmount,'payerIdentity'=> $Mobile , 'returnUrl' => $CallbackURL, 'Description' => $SendDescription , 'clientRefId' => $code );
+ try {
+ $curl = curl_init();
+ curl_setopt_array($curl, array(
+ CURLOPT_URL => "https://api.payping.ir/v1/pay",
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_ENCODING => "",
+ CURLOPT_MAXREDIRS => 10,
+ CURLOPT_TIMEOUT => 30,
+ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+ CURLOPT_CUSTOMREQUEST => "POST",
+ CURLOPT_POSTFIELDS => json_encode($data),
+ CURLOPT_HTTPHEADER => array(
+ "accept: application/json",
+ "authorization: Bearer " .$MerchantID,
+ "cache-control: no-cache",
+ "content-type: application/json"),
+ )
+ );
+ $response = curl_exec($curl);
+ $header = curl_getinfo($curl);
+ $err = curl_error($curl);
+ curl_close($curl);
+ if ($err) {
+ echo "cURL Error #:" . $err;
+ } else {
+ if ($header['http_code'] == 200) {
+ $response = json_decode($response, true);
+ if (isset($response["code"]) and $response["code"] != '') {
+
+ wp_redirect(sprintf('https://api.payping.ir/v1/pay/gotoipg/%s', $response["code"]));
+ exit;
+ } else {
+ $error .= ' تراکنش ناموفق بود- شرح خطا : عدم وجود کد ارجاع '. "
\r\n";
+ }
+ } elseif ($header['http_code'] == 400) {
+ $error .= ' تراکنش ناموفق بود- شرح خطا : ' . implode('. ',array_values (json_decode($response,true))). "
\r\n" ;
+ } else {
+ $error .= ' تراکنش ناموفق بود- شرح خطا : ' . payPingDonate_GetResaultStatusString($header['http_code']) . '(' . $header['http_code'] . ')'. "
\r\n";
+ }
+ }
+ } catch (Exception $e){
+ $error .= ' تراکنش ناموفق بود- شرح خطا سمت برنامه شما : ' . $e->getMessage(). "
\r\n";
+ }
+ }
+ }
+ //// END REQUEST
+
+
+ ////////////////////////////////////////////////////
+ /// RESPONSE
+ if(isset($_GET['clientrefid']))
+ {
+ $id = filter_input(INPUT_GET, 'clientrefid', FILTER_SANITIZE_SPECIAL_CHARS);
+ $refid = filter_input(INPUT_GET, 'refid', FILTER_SANITIZE_SPECIAL_CHARS);
+
+
+
+ $Record = payPingDonate_GetDonate($id);
+ if( $Record === false)
+ {
+ $error .= 'چنین تراکنشی در سایت ثبت نشده است' . "
\r\n";
+ }
+ else
+ {
+
+
+ $data = array('refId' => $refid, 'amount' => $Record['AmountTomaan']);
+ try {
+ $curl = curl_init();
+ curl_setopt_array($curl, array(
+ CURLOPT_URL => "https://api.payping.ir/v1/pay/verify",
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_ENCODING => "",
+ CURLOPT_MAXREDIRS => 10,
+ CURLOPT_TIMEOUT => 30,
+ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+ CURLOPT_CUSTOMREQUEST => "POST",
+ CURLOPT_POSTFIELDS => json_encode($data),
+ CURLOPT_HTTPHEADER => array(
+ "accept: application/json",
+ "authorization: Bearer ".$MerchantID,
+ "cache-control: no-cache",
+ "content-type: application/json",
+ ),
+ ));
+ $response = curl_exec($curl);
+ $err = curl_error($curl);
+ $header = curl_getinfo($curl);
+ curl_close($curl);
+ if ($err) {
+ payPingDonate_ChangeStatus($id, 'ERROR');
+ $error .= get_option( 'payPingDonate_IsError') . "
\r\n";
+ $error .= 'خطا در ارتباط به پیپینگ : شرح خطا '.$err. "
\r\n";
+ payPingDonate_SetAuthority($id, $refid);
+ } else {
+ if ($header['http_code'] == 200) {
+ $response = json_decode($response, true);
+ if (isset($_GET["refid"]) and $_GET["refid"] != '') {
+ payPingDonate_ChangeStatus($id, 'OK');
+ $message .= get_option( 'payPingDonate_IsOk') . "
\r\n";
+ $message .= 'کد پیگیری تراکنش:'. $refid . "
\r\n";
+ $payPingDonate_TotalAmount = get_option("payPingDonate_TotalAmount");
+ update_option("payPingDonate_TotalAmount" , $payPingDonate_TotalAmount + $Record['AmountTomaan']);
+ } else {
+ payPingDonate_ChangeStatus($id, 'ERROR');
+ $error .= get_option( 'payPingDonate_IsError') . "
\r\n";
+ payPingDonate_SetAuthority($id, $refid);
+ $error .= 'متافسانه سامانه قادر به دریافت کد پیگیری نمی باشد! نتیجه درخواست : ' . payPingDonate_GetResaultStatusString($header['http_code']) . '(' . $header['http_code'] . ')' . "
\r\n";
+ }
+ } elseif ($header['http_code'] == 400) {
+ payPingDonate_ChangeStatus($id, 'ERROR');
+ $error .= get_option( 'payPingDonate_IsError') . "
\r\n";
+ payPingDonate_SetAuthority($id, $refid);
+ $error .= 'تراکنش ناموفق بود- شرح خطا : ' . implode('. ',array_values (json_decode($response,true))) . "
\r\n";
+ } else {
+ payPingDonate_ChangeStatus($id, 'ERROR');
+ $error .= get_option( 'payPingDonate_IsError') . "
\r\n";
+ payPingDonate_SetAuthority($id, $refid);
+ $error .= ' تراکنش ناموفق بود- شرح خطا : ' . payPingDonate_GetResaultStatusString($header['http_code']) . '(' . $header['http_code'] . ')'. "
\r\n";
+ }
+ }
+ } catch (Exception $e){
+ payPingDonate_ChangeStatus($id, 'ERROR');
+ $error .= get_option( 'payPingDonate_IsError') . "
\r\n";
+ payPingDonate_SetAuthority($id, $refid);
+ $error .= ' تراکنش ناموفق بود- شرح خطا سمت برنامه شما : ' . $e->getMessage(). "
\r\n";
+ }
+
+ }
+
+ }
+ /// END RESPONSE
+
+ $style = '';
+
+ if(get_option('payPingDonate_UseCustomStyle') == 'true')
+ {
+ $style = get_option('payPingDonate_CustomStyle');
+ }
+ else
+ {
+ $style = '#payPingDonate_MainForm { width: 400px; height: auto; margin: 0 auto; direction: rtl; } #payPingDonate_Form { width: 96%; height: auto; float: right; padding: 10px 2%; } #payPingDonate_Message,#payPingDonate_Error { width: 90%; margin-top: 10px; margin-right: 2%; float: right; padding: 5px 2%; border-right: 2px solid #006704; background-color: #e7ffc5; color: #00581f; } #payPingDonate_Error { border-right: 2px solid #790000; background-color: #ffc9c5; color: #580a00; } .payPingDonate_FormItem { width: 90%; margin-top: 10px; margin-right: 2%; float: right; padding: 5px 2%; } .payPingDonate_FormLabel { width: 35%; float: right; padding: 3px 0; } .payPingDonate_ItemInput { width: 64%; float: left; } .payPingDonate_ItemInput input { width: 90%; float: right; border-radius: 3px; box-shadow: 0 0 2px #00c4ff; border: 0px solid #c0fff0; font-family: inherit; font-size: inherit; padding: 3px 5px; } .payPingDonate_ItemInput input:focus { box-shadow: 0 0 4px #0099d1; } .payPingDonate_ItemInput input.error { box-shadow: 0 0 4px #ef0d1e; } input.payPingDonate_Submit { background: none repeat scroll 0 0 #2ea2cc; border-color: #0074a2; box-shadow: 0 1px 0 rgba(120, 200, 230, 0.5) inset, 0 1px 0 rgba(0, 0, 0, 0.15); color: #fff; text-decoration: none; border-radius: 3px; border-style: solid; border-width: 1px; box-sizing: border-box; cursor: pointer; display: inline-block; font-size: 13px; line-height: 26px; margin: 0; padding: 0 10px 1px; margin: 10px auto; width: 50%; font: inherit; float: right; margin-right: 24%; }';
+ }
+
+
+ $out = '
+
+
تنظیمات ذخیره شد.
'; + +} + +?> +نام و نام خانوادگی | مبلغ (تومان) | موبایل | شماره پیگیری | ایمیل | توضیحات | تاریخ | |
---|---|---|---|---|---|---|---|
نام و نام خانوادگی | مبلغ (تومان) | موبایل | شماره پیگیری | ایمیل | توضیحات | تاریخ | |
Name; ?> Status; ?>
|
AmountTomaan; ?> | Mobile; ?> | Authority; ?> | Email; ?> | Description; ?> | InputDate; ?> |