Changeset 3242781
- Timestamp:
- 02/18/2025 04:52:02 PM (12 months ago)
- Location:
- arca-payment-gateway
- Files:
-
- 8 edited
- 1 copied
-
tags/1.4.9 (copied) (copied from arca-payment-gateway/trunk)
-
tags/1.4.9/arca-payment-gateway.php (modified) (2 diffs)
-
tags/1.4.9/endpoints/apg-idram.php (modified) (17 diffs)
-
tags/1.4.9/includes/apg-wc.php (modified) (1 diff)
-
tags/1.4.9/readme.txt (modified) (2 diffs)
-
trunk/arca-payment-gateway.php (modified) (2 diffs)
-
trunk/endpoints/apg-idram.php (modified) (17 diffs)
-
trunk/includes/apg-wc.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
arca-payment-gateway/tags/1.4.9/arca-payment-gateway.php
r3241730 r3242781 3 3 * Plugin Name: Planet Studio Payment Gateway for ArCa 4 4 * Description: This Plugin allows you to accept online payments from local and international customers to Armenian banks, Idram payment system and adds ArCa paycenter as a payment gateway for WooCommerce and for GiveWP donation Plugin and TATIOSA hotel booking management platform. 5 * Version: 1.4. 85 * Version: 1.4.9 6 6 * Author: Planet Studio team 7 7 * Author URI: https://planetstudio.am … … 15 15 define('ARCAPG_DIR_NAME', dirname(plugin_basename( __FILE__ ))); 16 16 define('ARCAPG_URL', plugins_url(plugin_basename(dirname(__FILE__)))); 17 define('ARCAPG_VERSION', '1.4. 8');17 define('ARCAPG_VERSION', '1.4.9'); 18 18 define('ARCAPG_PRO', FALSE); 19 19 define('ARCAPG_DELETE_DATA_ACTIONS', false); -
arca-payment-gateway/tags/1.4.9/endpoints/apg-idram.php
r3240719 r3242781 15 15 16 16 if ( !class_exists('woocommerce') ) { 17 add_filter( 'request', function($query_vars){18 if( isset($query_vars['wc-api']) ){19 do_action( 'woocommerce_api_'. $query_vars['wc-api'] );20 die;21 }22 return $query_vars;23 });17 add_filter( 'request', function($query_vars){ 18 if( isset($query_vars['wc-api']) ){ 19 do_action( 'woocommerce_api_'. $query_vars['wc-api'] ); 20 die; 21 } 22 return $query_vars; 23 }); 24 24 } 25 25 26 26 function apg_wc_api_idram_result(){ 27 27 28 global $wpdb, $arca_idram_config;29 $request = $_REQUEST;30 31 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1;32 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null;33 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null;34 35 if(isset($request['EDP_PRECHECK']) && isset($request['EDP_BILL_NO']) && isset($request['EDP_REC_ACCOUNT']) && isset($request['EDP_AMOUNT'])){36 if($request['EDP_PRECHECK'] == "YES") {37 if($request['EDP_REC_ACCOUNT'] == EDP_REC_ACCOUNT) {38 $bill_no = $request['EDP_BILL_NO'];39 40 // this code checks if $bill_no exists in your system orders if exists then echo OK otherwise28 global $wpdb, $arca_idram_config; 29 $request = $_REQUEST; 30 31 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1; 32 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null; 33 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null; 34 35 if(isset($request['EDP_PRECHECK']) && isset($request['EDP_BILL_NO']) && isset($request['EDP_REC_ACCOUNT']) && isset($request['EDP_AMOUNT'])){ 36 if($request['EDP_PRECHECK'] == "YES") { 37 if($request['EDP_REC_ACCOUNT'] == EDP_REC_ACCOUNT) { 38 $bill_no = $request['EDP_BILL_NO']; 39 40 // this code checks if $bill_no exists in your system orders if exists then echo OK otherwise 41 41 $result = $wpdb->get_var( 42 42 $wpdb->prepare( … … 47 47 if($result == 1){ 48 48 49 $OrderStatusExtended = json_encode( array( "Request 1 - confirm" => $_REQUEST ) );50 51 // update order row49 $OrderStatusExtended = json_encode( array( "Request 1 - confirm" => $_REQUEST ) ); 50 51 // update order row 52 52 $wpdb->query($wpdb->prepare( 53 53 "UPDATE " . $wpdb->prefix . "arca_pg_orders … … 60 60 )); 61 61 62 63 62 echo "OK"; 64 die;65 66 } else {67 echo "EDP_BILL_NO not found";68 die;69 }70 71 }72 }73 }74 75 if(isset($request['EDP_PAYER_ACCOUNT']) && isset($request['EDP_BILL_NO']) && isset($request['EDP_REC_ACCOUNT']) && isset($request['EDP_AMOUNT']) && isset($request['EDP_TRANS_ID']) && isset($request['EDP_CHECKSUM'])) {76 $txtToHash = EDP_REC_ACCOUNT . ":" . $request['EDP_AMOUNT'] . ":" . SECRET_KEY . ":" . $request['EDP_BILL_NO'] . ":" . $request['EDP_PAYER_ACCOUNT'] . ":" . $request['EDP_TRANS_ID'] . ":" . $request['EDP_TRANS_DATE'];77 if(strtoupper($request['EDP_CHECKSUM']) != strtoupper(md5($txtToHash))) {78 79 // please, write your code here to handle the payment fail80 81 // get previous stored requests63 die; 64 65 } else { 66 echo "EDP_BILL_NO not found"; 67 die; 68 } 69 70 } 71 } 72 } 73 74 if(isset($request['EDP_PAYER_ACCOUNT']) && isset($request['EDP_BILL_NO']) && isset($request['EDP_REC_ACCOUNT']) && isset($request['EDP_AMOUNT']) && isset($request['EDP_TRANS_ID']) && isset($request['EDP_CHECKSUM'])) { 75 $txtToHash = EDP_REC_ACCOUNT . ":" . $request['EDP_AMOUNT'] . ":" . SECRET_KEY . ":" . $request['EDP_BILL_NO'] . ":" . $request['EDP_PAYER_ACCOUNT'] . ":" . $request['EDP_TRANS_ID'] . ":" . $request['EDP_TRANS_DATE']; 76 if(strtoupper($request['EDP_CHECKSUM']) != strtoupper(md5($txtToHash))) { 77 78 // please, write your code here to handle the payment fail 79 80 // get previous stored requests 82 81 $OrderStatusExtended = json_decode( 83 82 $wpdb->get_var( … … 90 89 ); 91 90 92 93 91 // add new request 94 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Request 2 - fail" => $_REQUEST ) );95 96 $OrderStatusExtended = json_encode( $OrderStatusExtended );97 98 // update error number from REST system92 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Request 2 - fail" => $_REQUEST ) ); 93 94 $OrderStatusExtended = json_encode( $OrderStatusExtended ); 95 96 // update error number from REST system 99 97 $wpdb->query($wpdb->prepare( 100 98 "UPDATE " . $wpdb->prefix . "arca_pg_orders … … 107 105 108 106 echo "EDP_CHECKSUM not correct"; 109 die;110 111 } else {112 113 // please, write your code here to handle the payment success echo("OK");114 115 // get order payment state from REST response116 $paymentState = "DEPOSITED";117 118 // get previous stored requests107 die; 108 109 } else { 110 111 // please, write your code here to handle the payment success echo("OK"); 112 113 // get order payment state from REST response 114 $paymentState = "DEPOSITED"; 115 116 // get previous stored requests 119 117 $OrderStatusExtended = json_decode( 120 118 $wpdb->get_var( … … 127 125 ); 128 126 129 130 127 // add new request 131 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Request 2 - confirm" => $_REQUEST ) );132 133 $OrderStatusExtended = json_encode( $OrderStatusExtended );134 135 // update order payment REST response data128 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Request 2 - confirm" => $_REQUEST ) ); 129 130 $OrderStatusExtended = json_encode( $OrderStatusExtended ); 131 132 // update order payment REST response data 136 133 $wpdb->query($wpdb->prepare( 137 134 "UPDATE " . $wpdb->prefix . "arca_pg_orders … … 140 137 $OrderStatusExtended, 141 138 $paymentState, 142 $order Number // исправлено с orderId на orderNumber139 $orderId 143 140 )); 144 141 145 142 $wc_orderId = ( !empty($_REQUEST["wc_orderId"]) ) ? intval($_REQUEST["wc_orderId"]) : null; 146 $gwp_donationId = ( !empty($_REQUEST["gwp_donationId"]) ) ? intval($_REQUEST["gwp_donationId"]) : null; 147 148 // if woocommerce 149 if(isset($wc_orderId)) { 150 151 // get wc order 152 $apg_wc_order = wc_get_order($wc_orderId); 153 154 // get ws order status processing or failed 155 $apg_wc_orderStatus = ( $paymentState == 'DEPOSITED' ) ? $arca_idram_config->wc_order_status : 'failed'; 156 157 // set wc order status 158 $apg_wc_order->set_status($apg_wc_orderStatus, 'wc_apg_gatewey'); 159 $apg_wc_order->save(); 160 161 $apg_wc_order->reduce_order_stock(); 162 //WC()->cart->empty_cart(); 163 164 // set email sent if email exist in wc order 143 $gwp_donationId = ( !empty($_REQUEST["gwp_donationId"]) ) ? intval($_REQUEST["gwp_donationId"]) : null; 144 145 // if woocommerce 146 if(isset($wc_orderId)) { 147 148 // get wc order 149 $apg_wc_order = wc_get_order($wc_orderId); 150 151 // get ws order status processing or failed 152 $apg_wc_orderStatus = ( $paymentState == 'DEPOSITED' ) ? $arca_idram_config->wc_order_status : 'failed'; 153 154 155 // eHDM print for woocommerce orders 156 157 // end eHDM print 158 159 160 // set wc order status 161 $apg_wc_order->set_status($apg_wc_orderStatus, 'wc_apg_gatewey'); 162 $apg_wc_order->save(); 163 164 //$apg_wc_order->reduce_order_stock(); 165 WC()->cart->empty_cart(); 166 167 // set email sent if email exist in wc order 165 168 $wpdb->query($wpdb->prepare( 166 "UPDATE " . $wpdb->prefix . "arca_pg_orders167 SET mailSent = 1 168 WHERE orderNumber = % d",169 $order Number // исправлено с orderId на orderNumber169 "UPDATE {$wpdb->prefix}arca_pg_orders 170 SET mailSent = 1 171 WHERE orderNumber = %s", 172 $orderId 170 173 )); 171 174 172 175 // if give wp 173 } else if(isset($gwp_donationId)){174 175 // get give wp order status publish or failed176 $apg_givewp_orderStatus = ( $paymentState == 'DEPOSITED' ) ? 'publish' : 'failed';177 178 // set give wp donate status179 give_update_payment_status( $gwp_donationId, $apg_givewp_orderStatus );180 181 // set email sent if email exist in wc order176 } else if(isset($gwp_donationId)){ 177 178 // get give wp order status publish or failed 179 $apg_givewp_orderStatus = ( $paymentState == 'DEPOSITED' ) ? 'publish' : 'failed'; 180 181 // set give wp donate status 182 give_update_payment_status( $gwp_donationId, $apg_givewp_orderStatus ); 183 184 // set email sent if email exist in wc order 182 185 $wpdb->query($wpdb->prepare( 183 "UPDATE {$wpdb->prefix}arca_pg_orders 184 SET mailSent = 1 185 WHERE orderNumber = % d",186 $orderId // если это число186 "UPDATE {$wpdb->prefix}arca_pg_orders 187 SET mailSent = 1 188 WHERE orderNumber = %s", 189 $orderId 187 190 )); 188 191 189 192 // if tatiosa_booking 190 } else if(isset($tatiosa_booking_id)){ 191 192 $response = json_decode($response); 193 $response = $response->paymentAmountInfo; 194 195 // get ws order status processing or failed 196 $apg_booking_orderStatus = 1; //booking status, 0 (cancelled), 1 (confirmed), 2 (new), 3 (request) 197 $code = 0; 198 199 if( $apg_booking_orderStatus == 1){ 200 201 $tatiosa_booking_Key = wp_parse_url( get_site_url() )['host']; 202 $description = 'Paid via Credit Card'; 203 $payment_status = 'Successful'; 204 $amount = $response->approvedAmount; 205 206 207 // notify of payment status tatiosa.net 208 $booking_orderStatus_url = "https://tatiosa.net/api/custompaymentgateway/notify.php"; 209 $args = array( 210 'headers' => array('Content-Type: text/html; charset=UTF-8'), 211 'body' => array( 212 'key' => $tatiosa_booking_Key, 213 'bookid' => $tatiosa_booking_id, 214 'status' => $apg_booking_orderStatus, 215 'amount' => $amount, 216 'description' => $description, 217 'payment_status' => $payment_status, 218 ), 219 'method' => 'POST', 220 'data_format' => 'body', 221 ); 222 $response = wp_remote_post( $booking_orderStatus_url, $args ); 223 224 225 // get booking system status 226 $code = wp_remote_retrieve_response_code( $response ); 227 if($code != 200){ 228 arca_pg_errorCatch("Booking system respons error: " . json_encode($response, JSON_UNESCAPED_UNICODE), $wc_orderId, $gwp_donationId); 229 } 230 231 } 232 233 234 // get previous stored requests 235 //$OrderStatusExtended = json_decode( $wpdb->get_var("select OrderStatusExtended from " . $wpdb->prefix . "arca_pg_orders where orderId = '$orderId'"), true ); 193 } else if(isset($tatiosa_booking_id)){ 194 195 // get ws order status processing or failed 196 $apg_booking_orderStatus = 1; //booking status, 0 (cancelled), 1 (confirmed), 2 (new), 3 (request) 197 $code = 0; 198 199 if( $apg_booking_orderStatus == 1){ 200 201 $tatiosa_booking_Key = wp_parse_url( get_site_url() )['host']; 202 $description = 'Paid via Credit Card'; 203 $payment_status = 'Successful'; 204 205 // get amount for $orderId from orders 206 $amount = $wpdb->get_var($wpdb->prepare("SELECT amount from " . $wpdb->prefix . "arca_pg_orders where orderId = %s", $orderId)); 207 208 // notify of payment status tatiosa.net 209 $booking_orderStatus_url = "https://tatiosa.net/api/custompaymentgateway/notify.php"; 210 $args = array( 211 'headers' => array('Content-Type: text/html; charset=UTF-8'), 212 'body' => array( 213 'key' => $tatiosa_booking_Key, 214 'bookid' => $tatiosa_booking_id, 215 'status' => $apg_booking_orderStatus, 216 'amount' => $amount, 217 'description' => $description, 218 'payment_status' => $payment_status, 219 ), 220 'method' => 'POST', 221 'data_format' => 'body', 222 ); 223 $response = wp_remote_post( $booking_orderStatus_url, $args ); 224 225 226 // get booking system status 227 $code = wp_remote_retrieve_response_code( $response ); 228 if($code != 200){ 229 arca_pg_errorCatch("Booking system respons error: " . json_encode($response, JSON_UNESCAPED_UNICODE), $wc_orderId, $gwp_donationId); 230 } 231 232 } 233 234 // get previous stored requests 236 235 $OrderStatusExtended = json_decode( 237 236 $wpdb->get_var( … … 244 243 ); 245 244 246 // add new request247 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Booking System Response 1" => json_decode('{"Status": '.$code.'}', true) ) );248 249 $OrderStatusExtended = json_encode( $OrderStatusExtended );250 251 // update order payment REST response data245 // add new request 246 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Booking System Response 1" => json_decode('{"Status": '.$code.'}', true) ) ); 247 248 $OrderStatusExtended = json_encode( $OrderStatusExtended ); 249 250 // update order payment REST response data 252 251 $wpdb->query($wpdb->prepare( 253 "UPDATE {$wpdb->prefix}arca_pg_orders 254 SET OrderStatusExtended = %s, paymentState = %s 252 "UPDATE {$wpdb->prefix}arca_pg_orders 253 SET OrderStatusExtended = %s, paymentState = %s 255 254 WHERE orderId = %s", 256 255 $OrderStatusExtended, … … 261 260 } 262 261 263 echo "OK"; 264 die; 265 } 266 } 262 // eHDM print for apg, tatiosa orders 263 264 // end eHDM print 265 266 echo "OK"; 267 die; 268 } 269 } 267 270 268 271 } … … 270 273 function apg_wc_api_idram_complete(){ 271 274 272 global $wpdb;273 $request = $_REQUEST;274 275 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1;276 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null;277 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null;278 279 // if woocommerce280 if(isset($wc_orderId)) {281 282 // get wc return url283 $wc_apg_gatewey = new wc_apg_gatewey();284 285 // get wc order286 $apg_wc_order = wc_get_order($wc_orderId);287 288 // redirect to final page with REST payment state289 wp_redirect( $wc_apg_gatewey->get_return_url( $apg_wc_order ) );290 exit;291 292 // if give wp293 } else if(isset($gwp_donationId)){294 295 // redirect to final page with REST payment state296 give_send_to_success_page();297 exit;298 299 } else if(isset($tatiosa_booking_id)){300 301 302 303 }304 305 // get language306 $language = ( isset($_REQUEST["language"]) ) ? $_REQUEST["language"] : null;307 308 // get order payment state from REST response309 $paymentState = "DEPOSITED";310 311 // redirect to final page with REST payment state312 wp_redirect( arca_pg_checkOutPagePermalink($language) . "?state=$paymentState&orderId=$orderId");313 exit;275 global $wpdb; 276 $request = $_REQUEST; 277 278 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1; 279 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null; 280 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null; 281 282 // if woocommerce 283 if(isset($wc_orderId)) { 284 285 // get wc return url 286 $wc_apg_gatewey = new wc_apg_gatewey(); 287 288 // get wc order 289 $apg_wc_order = wc_get_order($wc_orderId); 290 291 // redirect to final page with REST payment state 292 wp_redirect( $wc_apg_gatewey->get_return_url( $apg_wc_order ) ); 293 exit; 294 295 // if give wp 296 } else if(isset($gwp_donationId)){ 297 298 // redirect to final page with REST payment state 299 give_send_to_success_page(); 300 exit; 301 302 } else if(isset($tatiosa_booking_id)){ 303 304 305 306 } 307 308 // get language 309 $language = ( isset($_REQUEST["language"]) ) ? $_REQUEST["language"] : null; 310 311 // get order payment state from REST response 312 $paymentState = "DEPOSITED"; 313 314 // redirect to final page with REST payment state 315 wp_redirect( arca_pg_checkOutPagePermalink($language) . "?state=$paymentState&orderId=$orderId"); 316 exit; 314 317 315 318 } … … 317 320 function apg_wc_api_idram_fail(){ 318 321 319 global $wpdb;320 $request = $_REQUEST;321 322 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1;323 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null;324 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null;325 326 // get previous stored requests322 global $wpdb; 323 $request = $_REQUEST; 324 325 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1; 326 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null; 327 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null; 328 329 // get previous stored requests 327 330 $OrderStatusExtended = json_decode( 328 331 $wpdb->get_var( … … 335 338 ); 336 339 337 // add new request338 $OrderStatusExtended = ( !empty($OrderStatusExtended) ) ? array_merge($OrderStatusExtended, array( "Request - fail" => $_REQUEST ) ) : array( "Request - fail" => $_REQUEST ) ;339 340 $OrderStatusExtended = json_encode( $OrderStatusExtended );341 342 // update error number from REST system340 // add new request 341 $OrderStatusExtended = ( !empty($OrderStatusExtended) ) ? array_merge($OrderStatusExtended, array( "Request - fail" => $_REQUEST ) ) : array( "Request - fail" => $_REQUEST ) ; 342 343 $OrderStatusExtended = json_encode( $OrderStatusExtended ); 344 345 // update error number from REST system 343 346 $wpdb->query($wpdb->prepare( 344 347 "UPDATE {$wpdb->prefix}arca_pg_orders … … 359 362 if ($arca_process == "idram"){ 360 363 361 // data validation362 $errMgs = array();363 364 // get form data or defaults values365 $wc_orderId = ( !empty($_REQUEST["wc_orderId"]) ) ? intval($_REQUEST["wc_orderId"]) : null;366 $gwp_donationId = ( !empty($_REQUEST["gwp_donationId"]) ) ? intval($_REQUEST["gwp_donationId"]) : null;367 $productId = ( !empty($_REQUEST["productId"]) ) ? intval($_REQUEST["productId"]) : 0;368 $amount = ( !empty($_REQUEST["amount"]) ) ? doubleval($_REQUEST["amount"]) : 0;369 $description = ( !empty($_REQUEST["description"]) ) ? sanitize_text_field($_REQUEST["description"]) : __( "Online payment", 'arca-payment-gateway' );370 $language = ( !empty($_REQUEST["language"]) ) ? sanitize_text_field($_REQUEST["language"]) : $arca_idram_config->default_language;371 $currency = ( !empty($_REQUEST["currency"]) ) ? sanitize_text_field($_REQUEST["currency"]) : "051";364 // data validation 365 $errMgs = array(); 366 367 // get form data or defaults values 368 $wc_orderId = ( !empty($_REQUEST["wc_orderId"]) ) ? intval($_REQUEST["wc_orderId"]) : null; 369 $gwp_donationId = ( !empty($_REQUEST["gwp_donationId"]) ) ? intval($_REQUEST["gwp_donationId"]) : null; 370 $productId = ( !empty($_REQUEST["productId"]) ) ? intval($_REQUEST["productId"]) : 0; 371 $amount = ( !empty($_REQUEST["amount"]) ) ? doubleval($_REQUEST["amount"]) : 0; 372 $description = ( !empty($_REQUEST["description"]) ) ? sanitize_text_field($_REQUEST["description"]) : __( "Online payment", 'arca-payment-gateway' ); 373 $language = ( !empty($_REQUEST["language"]) ) ? sanitize_text_field($_REQUEST["language"]) : $arca_idram_config->default_language; 374 $currency = ( !empty($_REQUEST["currency"]) ) ? sanitize_text_field($_REQUEST["currency"]) : "051"; 372 375 $custom_amount = ( !empty($_REQUEST["custom_amount"]) && intval($_REQUEST["custom_amount"]) == 1 ) ? 1 : 0; 373 376 374 // get payment initiator, woocommerce, givewp or apg375 if(isset($wc_orderId)) {376 377 // get wc order378 $apg_wc_order = wc_get_order($wc_orderId);379 380 // get order total amount381 $amount = $apg_wc_order->get_total();382 383 // validate currency384 $currency = ($apg_wc_order->get_currency()) == "AMD" ? "051" : null;385 if ( $currency != "051") array_push($errMgs, "Incorect currency:" . $currency);386 387 } else if (isset($gwp_donationId)) {388 389 // get give wp donation amount390 $amount = give_donation_amount($gwp_donationId);391 392 // get give wp donation currency abbr393 $apg_givewp_currency = (give_get_payment_currency_code($gwp_donationId)) == "AMD" ? "051" : null;394 395 // validate currency396 if ( $apg_givewp_currency != "051") array_push($errMgs, "Incorect currency:" . $apg_givewp_currency);397 398 } else {399 400 if($custom_amount == 0){401 402 // validate productId377 // get payment initiator, woocommerce, givewp or apg 378 if(isset($wc_orderId)) { 379 380 // get wc order 381 $apg_wc_order = wc_get_order($wc_orderId); 382 383 // get order total amount 384 $amount = $apg_wc_order->get_total(); 385 386 // validate currency 387 $currency = ($apg_wc_order->get_currency()) == "AMD" ? "051" : null; 388 if ( $currency != "051") array_push($errMgs, "Incorect currency:" . $currency); 389 390 } else if (isset($gwp_donationId)) { 391 392 // get give wp donation amount 393 $amount = give_donation_amount($gwp_donationId); 394 395 // get give wp donation currency abbr 396 $apg_givewp_currency = (give_get_payment_currency_code($gwp_donationId)) == "AMD" ? "051" : null; 397 398 // validate currency 399 if ( $apg_givewp_currency != "051") array_push($errMgs, "Incorect currency:" . $apg_givewp_currency); 400 401 } else { 402 403 if($custom_amount == 0){ 404 405 // validate productId 403 406 $resultCount = $wpdb->get_var( 404 407 $wpdb->prepare( … … 410 413 if ($resultCount == 0) array_push($errMgs, "incorrect productId:" . $productId); 411 414 412 // get product details415 // get product details 413 416 $priceList = $wpdb->get_row( 414 417 $wpdb->prepare( … … 418 421 ); 419 422 420 // get price, validate price421 $amount = arca_pg_getPriceFromJson($priceList->productPrice, $currency);422 if ($amount == 0) array_push($errMgs, "Incorrect amount:" . $amount . " with the currency:" . $currency);423 424 }425 426 // validate currency427 if ( $currency != "051") array_push($errMgs, "Incorect currency:" . $currency);428 429 }430 431 // validate language423 // get price, validate price 424 $amount = arca_pg_getPriceFromJson($priceList->productPrice, $currency); 425 if ($amount == 0) array_push($errMgs, "Incorrect amount:" . $amount . " with the currency:" . $currency); 426 427 } 428 429 // validate currency 430 if ( $currency != "051") array_push($errMgs, "Incorect currency:" . $currency); 431 432 } 433 434 // validate language 432 435 $resultCount = $wpdb->get_var($wpdb->prepare( 433 436 "SELECT COUNT(*) FROM {$wpdb->prefix}arca_pg_language WHERE code = %s", … … 437 440 if ($resultCount == 0) $language = $arca_idram_config->default_language; 438 441 439 // validate checkout form permalink440 if (arca_pg_checkOutPagePermalink() == false) array_push($errMgs, "Checkout form not found");441 442 // get orderDetails443 $orderDetails = json_encode($_REQUEST, JSON_UNESCAPED_UNICODE);444 445 // validation446 if (empty($errMgs)){447 448 // create order blank row in db449 $table = $wpdb->prefix . 'arca_pg_orders';450 $data = array(451 'productId' => $productId,452 'wc_orderId' => $wc_orderId,453 //'gwp_donationId' => $gwp_donationId,454 'amount' => $amount,455 'currency' => $currency,456 'orderDetails' => $orderDetails,457 'rest_serverID' => ($arca_idram_config->testMode) ? 2 : 1,458 'orderDate' => current_time('mysql'),442 // validate checkout form permalink 443 if (arca_pg_checkOutPagePermalink() == false) array_push($errMgs, "Checkout form not found"); 444 445 // get orderDetails 446 $orderDetails = json_encode($_REQUEST, JSON_UNESCAPED_UNICODE); 447 448 // validation 449 if (empty($errMgs)){ 450 451 // create order blank row in db 452 $table = $wpdb->prefix . 'arca_pg_orders'; 453 $data = array( 454 'productId' => $productId, 455 'wc_orderId' => $wc_orderId, 456 //'gwp_donationId' => $gwp_donationId, 457 'amount' => $amount, 458 'currency' => $currency, 459 'orderDetails' => $orderDetails, 460 'rest_serverID' => ($arca_idram_config->testMode) ? 2 : 1, 461 'orderDate' => current_time('mysql'), 459 462 'bankId' => 12, // iDram 460 ); 461 $format = array( 462 '%d', 463 '%d', 464 //'%d', 465 '%f', 466 '%s', 467 '%s', 468 '%d', 463 ); 464 $format = array( 465 '%d', 466 '%d', 467 //'%d', 468 '%f', 469 '%s', 469 470 '%s', 470 471 '%d', 471 ); 472 $insert = $wpdb->insert($table, $data, $format); 473 if ($insert){ 474 475 // get orderNumber from created row 476 $orderNumber = $wpdb->insert_id; 472 '%s', 473 '%d', 474 ); 475 $insert = $wpdb->insert($table, $data, $format); 476 if ($insert){ 477 478 // get orderNumber from created row 479 $orderNumber = $wpdb->insert_id; 477 480 478 481 // create idram submit form … … 494 497 die; 495 498 496 } else {497 arca_pg_errorCatch("Error on insert new order row, wpdb error: " . $wpdb->error, $wc_orderId, $gwp_donationId);498 }499 500 } else {501 arca_pg_errorCatch("Data validation error: " . implode(', ', $errMgs), $wc_orderId, $gwp_donationId);502 }499 } else { 500 arca_pg_errorCatch("Error on insert new order row, wpdb error: " . $wpdb->error, $wc_orderId, $gwp_donationId); 501 } 502 503 } else { 504 arca_pg_errorCatch("Data validation error: " . implode(', ', $errMgs), $wc_orderId, $gwp_donationId); 505 } 503 506 504 507 } -
arca-payment-gateway/tags/1.4.9/includes/apg-wc.php
r3240719 r3242781 31 31 32 32 // subscription Хук для продления подписок 33 //add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'process_subscription_payment'), 10, 2);33 // add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'process_subscription_payment'), 10, 2); 34 34 } 35 35 -
arca-payment-gateway/tags/1.4.9/readme.txt
r3241730 r3242781 5 5 Requires PHP: 7.4 6 6 Tested up to: 6.7.2 7 Stable tag: 1.4. 87 Stable tag: 1.4.9 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 125 125 == Changelog == 126 126 127 = 1.4.9 = 128 *Fixed idram endpoint bug 129 127 130 = 1.4.8 = 128 131 *Fixed wc blocks bugs -
arca-payment-gateway/trunk/arca-payment-gateway.php
r3241730 r3242781 3 3 * Plugin Name: Planet Studio Payment Gateway for ArCa 4 4 * Description: This Plugin allows you to accept online payments from local and international customers to Armenian banks, Idram payment system and adds ArCa paycenter as a payment gateway for WooCommerce and for GiveWP donation Plugin and TATIOSA hotel booking management platform. 5 * Version: 1.4. 85 * Version: 1.4.9 6 6 * Author: Planet Studio team 7 7 * Author URI: https://planetstudio.am … … 15 15 define('ARCAPG_DIR_NAME', dirname(plugin_basename( __FILE__ ))); 16 16 define('ARCAPG_URL', plugins_url(plugin_basename(dirname(__FILE__)))); 17 define('ARCAPG_VERSION', '1.4. 8');17 define('ARCAPG_VERSION', '1.4.9'); 18 18 define('ARCAPG_PRO', FALSE); 19 19 define('ARCAPG_DELETE_DATA_ACTIONS', false); -
arca-payment-gateway/trunk/endpoints/apg-idram.php
r3240719 r3242781 15 15 16 16 if ( !class_exists('woocommerce') ) { 17 add_filter( 'request', function($query_vars){18 if( isset($query_vars['wc-api']) ){19 do_action( 'woocommerce_api_'. $query_vars['wc-api'] );20 die;21 }22 return $query_vars;23 });17 add_filter( 'request', function($query_vars){ 18 if( isset($query_vars['wc-api']) ){ 19 do_action( 'woocommerce_api_'. $query_vars['wc-api'] ); 20 die; 21 } 22 return $query_vars; 23 }); 24 24 } 25 25 26 26 function apg_wc_api_idram_result(){ 27 27 28 global $wpdb, $arca_idram_config;29 $request = $_REQUEST;30 31 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1;32 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null;33 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null;34 35 if(isset($request['EDP_PRECHECK']) && isset($request['EDP_BILL_NO']) && isset($request['EDP_REC_ACCOUNT']) && isset($request['EDP_AMOUNT'])){36 if($request['EDP_PRECHECK'] == "YES") {37 if($request['EDP_REC_ACCOUNT'] == EDP_REC_ACCOUNT) {38 $bill_no = $request['EDP_BILL_NO'];39 40 // this code checks if $bill_no exists in your system orders if exists then echo OK otherwise28 global $wpdb, $arca_idram_config; 29 $request = $_REQUEST; 30 31 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1; 32 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null; 33 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null; 34 35 if(isset($request['EDP_PRECHECK']) && isset($request['EDP_BILL_NO']) && isset($request['EDP_REC_ACCOUNT']) && isset($request['EDP_AMOUNT'])){ 36 if($request['EDP_PRECHECK'] == "YES") { 37 if($request['EDP_REC_ACCOUNT'] == EDP_REC_ACCOUNT) { 38 $bill_no = $request['EDP_BILL_NO']; 39 40 // this code checks if $bill_no exists in your system orders if exists then echo OK otherwise 41 41 $result = $wpdb->get_var( 42 42 $wpdb->prepare( … … 47 47 if($result == 1){ 48 48 49 $OrderStatusExtended = json_encode( array( "Request 1 - confirm" => $_REQUEST ) );50 51 // update order row49 $OrderStatusExtended = json_encode( array( "Request 1 - confirm" => $_REQUEST ) ); 50 51 // update order row 52 52 $wpdb->query($wpdb->prepare( 53 53 "UPDATE " . $wpdb->prefix . "arca_pg_orders … … 60 60 )); 61 61 62 63 62 echo "OK"; 64 die;65 66 } else {67 echo "EDP_BILL_NO not found";68 die;69 }70 71 }72 }73 }74 75 if(isset($request['EDP_PAYER_ACCOUNT']) && isset($request['EDP_BILL_NO']) && isset($request['EDP_REC_ACCOUNT']) && isset($request['EDP_AMOUNT']) && isset($request['EDP_TRANS_ID']) && isset($request['EDP_CHECKSUM'])) {76 $txtToHash = EDP_REC_ACCOUNT . ":" . $request['EDP_AMOUNT'] . ":" . SECRET_KEY . ":" . $request['EDP_BILL_NO'] . ":" . $request['EDP_PAYER_ACCOUNT'] . ":" . $request['EDP_TRANS_ID'] . ":" . $request['EDP_TRANS_DATE'];77 if(strtoupper($request['EDP_CHECKSUM']) != strtoupper(md5($txtToHash))) {78 79 // please, write your code here to handle the payment fail80 81 // get previous stored requests63 die; 64 65 } else { 66 echo "EDP_BILL_NO not found"; 67 die; 68 } 69 70 } 71 } 72 } 73 74 if(isset($request['EDP_PAYER_ACCOUNT']) && isset($request['EDP_BILL_NO']) && isset($request['EDP_REC_ACCOUNT']) && isset($request['EDP_AMOUNT']) && isset($request['EDP_TRANS_ID']) && isset($request['EDP_CHECKSUM'])) { 75 $txtToHash = EDP_REC_ACCOUNT . ":" . $request['EDP_AMOUNT'] . ":" . SECRET_KEY . ":" . $request['EDP_BILL_NO'] . ":" . $request['EDP_PAYER_ACCOUNT'] . ":" . $request['EDP_TRANS_ID'] . ":" . $request['EDP_TRANS_DATE']; 76 if(strtoupper($request['EDP_CHECKSUM']) != strtoupper(md5($txtToHash))) { 77 78 // please, write your code here to handle the payment fail 79 80 // get previous stored requests 82 81 $OrderStatusExtended = json_decode( 83 82 $wpdb->get_var( … … 90 89 ); 91 90 92 93 91 // add new request 94 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Request 2 - fail" => $_REQUEST ) );95 96 $OrderStatusExtended = json_encode( $OrderStatusExtended );97 98 // update error number from REST system92 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Request 2 - fail" => $_REQUEST ) ); 93 94 $OrderStatusExtended = json_encode( $OrderStatusExtended ); 95 96 // update error number from REST system 99 97 $wpdb->query($wpdb->prepare( 100 98 "UPDATE " . $wpdb->prefix . "arca_pg_orders … … 107 105 108 106 echo "EDP_CHECKSUM not correct"; 109 die;110 111 } else {112 113 // please, write your code here to handle the payment success echo("OK");114 115 // get order payment state from REST response116 $paymentState = "DEPOSITED";117 118 // get previous stored requests107 die; 108 109 } else { 110 111 // please, write your code here to handle the payment success echo("OK"); 112 113 // get order payment state from REST response 114 $paymentState = "DEPOSITED"; 115 116 // get previous stored requests 119 117 $OrderStatusExtended = json_decode( 120 118 $wpdb->get_var( … … 127 125 ); 128 126 129 130 127 // add new request 131 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Request 2 - confirm" => $_REQUEST ) );132 133 $OrderStatusExtended = json_encode( $OrderStatusExtended );134 135 // update order payment REST response data128 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Request 2 - confirm" => $_REQUEST ) ); 129 130 $OrderStatusExtended = json_encode( $OrderStatusExtended ); 131 132 // update order payment REST response data 136 133 $wpdb->query($wpdb->prepare( 137 134 "UPDATE " . $wpdb->prefix . "arca_pg_orders … … 140 137 $OrderStatusExtended, 141 138 $paymentState, 142 $order Number // исправлено с orderId на orderNumber139 $orderId 143 140 )); 144 141 145 142 $wc_orderId = ( !empty($_REQUEST["wc_orderId"]) ) ? intval($_REQUEST["wc_orderId"]) : null; 146 $gwp_donationId = ( !empty($_REQUEST["gwp_donationId"]) ) ? intval($_REQUEST["gwp_donationId"]) : null; 147 148 // if woocommerce 149 if(isset($wc_orderId)) { 150 151 // get wc order 152 $apg_wc_order = wc_get_order($wc_orderId); 153 154 // get ws order status processing or failed 155 $apg_wc_orderStatus = ( $paymentState == 'DEPOSITED' ) ? $arca_idram_config->wc_order_status : 'failed'; 156 157 // set wc order status 158 $apg_wc_order->set_status($apg_wc_orderStatus, 'wc_apg_gatewey'); 159 $apg_wc_order->save(); 160 161 $apg_wc_order->reduce_order_stock(); 162 //WC()->cart->empty_cart(); 163 164 // set email sent if email exist in wc order 143 $gwp_donationId = ( !empty($_REQUEST["gwp_donationId"]) ) ? intval($_REQUEST["gwp_donationId"]) : null; 144 145 // if woocommerce 146 if(isset($wc_orderId)) { 147 148 // get wc order 149 $apg_wc_order = wc_get_order($wc_orderId); 150 151 // get ws order status processing or failed 152 $apg_wc_orderStatus = ( $paymentState == 'DEPOSITED' ) ? $arca_idram_config->wc_order_status : 'failed'; 153 154 155 // eHDM print for woocommerce orders 156 157 // end eHDM print 158 159 160 // set wc order status 161 $apg_wc_order->set_status($apg_wc_orderStatus, 'wc_apg_gatewey'); 162 $apg_wc_order->save(); 163 164 //$apg_wc_order->reduce_order_stock(); 165 WC()->cart->empty_cart(); 166 167 // set email sent if email exist in wc order 165 168 $wpdb->query($wpdb->prepare( 166 "UPDATE " . $wpdb->prefix . "arca_pg_orders167 SET mailSent = 1 168 WHERE orderNumber = % d",169 $order Number // исправлено с orderId на orderNumber169 "UPDATE {$wpdb->prefix}arca_pg_orders 170 SET mailSent = 1 171 WHERE orderNumber = %s", 172 $orderId 170 173 )); 171 174 172 175 // if give wp 173 } else if(isset($gwp_donationId)){174 175 // get give wp order status publish or failed176 $apg_givewp_orderStatus = ( $paymentState == 'DEPOSITED' ) ? 'publish' : 'failed';177 178 // set give wp donate status179 give_update_payment_status( $gwp_donationId, $apg_givewp_orderStatus );180 181 // set email sent if email exist in wc order176 } else if(isset($gwp_donationId)){ 177 178 // get give wp order status publish or failed 179 $apg_givewp_orderStatus = ( $paymentState == 'DEPOSITED' ) ? 'publish' : 'failed'; 180 181 // set give wp donate status 182 give_update_payment_status( $gwp_donationId, $apg_givewp_orderStatus ); 183 184 // set email sent if email exist in wc order 182 185 $wpdb->query($wpdb->prepare( 183 "UPDATE {$wpdb->prefix}arca_pg_orders 184 SET mailSent = 1 185 WHERE orderNumber = % d",186 $orderId // если это число186 "UPDATE {$wpdb->prefix}arca_pg_orders 187 SET mailSent = 1 188 WHERE orderNumber = %s", 189 $orderId 187 190 )); 188 191 189 192 // if tatiosa_booking 190 } else if(isset($tatiosa_booking_id)){ 191 192 $response = json_decode($response); 193 $response = $response->paymentAmountInfo; 194 195 // get ws order status processing or failed 196 $apg_booking_orderStatus = 1; //booking status, 0 (cancelled), 1 (confirmed), 2 (new), 3 (request) 197 $code = 0; 198 199 if( $apg_booking_orderStatus == 1){ 200 201 $tatiosa_booking_Key = wp_parse_url( get_site_url() )['host']; 202 $description = 'Paid via Credit Card'; 203 $payment_status = 'Successful'; 204 $amount = $response->approvedAmount; 205 206 207 // notify of payment status tatiosa.net 208 $booking_orderStatus_url = "https://tatiosa.net/api/custompaymentgateway/notify.php"; 209 $args = array( 210 'headers' => array('Content-Type: text/html; charset=UTF-8'), 211 'body' => array( 212 'key' => $tatiosa_booking_Key, 213 'bookid' => $tatiosa_booking_id, 214 'status' => $apg_booking_orderStatus, 215 'amount' => $amount, 216 'description' => $description, 217 'payment_status' => $payment_status, 218 ), 219 'method' => 'POST', 220 'data_format' => 'body', 221 ); 222 $response = wp_remote_post( $booking_orderStatus_url, $args ); 223 224 225 // get booking system status 226 $code = wp_remote_retrieve_response_code( $response ); 227 if($code != 200){ 228 arca_pg_errorCatch("Booking system respons error: " . json_encode($response, JSON_UNESCAPED_UNICODE), $wc_orderId, $gwp_donationId); 229 } 230 231 } 232 233 234 // get previous stored requests 235 //$OrderStatusExtended = json_decode( $wpdb->get_var("select OrderStatusExtended from " . $wpdb->prefix . "arca_pg_orders where orderId = '$orderId'"), true ); 193 } else if(isset($tatiosa_booking_id)){ 194 195 // get ws order status processing or failed 196 $apg_booking_orderStatus = 1; //booking status, 0 (cancelled), 1 (confirmed), 2 (new), 3 (request) 197 $code = 0; 198 199 if( $apg_booking_orderStatus == 1){ 200 201 $tatiosa_booking_Key = wp_parse_url( get_site_url() )['host']; 202 $description = 'Paid via Credit Card'; 203 $payment_status = 'Successful'; 204 205 // get amount for $orderId from orders 206 $amount = $wpdb->get_var($wpdb->prepare("SELECT amount from " . $wpdb->prefix . "arca_pg_orders where orderId = %s", $orderId)); 207 208 // notify of payment status tatiosa.net 209 $booking_orderStatus_url = "https://tatiosa.net/api/custompaymentgateway/notify.php"; 210 $args = array( 211 'headers' => array('Content-Type: text/html; charset=UTF-8'), 212 'body' => array( 213 'key' => $tatiosa_booking_Key, 214 'bookid' => $tatiosa_booking_id, 215 'status' => $apg_booking_orderStatus, 216 'amount' => $amount, 217 'description' => $description, 218 'payment_status' => $payment_status, 219 ), 220 'method' => 'POST', 221 'data_format' => 'body', 222 ); 223 $response = wp_remote_post( $booking_orderStatus_url, $args ); 224 225 226 // get booking system status 227 $code = wp_remote_retrieve_response_code( $response ); 228 if($code != 200){ 229 arca_pg_errorCatch("Booking system respons error: " . json_encode($response, JSON_UNESCAPED_UNICODE), $wc_orderId, $gwp_donationId); 230 } 231 232 } 233 234 // get previous stored requests 236 235 $OrderStatusExtended = json_decode( 237 236 $wpdb->get_var( … … 244 243 ); 245 244 246 // add new request247 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Booking System Response 1" => json_decode('{"Status": '.$code.'}', true) ) );248 249 $OrderStatusExtended = json_encode( $OrderStatusExtended );250 251 // update order payment REST response data245 // add new request 246 $OrderStatusExtended = array_merge($OrderStatusExtended, array( "Booking System Response 1" => json_decode('{"Status": '.$code.'}', true) ) ); 247 248 $OrderStatusExtended = json_encode( $OrderStatusExtended ); 249 250 // update order payment REST response data 252 251 $wpdb->query($wpdb->prepare( 253 "UPDATE {$wpdb->prefix}arca_pg_orders 254 SET OrderStatusExtended = %s, paymentState = %s 252 "UPDATE {$wpdb->prefix}arca_pg_orders 253 SET OrderStatusExtended = %s, paymentState = %s 255 254 WHERE orderId = %s", 256 255 $OrderStatusExtended, … … 261 260 } 262 261 263 echo "OK"; 264 die; 265 } 266 } 262 // eHDM print for apg, tatiosa orders 263 264 // end eHDM print 265 266 echo "OK"; 267 die; 268 } 269 } 267 270 268 271 } … … 270 273 function apg_wc_api_idram_complete(){ 271 274 272 global $wpdb;273 $request = $_REQUEST;274 275 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1;276 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null;277 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null;278 279 // if woocommerce280 if(isset($wc_orderId)) {281 282 // get wc return url283 $wc_apg_gatewey = new wc_apg_gatewey();284 285 // get wc order286 $apg_wc_order = wc_get_order($wc_orderId);287 288 // redirect to final page with REST payment state289 wp_redirect( $wc_apg_gatewey->get_return_url( $apg_wc_order ) );290 exit;291 292 // if give wp293 } else if(isset($gwp_donationId)){294 295 // redirect to final page with REST payment state296 give_send_to_success_page();297 exit;298 299 } else if(isset($tatiosa_booking_id)){300 301 302 303 }304 305 // get language306 $language = ( isset($_REQUEST["language"]) ) ? $_REQUEST["language"] : null;307 308 // get order payment state from REST response309 $paymentState = "DEPOSITED";310 311 // redirect to final page with REST payment state312 wp_redirect( arca_pg_checkOutPagePermalink($language) . "?state=$paymentState&orderId=$orderId");313 exit;275 global $wpdb; 276 $request = $_REQUEST; 277 278 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1; 279 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null; 280 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null; 281 282 // if woocommerce 283 if(isset($wc_orderId)) { 284 285 // get wc return url 286 $wc_apg_gatewey = new wc_apg_gatewey(); 287 288 // get wc order 289 $apg_wc_order = wc_get_order($wc_orderId); 290 291 // redirect to final page with REST payment state 292 wp_redirect( $wc_apg_gatewey->get_return_url( $apg_wc_order ) ); 293 exit; 294 295 // if give wp 296 } else if(isset($gwp_donationId)){ 297 298 // redirect to final page with REST payment state 299 give_send_to_success_page(); 300 exit; 301 302 } else if(isset($tatiosa_booking_id)){ 303 304 305 306 } 307 308 // get language 309 $language = ( isset($_REQUEST["language"]) ) ? $_REQUEST["language"] : null; 310 311 // get order payment state from REST response 312 $paymentState = "DEPOSITED"; 313 314 // redirect to final page with REST payment state 315 wp_redirect( arca_pg_checkOutPagePermalink($language) . "?state=$paymentState&orderId=$orderId"); 316 exit; 314 317 315 318 } … … 317 320 function apg_wc_api_idram_fail(){ 318 321 319 global $wpdb;320 $request = $_REQUEST;321 322 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1;323 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null;324 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null;325 326 // get previous stored requests322 global $wpdb; 323 $request = $_REQUEST; 324 325 $orderNumber = $orderId = ( !empty($request["EDP_BILL_NO"]) ) ? intval($request["EDP_BILL_NO"]) : -1; 326 $wc_orderId = ( !empty($request["wc_orderId"]) ) ? intval($request["wc_orderId"]) : null; 327 $gwp_donationId = ( !empty($request["gwp_donationId"]) ) ? intval($request["gwp_donationId"]) : null; 328 329 // get previous stored requests 327 330 $OrderStatusExtended = json_decode( 328 331 $wpdb->get_var( … … 335 338 ); 336 339 337 // add new request338 $OrderStatusExtended = ( !empty($OrderStatusExtended) ) ? array_merge($OrderStatusExtended, array( "Request - fail" => $_REQUEST ) ) : array( "Request - fail" => $_REQUEST ) ;339 340 $OrderStatusExtended = json_encode( $OrderStatusExtended );341 342 // update error number from REST system340 // add new request 341 $OrderStatusExtended = ( !empty($OrderStatusExtended) ) ? array_merge($OrderStatusExtended, array( "Request - fail" => $_REQUEST ) ) : array( "Request - fail" => $_REQUEST ) ; 342 343 $OrderStatusExtended = json_encode( $OrderStatusExtended ); 344 345 // update error number from REST system 343 346 $wpdb->query($wpdb->prepare( 344 347 "UPDATE {$wpdb->prefix}arca_pg_orders … … 359 362 if ($arca_process == "idram"){ 360 363 361 // data validation362 $errMgs = array();363 364 // get form data or defaults values365 $wc_orderId = ( !empty($_REQUEST["wc_orderId"]) ) ? intval($_REQUEST["wc_orderId"]) : null;366 $gwp_donationId = ( !empty($_REQUEST["gwp_donationId"]) ) ? intval($_REQUEST["gwp_donationId"]) : null;367 $productId = ( !empty($_REQUEST["productId"]) ) ? intval($_REQUEST["productId"]) : 0;368 $amount = ( !empty($_REQUEST["amount"]) ) ? doubleval($_REQUEST["amount"]) : 0;369 $description = ( !empty($_REQUEST["description"]) ) ? sanitize_text_field($_REQUEST["description"]) : __( "Online payment", 'arca-payment-gateway' );370 $language = ( !empty($_REQUEST["language"]) ) ? sanitize_text_field($_REQUEST["language"]) : $arca_idram_config->default_language;371 $currency = ( !empty($_REQUEST["currency"]) ) ? sanitize_text_field($_REQUEST["currency"]) : "051";364 // data validation 365 $errMgs = array(); 366 367 // get form data or defaults values 368 $wc_orderId = ( !empty($_REQUEST["wc_orderId"]) ) ? intval($_REQUEST["wc_orderId"]) : null; 369 $gwp_donationId = ( !empty($_REQUEST["gwp_donationId"]) ) ? intval($_REQUEST["gwp_donationId"]) : null; 370 $productId = ( !empty($_REQUEST["productId"]) ) ? intval($_REQUEST["productId"]) : 0; 371 $amount = ( !empty($_REQUEST["amount"]) ) ? doubleval($_REQUEST["amount"]) : 0; 372 $description = ( !empty($_REQUEST["description"]) ) ? sanitize_text_field($_REQUEST["description"]) : __( "Online payment", 'arca-payment-gateway' ); 373 $language = ( !empty($_REQUEST["language"]) ) ? sanitize_text_field($_REQUEST["language"]) : $arca_idram_config->default_language; 374 $currency = ( !empty($_REQUEST["currency"]) ) ? sanitize_text_field($_REQUEST["currency"]) : "051"; 372 375 $custom_amount = ( !empty($_REQUEST["custom_amount"]) && intval($_REQUEST["custom_amount"]) == 1 ) ? 1 : 0; 373 376 374 // get payment initiator, woocommerce, givewp or apg375 if(isset($wc_orderId)) {376 377 // get wc order378 $apg_wc_order = wc_get_order($wc_orderId);379 380 // get order total amount381 $amount = $apg_wc_order->get_total();382 383 // validate currency384 $currency = ($apg_wc_order->get_currency()) == "AMD" ? "051" : null;385 if ( $currency != "051") array_push($errMgs, "Incorect currency:" . $currency);386 387 } else if (isset($gwp_donationId)) {388 389 // get give wp donation amount390 $amount = give_donation_amount($gwp_donationId);391 392 // get give wp donation currency abbr393 $apg_givewp_currency = (give_get_payment_currency_code($gwp_donationId)) == "AMD" ? "051" : null;394 395 // validate currency396 if ( $apg_givewp_currency != "051") array_push($errMgs, "Incorect currency:" . $apg_givewp_currency);397 398 } else {399 400 if($custom_amount == 0){401 402 // validate productId377 // get payment initiator, woocommerce, givewp or apg 378 if(isset($wc_orderId)) { 379 380 // get wc order 381 $apg_wc_order = wc_get_order($wc_orderId); 382 383 // get order total amount 384 $amount = $apg_wc_order->get_total(); 385 386 // validate currency 387 $currency = ($apg_wc_order->get_currency()) == "AMD" ? "051" : null; 388 if ( $currency != "051") array_push($errMgs, "Incorect currency:" . $currency); 389 390 } else if (isset($gwp_donationId)) { 391 392 // get give wp donation amount 393 $amount = give_donation_amount($gwp_donationId); 394 395 // get give wp donation currency abbr 396 $apg_givewp_currency = (give_get_payment_currency_code($gwp_donationId)) == "AMD" ? "051" : null; 397 398 // validate currency 399 if ( $apg_givewp_currency != "051") array_push($errMgs, "Incorect currency:" . $apg_givewp_currency); 400 401 } else { 402 403 if($custom_amount == 0){ 404 405 // validate productId 403 406 $resultCount = $wpdb->get_var( 404 407 $wpdb->prepare( … … 410 413 if ($resultCount == 0) array_push($errMgs, "incorrect productId:" . $productId); 411 414 412 // get product details415 // get product details 413 416 $priceList = $wpdb->get_row( 414 417 $wpdb->prepare( … … 418 421 ); 419 422 420 // get price, validate price421 $amount = arca_pg_getPriceFromJson($priceList->productPrice, $currency);422 if ($amount == 0) array_push($errMgs, "Incorrect amount:" . $amount . " with the currency:" . $currency);423 424 }425 426 // validate currency427 if ( $currency != "051") array_push($errMgs, "Incorect currency:" . $currency);428 429 }430 431 // validate language423 // get price, validate price 424 $amount = arca_pg_getPriceFromJson($priceList->productPrice, $currency); 425 if ($amount == 0) array_push($errMgs, "Incorrect amount:" . $amount . " with the currency:" . $currency); 426 427 } 428 429 // validate currency 430 if ( $currency != "051") array_push($errMgs, "Incorect currency:" . $currency); 431 432 } 433 434 // validate language 432 435 $resultCount = $wpdb->get_var($wpdb->prepare( 433 436 "SELECT COUNT(*) FROM {$wpdb->prefix}arca_pg_language WHERE code = %s", … … 437 440 if ($resultCount == 0) $language = $arca_idram_config->default_language; 438 441 439 // validate checkout form permalink440 if (arca_pg_checkOutPagePermalink() == false) array_push($errMgs, "Checkout form not found");441 442 // get orderDetails443 $orderDetails = json_encode($_REQUEST, JSON_UNESCAPED_UNICODE);444 445 // validation446 if (empty($errMgs)){447 448 // create order blank row in db449 $table = $wpdb->prefix . 'arca_pg_orders';450 $data = array(451 'productId' => $productId,452 'wc_orderId' => $wc_orderId,453 //'gwp_donationId' => $gwp_donationId,454 'amount' => $amount,455 'currency' => $currency,456 'orderDetails' => $orderDetails,457 'rest_serverID' => ($arca_idram_config->testMode) ? 2 : 1,458 'orderDate' => current_time('mysql'),442 // validate checkout form permalink 443 if (arca_pg_checkOutPagePermalink() == false) array_push($errMgs, "Checkout form not found"); 444 445 // get orderDetails 446 $orderDetails = json_encode($_REQUEST, JSON_UNESCAPED_UNICODE); 447 448 // validation 449 if (empty($errMgs)){ 450 451 // create order blank row in db 452 $table = $wpdb->prefix . 'arca_pg_orders'; 453 $data = array( 454 'productId' => $productId, 455 'wc_orderId' => $wc_orderId, 456 //'gwp_donationId' => $gwp_donationId, 457 'amount' => $amount, 458 'currency' => $currency, 459 'orderDetails' => $orderDetails, 460 'rest_serverID' => ($arca_idram_config->testMode) ? 2 : 1, 461 'orderDate' => current_time('mysql'), 459 462 'bankId' => 12, // iDram 460 ); 461 $format = array( 462 '%d', 463 '%d', 464 //'%d', 465 '%f', 466 '%s', 467 '%s', 468 '%d', 463 ); 464 $format = array( 465 '%d', 466 '%d', 467 //'%d', 468 '%f', 469 '%s', 469 470 '%s', 470 471 '%d', 471 ); 472 $insert = $wpdb->insert($table, $data, $format); 473 if ($insert){ 474 475 // get orderNumber from created row 476 $orderNumber = $wpdb->insert_id; 472 '%s', 473 '%d', 474 ); 475 $insert = $wpdb->insert($table, $data, $format); 476 if ($insert){ 477 478 // get orderNumber from created row 479 $orderNumber = $wpdb->insert_id; 477 480 478 481 // create idram submit form … … 494 497 die; 495 498 496 } else {497 arca_pg_errorCatch("Error on insert new order row, wpdb error: " . $wpdb->error, $wc_orderId, $gwp_donationId);498 }499 500 } else {501 arca_pg_errorCatch("Data validation error: " . implode(', ', $errMgs), $wc_orderId, $gwp_donationId);502 }499 } else { 500 arca_pg_errorCatch("Error on insert new order row, wpdb error: " . $wpdb->error, $wc_orderId, $gwp_donationId); 501 } 502 503 } else { 504 arca_pg_errorCatch("Data validation error: " . implode(', ', $errMgs), $wc_orderId, $gwp_donationId); 505 } 503 506 504 507 } -
arca-payment-gateway/trunk/includes/apg-wc.php
r3240719 r3242781 31 31 32 32 // subscription Хук для продления подписок 33 //add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'process_subscription_payment'), 10, 2);33 // add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'process_subscription_payment'), 10, 2); 34 34 } 35 35 -
arca-payment-gateway/trunk/readme.txt
r3241730 r3242781 5 5 Requires PHP: 7.4 6 6 Tested up to: 6.7.2 7 Stable tag: 1.4. 87 Stable tag: 1.4.9 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 125 125 == Changelog == 126 126 127 = 1.4.9 = 128 *Fixed idram endpoint bug 129 127 130 = 1.4.8 = 128 131 *Fixed wc blocks bugs
Note: See TracChangeset
for help on using the changeset viewer.