Changeset 2961101
- Timestamp:
- 08/31/2023 11:10:54 AM (2 years ago)
- Location:
- bsecure/trunk
- Files:
-
- 9 edited
-
assets/js/bsecure-front.js (modified) (2 diffs)
-
bsecure.php (modified) (1 diff)
-
includes/class-bsecure-admin.php (modified) (4 diffs)
-
includes/class-bsecure-apis.php (modified) (4 diffs)
-
includes/class-bsecure-checkout.php (modified) (15 diffs)
-
includes/class-sign-in-with-bsecure.php (modified) (4 diffs)
-
includes/class-wc-bsecure.php (modified) (3 diffs)
-
includes/class-wc-gateway-bsecure.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bsecure/trunk/assets/js/bsecure-front.js
r2935099 r2961101 285 285 286 286 // Receive message from bsecure server // 287 window.addEventListener("message", (event)=>{ 287 window.addEventListener("message", (event)=>{ 288 288 289 289 if (event.origin == "https://order-dev.bsecure.app" || … … 296 296 event.origin == "https://order-dev-v2.bsecure.app" || 297 297 event.origin == "https://fast-dev.bsecure.app" || 298 event.origin == "https://fast.bsecure.pk" 298 event.origin == "https://fast.bsecure.pk" || 299 event.origin == "https://card.bsecure.pk" || 300 event.origin == "https://card-stage.bsecure.app" || 301 event.origin == "https://card-dev.bsecure.app" 299 302 ){ 300 303 -
bsecure/trunk/bsecure.php
r2935099 r2961101 6 6 * Author: bSecure 7 7 * Author URI: https://bsecure.pk/ 8 * Version: 1.7. 58 * Version: 1.7.6 9 9 * 10 10 */ -
bsecure/trunk/includes/class-bsecure-admin.php
r2590855 r2961101 274 274 ]; 275 275 276 277 $response = $this->bsecureGetOauthToken(); 278 279 $validateResponse = $this->validateResponse($response,'token_request'); 280 281 if( $validateResponse['error'] ){ 282 283 wp_send_json_error( __('Response Error: ', 'wc-bsecure').$validateResponse['msg']); 284 285 } else { 286 287 // Get Order // 288 $access_token = $response->access_token; 289 290 //$headers = 'Authorization: Bearer '.$access_token; 291 $headers = $this->getApiHeaders($access_token); 276 277 $headers = $this->getApiHeaders(); 292 278 293 279 $params = [ … … 297 283 298 284 ]; 299 300 //$config = $this->getBsecureConfig(); 285 301 286 $survey_endpoint = get_option('wc_bsecure_base_url') . '/plugin/status'; 302 287 … … 324 309 325 310 } 326 }311 327 312 328 313 } … … 381 366 ]; 382 367 383 384 $response = $this->bsecureGetOauthToken(); 368 369 $headers = $this->getApiHeaders(); 370 371 $params = [ 372 'method' => 'POST', 373 'body' => $request_data, 374 'headers' => $headers, 375 376 ]; 377 378 $config = $this->getBsecureConfig(); 379 $survey_endpoint = !empty($config->pluginStatus) ? $config->pluginStatus : 380 get_option('wc_bsecure_base_url') . '/plugin/status'; 381 382 $response = $this->bsecureSendCurlRequest( $survey_endpoint, $params); 383 384 $validateResponse = $this->validateResponse($response); 385 386 if($validateResponse['error']){ 387 388 return false; 389 390 }else{ 391 392 update_option('bsecure_activated', $isActivate); 393 394 if (!empty($response->body)) { 395 396 return true; 397 398 } else { 399 400 return false; 401 402 } 385 403 386 $validateResponse = $this->validateResponse($response,'token_request'); 387 388 if( $validateResponse['error'] ){ 389 390 //error_log( __('Response Error: ', 'wc-bsecure').$validateResponse['msg']); 391 return false; 392 393 } else { 394 395 // Get Order // 396 $access_token = $response->access_token; 397 398 //$headers = 'Authorization: Bearer '.$access_token; 399 $headers = $this->getApiHeaders($access_token); 400 401 $params = [ 402 'method' => 'POST', 403 'body' => $request_data, 404 'headers' => $headers, 405 406 ]; 407 408 $config = $this->getBsecureConfig(); 409 $survey_endpoint = !empty($config->pluginStatus) ? $config->pluginStatus : 410 get_option('wc_bsecure_base_url') . '/plugin/status'; 411 412 $response = $this->bsecureSendCurlRequest( $survey_endpoint, $params); 413 414 $validateResponse = $this->validateResponse($response); 415 416 if($validateResponse['error']){ 417 418 //error_log( __('Response Error: ', 'wc-bsecure').$validateResponse['msg']); 419 return false; 420 421 }else{ 422 423 update_option('bsecure_activated', $isActivate); 424 425 if (!empty($response->body)) { 426 427 //error_log(json_encode([$response->body])); 428 return true; 429 430 } else { 431 432 //error_log(__("No response from bSecure server",'wc-bsecure') ); 433 return false; 434 435 } 436 437 } 438 } 404 } 405 439 406 } 440 407 -
bsecure/trunk/includes/class-bsecure-apis.php
r2935099 r2961101 71 71 $order_data = []; 72 72 73 $response = $this->bsecureGetOauthToken(); 74 75 $validateResponse = $this->validateResponse($response,'token_request'); 76 77 if( $validateResponse['error'] ){ 73 $headers = $this->getApiHeaders(); 74 75 $request_data['order_ref'] = $bsecure_order_ref; 76 77 $params = [ 78 'method' => 'POST', 79 'body' => $request_data, 80 'headers' => $headers, 81 82 ]; 83 84 $config = $this->getBsecureConfig(); 85 $order_status_endpoint = !empty($config->orderStatus) ? $config->orderStatus : ""; 86 $response = $this->bsecureSendCurlRequest( $order_status_endpoint, $params, 0, true); 87 88 $validateResponse = $this->validateResponse($response); 89 90 if($validateResponse['error']){ 78 91 79 92 status_header( 422 ); 80 93 echo json_encode($validateResponse); 81 94 exit; 82 83 95 84 96 }else{ 85 97 86 // Get Order // 87 $this->access_token = $response->access_token; 88 89 //$headers = 'Authorization: Bearer '.$this->access_token; 90 $headers = $this->getApiHeaders($this->access_token); 91 92 $request_data['order_ref'] = $bsecure_order_ref; 93 94 $params = [ 95 'method' => 'POST', 96 'body' => $request_data, 97 'headers' => $headers, 98 99 ]; 100 101 $config = $this->getBsecureConfig(); 102 $order_status_endpoint = !empty($config->orderStatus) ? $config->orderStatus : ""; 103 $response = $this->bsecureSendCurlRequest( $order_status_endpoint, $params, 0, true); 104 105 $validateResponse = $this->validateResponse($response); 106 107 if($validateResponse['error']){ 108 109 status_header( 422 ); 110 echo json_encode($validateResponse); 111 exit; 112 113 }else{ 114 115 $order_data = $response->body; 116 } 117 118 119 } 98 $order_data = $response->body; 99 } 100 101 102 120 103 121 104 … … 336 319 337 320 338 $accessToken = __("No token needed","wc-bsecure");321 339 322 340 323 $config = $this->getBsecureConfig(); 341 324 $order_url = !empty($config->orderCreate) ? $config->orderCreate : ""; 342 //$headers = 'Authorization: Bearer '.$accessToken; 343 $headers = $this->getApiHeaders( $accessToken,false);325 326 $headers = $this->getApiHeaders(); 344 327 345 328 $params = [ … … 523 506 $auth_code = !empty($data->auth_code) ? sanitize_text_field($data->auth_code) : ""; 524 507 525 /*$validate = $this->validateState($state); 526 527 if(!$validate['status']){ 528 529 status_header( 422 ); 530 echo json_encode($validate); 531 exit; 532 }*/ 533 534 $response = $this->bsecureGetOauthToken(); 535 536 $validateResponse = $this->validateResponse($response,'token_request'); 537 538 if( $validateResponse['error'] ){ 539 540 status_header( 422 ); 541 echo json_encode(['status' => false, 'msg'=>'Response Error: '.$validateResponse['msg']]); 542 exit; 543 544 } 545 546 $access_token = ""; 547 548 if(!empty($response->access_token)){ 549 550 $access_token = $response->access_token; 551 } 508 552 509 553 510 // Sanitize auth code. … … 558 515 $url = $base_url.$get_customer_endpoint; 559 516 560 //$headers = 'Authorization: Bearer '.$access_token; 561 $headers = $this->getApiHeaders($access_token); 517 $headers = $this->getApiHeaders(); 562 518 563 519 $args = [ -
bsecure/trunk/includes/class-bsecure-checkout.php
r2935099 r2961101 33 33 const STATUS_ONHOLD = 'on-hold'; 34 34 const STATUS_FAILED = 'failed'; 35 const STATUS_CONFIRMED = 'confirmed'; 35 36 const STATUS_DRAFT = 'bsecure_draft'; 36 37 const ORDER_TYPE_APP = 'app'; … … 71 72 add_action( 'clear_auth_cookie', array($this, 'actions_at_logout') ); 72 73 add_action( 'wp', array($this, 'handle_checkout_page' )); 73 add_action( ' wp_loaded', array($this, 'load_bsecure_gateway_class' ));74 add_action( 'plugins_loaded', array($this, 'load_bsecure_gateway_class' ),11 ); 74 75 75 76 if ( $wc_bsecure_payment_gateway == 'yes' && $wc_bsecure_is_active == 'yes') { … … 359 360 }else{ 360 361 361 $order->update_status($this->woocommerceStatus($placement_status ),"",true);362 $order->update_status($this->woocommerceStatus($placement_status,$order_data),"",true); 362 363 363 364 //Update payment method title … … 638 639 } 639 640 640 } 641 642 //27ddf3a0-6195-4e2a-ac28-0e2ced458e58 643 644 645 // Get Order // 646 $this->access_token = __('No token needed','wc-bsecure'); 647 648 $headers = $this->getApiHeaders($this->access_token, false); 641 } 642 643 644 // Get Order // 645 646 $headers = $this->getApiHeaders(); 649 647 650 648 $request_data['order_ref'] = $bsecure_order_ref; … … 762 760 763 761 $_order_key = get_post_meta($order_id, '_order_key', true); 764 762 765 763 wp_redirect(wc_get_checkout_url()."order-received/".$order_id."/?key=".$_order_key); 766 764 $this->updateOrderStatus($order,$order_data); … … 1513 1511 $order_url = $this->order_create_endpoint; 1514 1512 1515 $headers = $this->getApiHeaders( $accessToken,false);1513 $headers = $this->getApiHeaders(); 1516 1514 1517 1515 $params = [ … … 1584 1582 * Map bScure statuses with woocommerce default statuses 1585 1583 */ 1586 public function woocommerceStatus($placement_status ){1584 public function woocommerceStatus($placement_status, $order_data = []){ 1587 1585 1588 1586 /*"order_status": { … … 1620 1618 case 3: 1621 1619 1622 $order_status = Bsecure_Checkout::STATUS_PROCESSING; 1620 1621 $order_status = $this->getConfimredStatus($order_data); 1622 1623 1623 1624 1624 break; … … 2154 2154 public function getBsecureOrderByRefId($bsecure_order_ref){ 2155 2155 2156 $headers = $this->getApiHeaders( '',false);2156 $headers = $this->getApiHeaders(); 2157 2157 $request_data['order_ref'] = $bsecure_order_ref; 2158 2158 … … 2342 2342 } 2343 2343 2344 $order->update_status($this->woocommerceStatus($placement_status ),"",true);2344 $order->update_status($this->woocommerceStatus($placement_status, $order_data),"",true); 2345 2345 $order->save(); 2346 2346 … … 2752 2752 } 2753 2753 2754 // Get Order // 2755 $this->access_token = __('No token needed','wc-bsecure');; 2756 2757 $headers = $this->getApiHeaders($this->access_token, false); 2754 // Get Order // 2755 2756 $headers = $this->getApiHeaders(); 2758 2757 2759 2758 $request_data['order_ref'] = $order_ref; … … 3132 3131 $webhook_url = $base_url.$webhook_endpoint; 3133 3132 3134 if(get_option('wc_bsecure_is_active', 'no') == 'yes' && get_option('wc_bsecure_is_pim_enabled', 'no') == 'yes'){ 3135 3136 $this->access_token = $this->getAccessTokenSessionOrBsecure(); 3137 3138 if(!empty($this->access_token)){ 3139 3140 $headers = $this->getApiHeaders($this->access_token); 3133 if(get_option('wc_bsecure_is_active', 'no') == 'yes' && get_option('wc_bsecure_is_pim_enabled', 'no') == 'yes'){ 3134 3135 3136 $headers = $this->getApiHeaders(); 3141 3137 3142 3138 $params = [ … … 3156 3152 $this->sendLogsToBsecureServer($sendData); 3157 3153 } 3158 }3154 3159 3155 } 3160 3156 } … … 3191 3187 if(get_option('wc_bsecure_is_active', 'no') == 'yes'){ 3192 3188 3193 $this->access_token = $this->getAccessTokenSessionOrBsecure(); 3194 3195 if(!empty($this->access_token)){ 3196 3197 $headers = $this->getApiHeaders($this->access_token); 3198 3199 $params = [ 3200 3201 'method' => 'POST', 3202 'body' => $request_data, 3203 'headers' => $headers, 3204 3205 ]; 3206 3207 $this->bsecureSendCurlRequest($webhook_url,$params); 3208 3209 } 3189 3190 $headers = $this->getApiHeaders(); 3191 3192 $params = [ 3193 3194 'method' => 'POST', 3195 'body' => $request_data, 3196 'headers' => $headers, 3197 3198 ]; 3199 3200 $this->bsecureSendCurlRequest($webhook_url,$params); 3210 3201 3211 3202 } … … 3306 3297 3307 3298 $order_placement_status = !empty($order_data->placement_status) ? $order_data->placement_status : ''; 3308 $order_status = $this->woocommerceStatus($order_placement_status );3299 $order_status = $this->woocommerceStatus($order_placement_status,$order_data); 3309 3300 $order->calculate_totals(); 3310 3301 $return = $order->update_status($order_status,'',true); 3311 3302 return $return; 3312 3303 } 3304 3305 3306 public function getConfimredStatus($order_data){ 3307 3308 $order_status = Bsecure_Checkout::STATUS_PROCESSING; 3309 3310 $wc_order_statuses = wc_get_order_statuses(); 3311 3312 if(array_key_exists('wc-'. Bsecure_Checkout::STATUS_CONFIRMED, $wc_order_statuses)){ 3313 if(!empty($order_data)){ 3314 if(!empty($order_data->payment_method)){ 3315 if($order_data->payment_method->id == 1){ // COD = 1 3316 $order_status = Bsecure_Checkout::STATUS_CONFIRMED; 3317 } 3318 3319 } 3320 3321 } 3322 3323 } 3324 3325 return $order_status; 3326 } 3313 3327 } 3314 3328 -
bsecure/trunk/includes/class-sign-in-with-bsecure.php
r2935099 r2961101 306 306 } 307 307 308 /*$response = $this->bsecureGetOauthToken(); 309 310 $validateResponse = $this->validateResponse($response,'token_request'); 311 312 if( $validateResponse['error'] ){ 313 314 $this->redirectToMyAccountPage('Response Error: '.$validateResponse['msg']); 315 316 }else if(!empty($response->access_token)){ 317 318 $this->access_token = $response->access_token; 319 }*/ 320 308 321 309 // Sanitize auth code. 322 310 $code = sanitize_text_field( $code ); … … 324 312 $url = $this->base_url.$this->get_customer_endpoint; 325 313 326 //$headers = 'Authorization: Bearer '.$this->access_token; 327 //$headers = $this->getApiHeaders($this->access_token); 328 $headers = $this->getApiHeaders('',false); 314 $headers = $this->getApiHeaders(); 329 315 330 316 $args = [ … … 401 387 protected function get_user_by_token($code) { 402 388 403 //$headers = 'Authorization: Bearer '.$this->access_token; 404 //$headers = $this->getApiHeaders($this->access_token); 405 $headers = $this->getApiHeaders('',false); 389 $headers = $this->getApiHeaders(); 406 390 407 391 $args = [ … … 412 396 413 397 $response = $this->bsecureSendCurlRequest( $this->base_url.$this->get_customer_endpoint, $args ); 414 415 416 398 417 399 $validateResponse = $this->validateResponse($response); -
bsecure/trunk/includes/class-wc-bsecure.php
r2935099 r2961101 30 30 31 31 const PLUGIN_NAME = 'WooCommerce'; 32 const PLUGIN_VERSION = '1.7. 5';32 const PLUGIN_VERSION = '1.7.6'; 33 33 const QISSTPAY_PER_MONTH = 4; 34 34 const QISSTPAY_AMOUNT_MAX_LIMIT = 50000; … … 1510 1510 } 1511 1511 1512 public function getApiHeaders($accessToken , $isToken = true){1512 public function getApiHeaders($accessToken = ''){ 1513 1513 1514 1514 $client_id = get_option('wc_bsecure_client_id'); … … 1517 1517 $client_id = !empty($store_id) ? $client_id.':'.sanitize_text_field($store_id) : $client_id; 1518 1518 1519 $headers = ['Authorization' => 'Bearer '.$accessToken]; 1520 1521 1522 if(!$isToken){ 1523 1524 $headers = [ 1519 $headers = [ 1525 1520 'x-client-id' => base64_encode($client_id), 1526 1521 'x-client-token' => base64_encode($client_secret), 1527 1522 ]; 1528 } 1523 1524 if(!empty($accessToken)){ 1525 $headers = ['Authorization' => 'Bearer '.$accessToken]; 1526 1527 } 1529 1528 1530 1529 return $headers; -
bsecure/trunk/includes/class-wc-gateway-bsecure.php
r2935099 r2961101 203 203 if (class_exists('WC_Bsecure')) { 204 204 205 $bSecure = new WC_Bsecure; 206 207 //$headers = 'Authorization: Bearer '.$response->access_token; 208 //$headers = ['Authorization' => 'Bearer '.$response->access_token]; 209 $headers = $bSecure->getApiHeaders('',false); 205 $bSecure = new WC_Bsecure; 206 207 $headers = $bSecure->getApiHeaders(); 210 208 211 209 $params = [ -
bsecure/trunk/readme.txt
r2935099 r2961101 3 3 Tags: payment, secure, checkout 4 4 Requires at least: 4.7 5 Tested up to: 6. 25 Tested up to: 6.3 6 6 Requires PHP: 5.6.20 or above 7 Stable tag: 1.7. 57 Stable tag: 1.7.6 8 8 License: GNU General Public License v3.0 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 115 115 * 1.7.4 Released General Update, New Fetures and Bug Fixes 116 116 117 = 1.7.6 August 31, 2023 = 118 * 1.7.6 Released General Update & Bug Fixes 117 119 118 120 == Upgrade Notice == … … 165 167 * 1.7.3 Released General Update and Bug Fixes 166 168 167 = 1.7. 4 December 12, 2022=168 * 1.7. 4 Released General Update, New Feturesand Bug Fixes169 = 1.7.6 August 31, 2023 = 170 * 1.7.6 Released General Update and Bug Fixes 169 171 170 172 == Screenshots ==
Note: See TracChangeset
for help on using the changeset viewer.