Changeset 3165632
- Timestamp:
- 10/09/2024 10:38:46 AM (18 months ago)
- Location:
- woo-payping-gateway
- Files:
-
- 14 added
- 1 deleted
- 3 edited
-
tags/4.5.0 (added)
-
tags/4.5.0/assets (added)
-
tags/4.5.0/assets/css (added)
-
tags/4.5.0/assets/css/style.css (added)
-
tags/4.5.0/assets/images (added)
-
tags/4.5.0/assets/images/logo.png (added)
-
tags/4.5.0/assets/js (added)
-
tags/4.5.0/assets/js/checkout.js (added)
-
tags/4.5.0/class-block.php (added)
-
tags/4.5.0/class-wc-gateway-payping.php (added)
-
tags/4.5.0/index.php (added)
-
tags/4.5.0/readme.txt (added)
-
tags/4.5.0/screenshot-1.png (added)
-
tags/4.5.0/screenshot-2.png (added)
-
trunk/assets/js/script-woo-vip.js (deleted)
-
trunk/class-wc-gateway-payping.php (modified) (15 diffs)
-
trunk/index.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-payping-gateway/trunk/class-wc-gateway-payping.php
r3063373 r3165632 5 5 class WC_payping extends WC_Payment_Gateway{ 6 6 7 private $baseurl = 'https://api.payping.ir/v 2';7 private $baseurl = 'https://api.payping.ir/v3'; 8 8 private $paypingToken; 9 9 private $success_massage; … … 21 21 22 22 $checkserver = $this->settings['ioserver']; 23 if( $checkserver == 'yes')$this->baseurl = 'https://api.payping.i o/v2';23 if( $checkserver == 'yes')$this->baseurl = 'https://api.payping.ir/v3'; 24 24 25 25 $this->title = $this->settings['title']; … … 131 131 $paypingpayCode = get_post_meta($order_id, '_payping_payCode', true); 132 132 if( $paypingpayCode ){ 133 wp_redirect( sprintf('%s/pay/ gotoipg/%s', $this->baseurl, $paypingpayCode )) ;133 wp_redirect( sprintf('%s/pay/start/%s', $this->baseurl, $paypingpayCode )) ; 134 134 exit; 135 135 } … … 189 189 $payerIdentity = $Email; 190 190 $data = array( 191 ' payerName'=>$Paymenter,191 'PayerName'=>$Paymenter, 192 192 'Amount' => $Amount, 193 ' payerIdentity'=> $payerIdentity ,194 ' returnUrl' => $CallbackUrl,193 'PayerIdentity'=> $payerIdentity , 194 'ReturnUrl' => $CallbackUrl, 195 195 'Description' => $Description , 196 'clientRefId' => $order->get_order_number() 196 'ClientRefId' => $order->get_order_number(), 197 'NationalCode' => '' 197 198 ); 198 199 … … 204 205 'blocking' => true, 205 206 'headers' => array( 207 'X-Platform' => 'woocommerce', 208 'X-Platform-Version' => '4.5.0', 206 209 'Authorization' => 'Bearer '.$this->paypingToken, 207 210 'Content-Type' => 'application/json', … … 214 217 215 218 $api_args = apply_filters( 'WC_payping_Gateway_Payment_api_args', $args, $order_id ); 216 219 217 220 $response = wp_remote_post($api_url, $api_args); 218 221 219 222 $ERR_ID = wp_remote_retrieve_header($response, 'x-paypingrequest-id'); 223 220 224 if( is_wp_error($response) ){ 221 225 $Message = $response->get_error_message(); … … 223 227 $code = wp_remote_retrieve_response_code( $response ); 224 228 if( $code === 200){ 225 if (isset($response["body"]) and $response["body"] != '') { 229 230 if (isset($response["body"]) && $response["body"] != '') { 226 231 $code_pay = wp_remote_retrieve_body($response); 227 232 $code_pay = json_decode($code_pay, true); 228 update_post_meta($order_id, '_payping_payCode', $code_pay[" code"] );229 $Note = 'ساخت موفق پرداخت، کد پرداخت: '.$code_pay[" code"];233 update_post_meta($order_id, '_payping_payCode', $code_pay["paymentCode"] ); 234 $Note = 'ساخت موفق پرداخت، کد پرداخت: '.$code_pay["paymentCode"]; 230 235 $order->add_order_note($Note, 1, false); 231 wp_redirect(sprintf('%s/pay/ gotoipg/%s', $this->baseurl, $code_pay["code"]));236 wp_redirect(sprintf('%s/pay/start/%s', $this->baseurl, $code_pay["paymentCode"])); 232 237 exit; 233 238 } else { … … 253 258 public function Return_from_payping_Gateway(){ 254 259 global $woocommerce; 255 260 $paypingResponse = stripslashes($_REQUEST['data']); 261 $responseData = json_decode($paypingResponse, true); 256 262 if( isset( $_REQUEST['wc_order'] ) ){ 257 263 $order_id = sanitize_text_field( $_REQUEST['wc_order'] ); … … 262 268 263 269 // Get refid 264 if ( isset( $_REQUEST['refid'] ) ){265 $refid = sanitize_text_field( $_REQUEST['refid']);270 if (isset($responseData['paymentRefId'])) { 271 $refid = sanitize_text_field($responseData['paymentRefId']); 266 272 }else{ 267 273 $refid = null; 268 274 } 269 275 270 $order_id = apply_filters('WC_payping_return_order_id', $order_id); 271 272 273 if( isset( $order_id ) ){ 274 if( $refid != null && $refid > 1000 ){ 275 update_post_meta($order_id, 'woo_payping_refid', $refid ); 276 } 277 278 // Get Order id 279 $order = new WC_Order($order_id); 280 // Get Currency Order 281 $currency = $order->get_currency(); 282 // Add Filter For Another Developer 283 $currency = apply_filters('WC_payping_Currency', $currency, $order_id); 284 276 // Get Order id 277 $order = new WC_Order($order_id); 278 // Get Currency Order 279 $currency = $order->get_currency(); 280 // Add Filter For Another Developer 281 $currency = apply_filters('WC_payping_Currency', $currency, $order_id); 282 283 // Add Filter for ANother Developer 284 $refid = apply_filters('WC_payping_return_refid', $refid); 285 $Transaction_ID = $refid; 286 287 if ($_REQUEST['status'] == 0) { 288 $Status = 'failed'; 289 $Message = "کاربر در صفحه بانک از پرداخت انصراف داده است."; 290 $Fault = 'تراكنش توسط شما لغو شد.'; 291 292 $tr_id = ($Transaction_ID && $Transaction_ID != 0) ? ('<br/>کد پیگیری: ' . $Transaction_ID) : ''; 293 $Note = sprintf(__('خطا در هنگام تایید پرداخت: %s', 'woocommerce'), $Message, $tr_id); 294 $Note = apply_filters('WC_payping_Return_from_Gateway_Failed_Note', $Note, $order_id, $Transaction_ID, $Fault); 295 $Notice = wpautop(wptexturize($Note)); 296 $Notice = str_replace("{transaction_id}", $Transaction_ID, $Notice); 297 $Notice = str_replace("{fault}", $Message, $Notice); 298 $Notice = apply_filters('WC_payping_Return_from_Gateway_Failed_Notice', $Notice, $order_id, $Transaction_ID, $Fault); 299 do_action('WC_payping_Return_from_Gateway_Failed', $order_id, $Transaction_ID, $Fault); 300 wc_add_notice($Fault, 'error'); 301 302 $order->add_order_note( $Notice, 0, false); 303 wp_redirect(wc_get_checkout_url()); 304 exit; 305 306 }else{ 307 $order_id = apply_filters('WC_payping_return_order_id', $order_id); 308 $order->update_meta_data( 'woo_payping_refid', $refid ); 309 285 310 if( $order->get_status() != 'completed' ){ 286 311 // Get Amount … … 291 316 $Amount = $this->payping_check_currency( $Amount, $currency ); 292 317 293 // Add Filter for ANother Developer294 $refid = apply_filters('WC_payping_return_refid', $refid);295 $Transaction_ID = $refid;296 297 318 //Set Data 298 $data = array('refId' => $refid, 'amount' => $Amount); 319 $data = array('PaymentRefId' => $refid, 'Amount' => $Amount); 320 299 321 $args = array( 300 322 'body' => json_encode($data), … … 304 326 'blocking' => true, 305 327 'headers' => array( 306 'Authorization' => 'Bearer ' . $this->paypingToken,307 'Content-Type' => 'application/json',308 'Accept' => 'application/json'328 'Authorization' => 'Bearer ' . $this->paypingToken, 329 'Content-Type' => 'application/json', 330 'Accept' => 'application/json' 309 331 ), 310 'cookies' => array()332 'cookies' => array() 311 333 ); 312 313 // Add Filter for use Another developer 314 $verify_api_url = apply_filters( 'WC_payping_Gateway_Payment_verify_api_url', $this->baseurl . '/pay/verify', $order_id ); 315 //response 316 $response = wp_remote_post($verify_api_url, $args); 317 318 $body = wp_remote_retrieve_body( $response ); 319 $rbody = json_decode( $body, true ); 320 321 $ERR_ID = wp_remote_retrieve_header($response, 'x-paypingrequest-id'); 322 if( is_wp_error($response) ){ 323 $Status = 'failed'; 324 $Fault = $response->get_error_message(); 325 $Message = 'خطا در ارتباط به پیپینگ : شرح خطا '.$response->get_error_message(); 326 }else{ 327 $code = wp_remote_retrieve_response_code( $response ); 328 $txtmsg = $this->status_message( $code ); 329 330 //check cardNumber payer 331 if(isset($rbody['cardNumber'])){ 332 $cardNumber = $rbody['cardNumber']; 333 update_post_meta($order_id, 'payping_payment_card_number', $cardNumber); 334 335 // Add Filter for use Another developer 336 $verify_api_url = apply_filters( 'WC_payping_Gateway_Payment_verify_api_url', $this->baseurl . '/pay/verify', $order_id ); 337 //response 338 $response = wp_remote_post($verify_api_url, $args); 339 $body = wp_remote_retrieve_body( $response ); 340 $rbody = json_decode( $body, true ); 341 342 if( is_wp_error($response) ){ 343 $Status = 'failed'; 344 $Fault = $response->get_error_message(); 345 $Message = 'خطا در ارتباط به پیپینگ : شرح خطا '.$response->get_error_message(); 346 }elseif (isset($rbody['status']) && $rbody['status'] == 409) { 347 $Status = 'completed'; 348 $Message = 'این سفارش قبلا تایید شده است.'; 334 349 }else{ 350 $code = wp_remote_retrieve_response_code( $response ); 351 $txtmsg = $this->status_message( $code ); 352 353 //check cardNumber payer 335 354 $cardNumber = '-'; 336 } 337 338 if( $code === 200 ){ 339 if( isset( $refid ) and $refid != '' ){ 355 $CardHashPan = '-'; 356 357 if(isset($rbody['cardNumber']))$cardNumber = $rbody['cardNumber']; 358 359 if(isset($rbody['cardHashPan']))$CardHashPan = $rbody['cardHashPan']; 360 361 $order->update_meta_data('payping_payment_card_number', $cardNumber); 362 $order->update_meta_data('payping_payment_card_hashpan', $CardHashPan); 363 364 if( $code === 200 ){ 340 365 $Status = 'completed'; 341 $Message = $txtmsg.'<br>شماره کارت: <b dir="ltr">'.$cardNumber.'</b>'; 366 $Message = "{$txtmsg}<br>شماره کارت: <b dir='ltr'>{$cardNumber}</b>"; 367 }elseif( $code == 400){ 368 $Status = 'failed'; 369 $Message = $txtmsg; 370 $Fault = 'خطایی رخ داده است، با مدیریت سایت تماس بگیرید.'; 342 371 }else{ 343 372 $Status = 'failed'; 344 $Message = 'متاسفانه سامانه قادر به دریافت کد پیگیری نمی باشد! نتیجه درخواست : ' . $body .'<br /> شماره خطا: '.$ERR_ID;345 $Fault = 'خطای دریافت کد پیگیری!';373 $Message = $txtmsg; 374 $Fault = 'خطای نامشخص در تایید پرداخت!'; 346 375 } 347 }elseif( $code == 400){348 if( array_key_exists('15', $rbody) ){349 $Status = 'completed';350 $Message = $txtmsg.'<br>شماره کارت: <b dir="ltr">'.$cardNumber.'</b>';351 }elseif( array_key_exists( '1', $rbody) ){352 $Status = 'failed';353 $Message = "کاربر در صفحه بانک از پرداخت انصراف داده است.<br> شماره خطا: $ERR_ID";354 $Fault = 'تراكنش توسط شما لغو شد.';355 }else{356 $Status = 'failed';357 $Message = $txtmsg."<br> شماره خطا: $ERR_ID";358 $Fault = 'خطایی رخ داده است، با مدیریت سایت تماس بگیرید.';359 }360 }else{361 $Status = 'failed';362 $Message = $txtmsg.'<br> شماره خطا: '.$ERR_ID;363 $Fault = 'خطای نامشخص در تایید پرداخت!';364 376 } 365 } 366 377 367 378 if( isset( $Transaction_ID ) && $Transaction_ID != 0 ){ 368 update_post_meta($order_id, '_transaction_id', $Transaction_ID ); 379 380 $order->update_meta_data( '_transaction_id', $Transaction_ID ); 381 369 382 if( $Status == 'completed' ){ 370 383 $Note = sprintf( __('%s <br> شماره سفارش: %s <br>', 'woocommerce'), $Message, $Transaction_ID) ; … … 372 385 $Notice = wpautop(wptexturize($this->success_massage)); 373 386 $Notice = str_replace("{transaction_id}", $Transaction_ID, $Notice); 374 $Notice = apply_filters('WC_payping_Return_from_Gateway_Success_Notice', $Notice, $order_id, $Transaction_ID); 387 $Notice = apply_filters('woocommerce_thankyou_order_received_text', $Notice, $order_id, $Transaction_ID); 388 375 389 do_action('WC_payping_Return_from_Gateway_Success', $order_id, $Transaction_ID, $response); 376 wc_add_notice($Message, 'error'); 377 $order->add_order_note( $Message, 0, false); 390 378 391 $woocommerce->cart->empty_cart(); 392 393 wc_add_notice($Message, 'success'); 394 379 395 $order->payment_complete($Transaction_ID); 396 397 // Add order note 398 $order->add_order_note( sprintf( __( '%s <br>شماره پیگیری پرداخت: %s', 'woocommerce' ), $Message, $Transaction_ID ) ); 399 380 400 wp_redirect(add_query_arg('wc_status', 'success', $this->get_return_url($order))); 401 381 402 exit; 382 403 }else{ … … 394 415 exit; 395 416 } 417 396 418 }else{ 397 419 wc_add_notice($Fault, 'error'); … … 399 421 update_post_meta($order_id, '_transaction_id', $Transaction_ID ); 400 422 } 423 $order->save(); 401 424 }else{ 402 425 $Transaction_ID = get_post_meta($order_id, '_transaction_id', true); 403 $Notice = wpautop(wptexturize($this->success_massage.' شناسه خطای پی پینگ:'.$ERR_ID));404 426 $Notice = str_replace("{transaction_id}", $Transaction_ID, $Notice); 405 427 $Notice = apply_filters('WC_payping_Return_from_Gateway_ReSuccess_Notice', $Notice, $order_id, $Transaction_ID); … … 410 432 exit; 411 433 } 412 }else{413 $Fault = __('شماره سفارش وجود ندارد .', 'woocommerce');414 $Notice = wpautop(wptexturize($this->failed_massage.' شناسه خطای پی پینگ:'.$ERR_ID));415 $Notice = str_replace("{fault}", $Fault, $Notice);416 $Notice = apply_filters('WC_payping_Return_from_Gateway_No_Order_ID_Notice', $Notice, $order_id, $Fault);417 wc_add_notice($Fault, 'error');418 $order->add_order_note( $Notice, 0, false);419 do_action('WC_payping_Return_from_Gateway_No_Order_ID', $order_id, $Transaction_ID, $Fault);420 wp_redirect(wc_get_checkout_url());421 exit;422 434 } 423 435 } -
woo-payping-gateway/trunk/index.php
r3063373 r3165632 2 2 /* 3 3 Plugin Name: Gateway for PayPing on WooCommerce 4 Version: 4. 4.04 Version: 4.5.0 5 5 Description: افزونه درگاه پرداخت پیپینگ برای ووکامرس 6 6 Plugin URI: https://www.payping.ir/ -
woo-payping-gateway/trunk/readme.txt
r3122739 r3165632 4 4 Donate link: https://payping.ir 5 5 Requires at least: 4.0.0 6 Tested up to: 6.6 6 Tested up to: 6.6.2 7 7 Requires PHP: 7.4.0 8 Stable tag: 4. 4.08 Stable tag: 4.5.0 9 9 License: GPLv3 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 21 21 22 22 == Changelog == 23 24 == 4.5.0 == 25 بروزرسانی وب سرویس پی پینگ به نسخه جدید. 23 26 24 27 == 4.4.0 ==
Note: See TracChangeset
for help on using the changeset viewer.