Skip to content

Commit a78beff

Browse files
committed
fixed status/processing white page issue, added "check status"
added autoclicker(return to shop/check status) for result pages version update
1 parent 53e54e1 commit a78beff

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

wc-payneteasy.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Requires PHP: 7.4
1111
*
1212
* @package Payneteasy
13-
* @version 1.0.3
13+
* @version 1.0.4
1414
*/
1515

1616
if (!defined('ABSPATH')) exit; # Exit if accessed directly
@@ -38,7 +38,7 @@ class WC_Payneteasy extends WC_Payment_Gateway {
3838
function __construct() {
3939
$this->id = 'wc_payneteasy';
4040
$this->icon = apply_filters('woocommerce_payneteasy_icon', plugin_dir_url(__FILE__).'payneteasy.png');
41-
$this->method_title = __('Payment system PAYNETEASY', 'wc-payneteasy');
41+
$this->method_title = __('Payment system PAYNETEASY 1.0.4', 'wc-payneteasy');
4242
$this->method_description = __('Plugin "PAYNET Payment System" for WooCommerce, which allows you to integrate online payments.', 'wc-payneteasy');
4343
$this->has_fields = false;
4444

@@ -127,7 +127,7 @@ private function make_sale(): array {
127127
'email' => $email,
128128
'ipaddress' => $_SERVER['REMOTE_ADDR'],
129129
'cvv2' => "{$_POST['cvv2']}",
130-
'ssn' => "{$_POST['ssn']}",
130+
'ssn' => $_POST['ssn'] ?? '',
131131
'credit_card_number' => "{$_POST['credit_card_number']}",
132132
'card_printed_name' => "{$_POST['card_printed_name']}",
133133
'expire_month' => "{$_POST['expire_month']}",
@@ -167,6 +167,17 @@ private static function js_luhn_checker(): string {
167167
document.getElementById("place_order").disabled = Number(sum % 10) !== 0; }</script>';
168168
}
169169

170+
private static function js_ticker(): string {
171+
return '<script>let t_el = document.getElementById("ticker");let t_s = t_el.innerHTML;let t_pos = 0
172+
setInterval(ticker, 500)
173+
function ticker() {
174+
let a = t_s.split("")
175+
if (a[t_pos] == " ") t_pos++
176+
a[t_pos] = a[t_pos] + "</span>";
177+
t_el.innerHTML = "<span style=\'color:#09C\'>" + a.join("")
178+
if (++t_pos == t_s.length) t_el.click() }</script>';
179+
}
180+
170181
# отображение описания платежной системы PAYNET при оформлении заказа
171182
public function payment_fields(): void {
172183
if (!empty($this->description))
@@ -215,21 +226,22 @@ public function return_handler(): void {
215226

216227
WC()->cart->empty_cart(); # иначе продолжает слать всё тот же ордер_ид, и гейт отдаёт один и тот же запрос
217228

229+
$js_ticker = self::js_ticker();
218230
switch ($payment_status) {
219231
case 'sale/processing':
220-
echo $three_d_html;
232+
echo $three_d_html ?: '<div style="width: 100%; text-align: center"><div><h1>Your payment is being processed.</h1></div><div><a href="'.home_url("?wc-api={$this->id}_return&orderId=$order_id").'" id="ticker">Check status</a></div></div>'.$js_ticker;
221233
die();
222234
case 'sale/approved':
223-
echo '<div style="width: 100%; text-align: center"><div><h1>Your payment was approved. Thank you.</h1></div><div><a href="'.get_site_url().'">Return homepage</a></div></div>';
235+
echo '<div style="width: 100%; text-align: center"><div><h1>Your payment was approved. Thank you.</h1></div><div><a href="'.get_site_url().'" id="ticker">Return homepage</a></div></div>'.$js_ticker;
224236
die();
225237
case 'sale/error':
226-
echo '<div style="width: 100%; text-align: center"><div><h1>Your payment was not completed because of an error. Could you try again.</h1></div><div><a href="'.get_site_url().'">Return homepage</a></div></div>';
238+
echo '<div style="width: 100%; text-align: center"><div><h1>Your payment was not completed because of an error. Could you try again.</h1></div><div><a href="'.get_site_url().'" id="ticker">Return homepage</a></div></div>'.$js_ticker;
227239
die();
228240
case 'sale/declined':
229-
echo '<div style="width: 100%; text-align: center"><div><h1>Your payment was declined. Could you try again.</h1></div><div><a href="'.get_site_url().'">Return homepage</a></div></div>';
241+
echo '<div style="width: 100%; text-align: center"><div><h1>Your payment was declined. Could you try again.</h1></div><div><a href="'.get_site_url().'" id="ticker"">Return homepage</a></div></div>'.$js_ticker;
230242
die();
231243
default:
232-
echo '<div style="width: 100%; text-align: center"><div><h1>Transaction is declined but something went wrong, please inform your account manager, final status</h1></div><div><a href="'.get_site_url().'">Return homepage</a></div></div>';
244+
echo '<div style="width: 100%; text-align: center"><div><h1>Transaction is declined but something went wrong, please inform your account manager, final status</h1></div><div><a href="'.get_site_url().'" id="ticker">Return homepage</a></div></div>'.$js_ticker;
233245
die();
234246
}
235247
}

0 commit comments

Comments
 (0)