pay by square

  • Posts: 36
  • Thank you received: 0
  • Hikashop Essential
3 months 6 days ago #329151

-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.24
-- PHP version -- : 7.4
-- Browser(s) name and version -- : chrome

Hello,
is there a plugin or any method how to add pay by square at the end of the order (also to send it to mail to customer)?
I mean:
customer chooses payment - bank transfer
he enters his bank app on his phone and he can choose scan QR to read all the information as bank account, price, reference, invoice number ...

thanks

Please Log in or Create an account to join the conversation.

  • Posts: 72763
  • Thank you received: 11096
  • MODERATOR
3 months 5 days ago #329153

Hi,

There is no existing plugin for that.
It would require developping a plugin to integrate with the webservice provided by "pay by square". So you'll have to hire a developer to work on that for you.
We have documentation for developers needing to do that here:
www.hikashop.com/support/documentation/6...r-documentation.html

Please Log in or Create an account to join the conversation.

  • Posts: 36
  • Thank you received: 0
  • Hikashop Essential
2 months 1 week ago #330358

Can You please tell me how will I call total order price and invoice number?

thanks

Please Log in or Create an account to join the conversation.

  • Posts: 36
  • Thank you received: 0
  • Hikashop Essential
2 months 1 week ago #330361

After adding this in the end view

$d = implode("\t", array(
	0 => '',
	1 => '1',
	2 => implode("\t", array(
		true,
		123.45,						// total amount
		'EUR',						// currency
		'20170101',					// date
		123456789,					// invoice
		'0308',						// 
		'1111',						// 
		'',
		'poznamka',					// note
		'1',
		'SK8011000000001234567890',	// IBAN
		'TATRSKBX',					// SWIFT
		'0',
		'0'
	))
));
$d = strrev(hash("crc32b", $d, TRUE)) . $d;
$x = proc_open("/usr/bin/xz '--format=raw' '--lzma1=lc=3,lp=0,pb=2,dict=128KiB' '-c' '-'", [0 => ["pipe", "r"], 1 => ["pipe", "w"]], $p);
fwrite($p[0], $d);
fclose($p[0]);
$o = stream_get_contents($p[1]);
fclose($p[1]);
proc_close($x);
$d = bin2hex("\x00\x00" . pack("v", strlen($d)) . $o);
$b = "";
for ($i = 0;$i < strlen($d);$i++) {
	$b .= str_pad(base_convert($d[$i], 16, 2), 4, "0", STR_PAD_LEFT);
}
$l = strlen($b);
$r = $l % 5;
if ($r > 0) {
	$p = 5 - $r;
	$b .= str_repeat("0", $p);
	$l += $p;
}
$l = $l / 5;
$d = str_repeat("_", $l);
for ($i = 0;$i < $l;$i += 1) {
	$d[$i] = "0123456789ABCDEFGHIJKLMNOPQRSTUV"[bindec(substr($b, $i * 5, 5))];
}
if (!empty($d)) {
	$u = '/chart?chs=200x200&cht=qr&chld=L|0&choe=UTF-8&chl=' . $d;
	$s = @fsockopen("chart.googleapis.com", 80, $e, $r, 1);
	if ($s) {
		$h = "GET " . $u . " HTTP/1.0\r\n";
		$h .= "Host: chart.googleapis.com\r\n";
		$h .= "Connection: close\r\n\r\n";
		fwrite($s, $h); $e = ''; $c = "";
		do {
			$e .= fgets($s, 128);
		} while (strpos($e, "\r\n\r\n") === false);
		while (!feof($s)) {
			$c .= fgets($s, 4096);
		}
		fclose($s);
	}
	header('Content-Type: image/png');
	echo $c;
}
i got this error in attachment

can you please help me

Attachments:
Last edit: 2 months 6 days ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 12786
  • Thank you received: 1757
  • MODERATOR
2 months 5 days ago #330395

Hello,

Can You please tell me how will I call total order price and invoice number?

Of course, but where do you exactly want to have these information ?

i got this error in attachment

We'll need more information about the context, where are you having that error, what's the goal of your code, what do you want to achieve ? Thank you.


Kind regards,
Mohamed.

Last edit: 2 months 6 days ago by Mohamed Thelji.

Please Log in or Create an account to join the conversation.

  • Posts: 36
  • Thank you received: 0
  • Hikashop Essential
2 months 3 days ago #330495

total order price and invoice number I want to have in end view

I have this error in end view
I want to display there QR code wherein are information about payment that customer will scan in bank account app

Please Log in or Create an account to join the conversation.

  • Posts: 72763
  • Thank you received: 11096
  • MODERATOR
2 months 2 days ago #330510

Hi,

The code you've added to the view is displaying the content of the QR code on the page. So the "error" that you see is not an error. It's the content of the QR code when you read it with notepad.
You would see something similar if you try to open an image file with notepad++ for example.
So the issue is the way did you code.
You can't do

header('Content-Type: image/png');
	echo $c;
in a HTML view file.
You need instead to do something like that:
echo '<img src="data:image/png;base64,'.base64_encode($c).'" />';
to tell the browser that you're displaying an image and directly providing the content of the image.
stackoverflow.com/questions/3695077/php-html-image-output

Last edit: 2 months 2 days ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 36
  • Thank you received: 0
  • Hikashop Essential
2 months 2 days ago #330552

I changed it like You said

$d = implode("\t", array(
	0 => '',
	1 => '1',
	2 => implode("\t", array(
		true,
		[color=red]123.45[/color],						// total amount
		'EUR',						// currency
		'20170101',					// date
		[color=red]123456789[/color] ,					// invoice
		'0308',						// 
		'1111',						// 
		'',
		'poznamka',					// note
		'1',
		'SK8011000000001234567890',	// IBAN
		'TATRSKBX',					// SWIFT
		'0',
		'0'
	))
));
$d = strrev(hash("crc32b", $d, TRUE)) . $d;
$x = proc_open("/usr/bin/xz '--format=raw' '--lzma1=lc=3,lp=0,pb=2,dict=128KiB' '-c' '-'", [0 => ["pipe", "r"], 1 => ["pipe", "w"]], $p);
fwrite($p[0], $d);
fclose($p[0]);
$o = stream_get_contents($p[1]);
fclose($p[1]);
proc_close($x);
$d = bin2hex("\x00\x00" . pack("v", strlen($d)) . $o);
$b = "";
for ($i = 0;$i < strlen($d);$i++) {
	$b .= str_pad(base_convert($d[$i], 16, 2), 4, "0", STR_PAD_LEFT);
}
$l = strlen($b);
$r = $l % 5;
if ($r > 0) {
	$p = 5 - $r;
	$b .= str_repeat("0", $p);
	$l += $p;
}
$l = $l / 5;
$d = str_repeat("_", $l);
for ($i = 0;$i < $l;$i += 1) {
	$d[$i] = "0123456789ABCDEFGHIJKLMNOPQRSTUV"[bindec(substr($b, $i * 5, 5))];
}
if (!empty($d)) {
	$u = '/chart?chs=200x200&cht=qr&chld=L|0&choe=UTF-8&chl=' . $d;
	$s = @fsockopen("chart.googleapis.com", 80, $e, $r, 1);
	if ($s) {
		$h = "GET " . $u . " HTTP/1.0\r\n";
		$h .= "Host: chart.googleapis.com\r\n";
		$h .= "Connection: close\r\n\r\n";
		fwrite($s, $h); $e = ''; $c = "";
		do {
			$e .= fgets($s, 128);
		} while (strpos($e, "\r\n\r\n") === false);
		while (!feof($s)) {
			$c .= fgets($s, 4096);
		}
		fclose($s);
	}
	echo '<img src="data:image/png;base64,'.base64_encode($c).'" />';
	echo $c;
}
and now I have there QR which is perfect but also there is the content of the QR, can You help me to reduce it?
and if You can tell me how can i get here real total amount of the order and also order number instead of 123.45 and 123456789

Attachments:
Last edit: 2 months 1 day ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 72763
  • Thank you received: 11096
  • MODERATOR
2 months 1 day ago #330570

Hi,

You have all the data of the order in $this->order
For for example you have the order id in $this->order->order_id
And you have the total amount in $this->order->order_full_price

Please Log in or Create an account to join the conversation.

  • Posts: 36
  • Thank you received: 0
  • Hikashop Essential
1 month 2 weeks ago #331052

Thank You, it works
I guess that invoice ID I will get like this: $this->order->invoice_id

Can You please help me with reducing the content of QR under the QR code?

$d = implode("\t", array(
	0 => '',
	1 => '1',
	2 => implode("\t", array(
		true,
		$this->order->order_full_price,			// total amount
		'EUR',						// currency
		'',					// date
		$this->order->order_id,				// invoice
		'0308',						// 
		'',						// 
		'',
		'',					// note
		'1',
		'SK7709000000005147806271',	// IBAN
		'GIBASKBX',					// SWIFT
		'0',
		'0'
	))
));
$d = strrev(hash("crc32b", $d, TRUE)) . $d;
$x = proc_open("/usr/bin/xz '--format=raw' '--lzma1=lc=3,lp=0,pb=2,dict=128KiB' '-c' '-'", [0 => ["pipe", "r"], 1 => ["pipe", "w"]], $p);
fwrite($p[0], $d);
fclose($p[0]);
$o = stream_get_contents($p[1]);
fclose($p[1]);
proc_close($x);
$d = bin2hex("\x00\x00" . pack("v", strlen($d)) . $o);
$b = "";
for ($i = 0;$i < strlen($d);$i++) {
	$b .= str_pad(base_convert($d[$i], 16, 2), 4, "0", STR_PAD_LEFT);
}
$l = strlen($b);
$r = $l % 5;
if ($r > 0) {
	$p = 5 - $r;
	$b .= str_repeat("0", $p);
	$l += $p;
}
$l = $l / 5;
$d = str_repeat("_", $l);
for ($i = 0;$i < $l;$i += 1) {
	$d[$i] = "0123456789ABCDEFGHIJKLMNOPQRSTUV"[bindec(substr($b, $i * 5, 5))];
}
if (!empty($d)) {
	$u = '/chart?chs=200x200&cht=qr&chld=L|0&choe=UTF-8&chl=' . $d;
	$s = @fsockopen("chart.googleapis.com", 80, $e, $r, 1);
	if ($s) {
		$h = "GET " . $u . " HTTP/1.0\r\n";
		$h .= "Host: chart.googleapis.com\r\n";
		$h .= "Connection: close\r\n\r\n";
		fwrite($s, $h); $e = ''; $c = "";
		do {
			$e .= fgets($s, 128);
		} while (strpos($e, "\r\n\r\n") === false);
		while (!feof($s)) {
			$c .= fgets($s, 4096);
		}
		fclose($s);
	}
	echo '<img src="data:image/png;base64,'.base64_encode($c).'" />';
	echo $c;
}

Attachments:
Last edit: 1 month 2 weeks ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 72763
  • Thank you received: 11096
  • MODERATOR
1 month 2 weeks ago #331057

Hi,

The invoice ID is in $order->order_invoice_id
However, this value is normally 0 when the order is created and is only set when the order's status is changed to "confirmed".
So normally, it's the order_id you want to send them.
Regarding the QR code content being displayed after the QR code, you just need to remove the last line

echo $c;

Please Log in or Create an account to join the conversation.

  • Posts: 36
  • Thank you received: 0
  • Hikashop Essential
1 month 1 week ago #331382

Hi,
ok I want to send them order_id but my order ID coontains year and 4digit order ID
but with the order_id I get only the 4digit ID

and one more question:
will it be possible to send the QR code in the email to customer when creating order?

Please Log in or Create an account to join the conversation.

  • Posts: 72763
  • Thank you received: 11096
  • MODERATOR
1 month 1 week ago #331384

Hi,

1. So it's not the order id you want to send but the order number. You can get the order number in $order->order_number

2. You could use the same code and replace $order by $data in the "HTML" section of the email when you edit the "order creation notification" email with the Business edition only.

Please Log in or Create an account to join the conversation.

Time to create page: 0.082 seconds
Powered by Kunena Forum