Changeset 3178082
- Timestamp:
- 10/29/2024 02:00:11 PM (17 months ago)
- Location:
- trustistecommerce/trunk
- Files:
-
- 3 edited
-
includes/gravityforms/TrustistGFPayments.php (modified) (7 diffs)
-
readme.txt (modified) (1 diff)
-
trustist-ecommerce.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trustistecommerce/trunk/includes/gravityforms/TrustistGFPayments.php
r3131773 r3178082 295 295 'required' => false, 296 296 ], 297 [ 298 'name' => 'description', 299 'label' => esc_html__('Description', 'trustistgfm'), 300 'required' => false, 301 ], 297 302 ); 298 303 … … 361 366 362 367 $redirect_url = $this->return_url($form['id'], $entry['id']); 363 $cancel_url = !empty($feed_meta['cancel_url']) && $feed_meta['cancel_url'] ? $ feed_meta['cancel_url']: $redirect_url;368 $cancel_url = !empty($feed_meta['cancel_url']) && $feed_meta['cancel_url'] ? $this->format_url_fragment($feed_meta['cancel_url']) : $redirect_url; 364 369 365 370 $orderid = $entry['id']; … … 369 374 $item_name = $this->get_item_name($line_items, $discounts); 370 375 371 $int_name = isset($feed_meta['billingInformation_name']) ? $feed_meta['billingInformation_name'] : '';372 376 $int_email = isset($feed_meta['billingInformation_email']) ? $feed_meta['billingInformation_email'] : ''; 373 377 $buyer_email = isset($entry[$int_email]) ? $entry[$int_email] : ''; 374 $buyer_name = $this->extractAndConcatenate($entry, $int_name); 378 379 $int_name = isset($feed_meta['billingInformation_name']) ? $feed_meta['billingInformation_name'] : ''; 380 $buyer_name = isset($entry[$int_name]) ? $entry[$int_name] : $this->extractAndConcatenate($entry, $int_name); 381 382 $int_description = isset($feed_meta['billingInformation_description']) ? $feed_meta['billingInformation_description'] : ''; 383 $description = isset($entry[$int_description]) ? $entry[$int_description] : $item_name; 375 384 376 385 $this->log_debug(__METHOD__ . '(): Entry is being converted => ' . print_r($entry, true)); … … 381 390 switch ($feed['meta']['transactionType']) { 382 391 case 'product': 383 $paymentRequest = new TrustistPaymentRequest($total, $orderid, $ item_name, $buyer_name, $buyer_email, $redirect_url, $cancel_url);392 $paymentRequest = new TrustistPaymentRequest($total, $orderid, $description, $buyer_name, $buyer_email, $redirect_url, $cancel_url); 384 393 385 394 $this->log_debug(__METHOD__ . '(): Payment request => ' . print_r($paymentRequest, true)); … … 421 430 return $payment['payLink']; 422 431 } 423 432 424 433 function extractAndConcatenate($array, $key_prefix = '') 425 434 { … … 427 436 428 437 foreach ($array as $key => $value) { 429 // Check if the key starts with '7.' or is exactly '7' 438 // Explicitly trim any unexpected whitespace in key_prefix 439 $key_prefix = trim($key_prefix); 440 441 // Check if the key starts with the prefix and a dot, or is exactly the prefix 430 442 if (strpos($key, $key_prefix . '.') === 0 || $key === $key_prefix) { 431 443 // Concatenate the values separated by a space … … 439 451 return trim($result); 440 452 } 441 442 private function return_url($form_id, $entry_id) 443 { 444 $pageURL = GFCommon::is_ssl() ? 'https://' : 'http://'; 445 446 // Sanitize SERVER_PORT 447 $server_port = sanitize_text_field(wp_unslash($_SERVER['SERVER_PORT'])); 448 453 454 private function format_url_fragment($fragment) 455 { 449 456 // Sanitize SERVER_NAME 450 457 $server_name = isset($_SERVER['SERVER_NAME']) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_NAME'])) : ''; 451 458 459 // Check if the fragment starts with "http://" or "https://" 460 if (preg_match('/^https?:\/\//', $fragment)) { 461 return $fragment; // Already a valid URL 462 } 463 464 // Prepend "http://<server_name>/" if the fragment isn't a full URL 465 $protocol = GFCommon::is_ssl() ? 'https://' : 'http://'; 466 $formatted_url = $protocol . rtrim($server_name, '/') . '/' . ltrim($fragment, '/'); 467 return $formatted_url; 468 } 469 470 private function return_url($form_id, $entry_id) 471 { 452 472 // Sanitize REQUEST_URI 453 473 $request_uri = isset($_SERVER['REQUEST_URI']) ? esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])) : ''; 454 455 if ($server_port != '80') { 456 $pageURL .= $server_name . ':' . $server_port . $request_uri; 457 } else { 458 $pageURL .= $server_name . $request_uri; 459 } 460 474 475 // Combine server name and request URI with SSL check 476 $pageURL = $this->format_url_fragment($request_uri); 477 478 // Build query arguments 461 479 $ids_query = "ids={$form_id}|{$entry_id}"; 462 480 $ids_query .= '&hash=' . wp_hash($ids_query); 463 481 464 482 // Use add_query_arg to safely add query arguments to the URL 465 483 $url = add_query_arg('gf_tr_return', base64_encode($ids_query), $pageURL); 466 484 467 485 return $url; 468 486 } -
trustistecommerce/trunk/readme.txt
r3174460 r3178082 4 4 Requires at least: 5.4 5 5 Tested up to: 6.5 6 Stable tag: 1.0. 26 Stable tag: 1.0.3 7 7 Requires PHP: 7.2 8 8 License: GPLv2 -
trustistecommerce/trunk/trustist-ecommerce.php
r3174460 r3178082 4 4 Plugin URI: https://www.trustistecommerce.com 5 5 Description: Take Open Banking or credit card payments in the UK using TrustistEcommerce. 6 Version: 1.0. 26 Version: 1.0.3 7 7 Author: Trustist 8 8 Author URI: https://www.trustist.com … … 12 12 defined( 'ABSPATH' ) or die(); 13 13 14 \define('TRUSTISTPLUGIN_VERSION', '1.0. 2');14 \define('TRUSTISTPLUGIN_VERSION', '1.0.3'); 15 15 \define('TRUSTISTPLUGIN_SLUG', 'trustistecommerce'); 16 16 \define('TRUSTISTPLUGIN_NAME', 'TrustistEcommerce');
Note: See TracChangeset
for help on using the changeset viewer.