V12 Finance Plugin

  • Posts: 127
  • Thank you received: 6
6 years 6 months ago #292085

-- HikaShop version -- : 3.2.2
-- Joomla version -- : 3.6.4
-- PHP version -- : 7.0.29

Hi
Love the new checkout of Hikashop - much easier to configure and loads nicer for the user, desktop and mobile looking good!
However, we have one payment plugin written for V12 Finance (very popular in the UK) which doesn't like the final step in the new checkout stages. The data isn't being passed to the V12 url, for some reason. On legacy all is well.

So, regrettably I have to revert to Checkout legacy.

I've looked hard for similar issues and in the support documentation for the changes that might have broken the plugin, but have drawn a blank so far.
I realise it's beyond the scope of your support but if anyone has time to look at the plugin files (attached) it would be great to get it compatible with the new checkout.
I'm also happy to share the work we've done here as a new payment plugin, which might help others, though it probably needs some little development to make it a full package.
Attached, the plug-in files. Really hope you could take a look and point me in the right direction. The original developer has moved on but I have some skills and I'm keen to fix it.
Regards, Bob

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 6 months ago #292086

Hi,

I don't see how your plugin can work at all.
In its v12_end.php file, it displays a form for the end step of the checkout.
This form has javascript code added to it in order to submit the form content through AJAX and the com_ajax system of Joomla ( docs.joomla.org/Using_Joomla_Ajax_Interface ) to a separate ajax/v12 plugin to process the data with the payment gateway and return a URL where to redirect the customer. So without that separate plugin it's impossible this payment plugin would work.

Besides that, I didn't see anything particular which would make that plugin not work with the new checkout so if there is something it must be an easy thing to fix. But without being able to test, and without you telling us exactly how it doesn't work with the new checkout, it's hard to say much on that end. What error message did you get ?

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

  • Posts: 127
  • Thank you received: 6
6 years 6 months ago #292125

Thanks for looking Nicolas
It actually has been working for over a year and we have had many sales this way.

The error message comes from v12_end.php:
'There was a problem with the application submission. Please contact us to manually create your order.'

In context:

// process the form
	jQuery('form#hikashop_v12_form').submit(function(event) {

		//Disable the submit button
		jQuery('#hikashop_v12_button').attr('disabled', 'disabled');

		// get the form data
		// there are many ways to get this data using jQuery (you can use the class or id also)
		var formData = {
			'product_id'      : jQuery('input[name="period"]:checked').val(),
			'deposit'     : jQuery('input[name=deposit]').val(),
			'data'    		: jQuery('input[name=data]').val()
		};

		// process the form
		jQuery.ajax({
			type        : 'post',
			url         : '?option=com_ajax&plugin=v12&format=json',
			data        : formData,
			dataType    : 'json',
			encode      : true
		}).done(function(data) {

			// log data to the console so we can see
			console.log(data);

			if (data.success) {
				if(data.data[0].formUrl) {
					jQuery('#application_link').attr("href", data.data[0].formUrl);

					//Hide the form and show the application link
					jQuery('#hikashop_v12_form').hide( "slow",function(){
						jQuery('#ajax-response-success').show("slow");
						//Click the link after 5 seconds
						setTimeout(function(){
							//Use window open as a click event will bind to the link before it has an href value
							window.open(data.data[0].formUrl);
						}, 5000);
					});

				} else if (data.data[0].noapplication) {
					//V12 didn't return an application link
					jQuery('#hikashop_v12_form').hide( "slow",function(){
						jQuery('#ajax-response-error').show("slow");
						jQuery('#ajax-error-message').html('There was a problem with the application submission. Please contact us to manually create your order.');
					});

...and more...

This message contains confidential information


On the live site the V12 payment is enabled and working with the legacy checkout enabled.
On my staging site checkout legacy is switched off. Otherwise they are the same Hikashop Configuration (caches are off on the staging site).

Nicolas, it is good of you to look at this, especially on May 1st and quite late in the evening. There is no rush at all - the live site is happy.
Kind regards
Bob

Last edit: 6 years 6 months ago by Bobwales.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 6 months ago #292139

Hi,

As I said in my previous message, looking at the code of your plugin, it requires another plugin of the group "ajax" also called v12 to work properly. And the issue happens in that ajax plugin based on what you're saying.
So we would need also the code of that second plugin to be able to say anything useful.

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

  • Posts: 127
  • Thank you received: 6
6 years 6 months ago #292153

Ah, I see.
I will take a look at the files in the V12 folder within the Ajax Plugin. It's attached too, if you want to follow up - like I say, I think it would be a good addition to the Payment Methods of Hikashop, but needs a little more work - clearly, beyond my skills to make into a robust package.

Thanks again Nicolas

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 6 months ago #292162

Hi,

Thanks. With the whole code, it makes more sense.
I would however be very wary using that plugin (and actually I wouldn't use it on one of my websites).
Looking at the code, there is no security at all. This means that:
- anyone can easily confirm an order himself on your website by just creating the correct link and opening it in its browser, without making any payment.
- anyone can change the amount of the payment after the order is created so that the amount paid is different than the total amount of the order and the plugin would still validate the order.
So after every confirmed order, you should check that the payment has really been made before sending any goods or providing any service.
To do it properly, I'm afraid it would require a complete rewrite.

Regarding the issue, it comes during the call to the payment gateway to get the redirection URL. Something goes wrong. Unfortunately, the code of the plugin doesn't have any debug capability to actually get the error message returned by the payment gateway. Instead, it just displays its own error message.
So to be able to fix the issue would require some code modification and debugging.
Clearely, it's not just something I could do in a few minutes but will require several hours of development/testing.
I can provide some tips to get you started if you're a developer:
look at the XHR request with your browser's developer tools on the end step of the checkout when you submit the payment form and get that error. In the networks tab, you can see it, along with the response from the server.
It contains the "request" and the "response" from the request made to the payment gateway which will contain the real error message. You can then go from there.

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

  • Posts: 127
  • Thank you received: 6
5 years 10 months ago #302639

Thank you Nicolas - I've now got some quiet time to pick this up again (the bike business is quiet at this time of year). And it would be fantastic to use the new checkout, rather than the old legacy checkout which is not throwing the error.

Following your advice I can see the following error

"Undefined property: stdClass::$order_id in /home/juicebik/staging/6/plugins/hikashoppayment/v12/v12.php on line 170 "

which refers to this code:


$vars = array(
'CashPrice' => $amount,
'vLink' => $this->payment_params->vlink,
'DuplicateSalesReferenceMethod' => 'ShowOriginalApplication',
'SalesReference' => $order->cart->order_id,
);

Changing that to:

$vars = array(
'CashPrice' => $amount,
'vLink' => $this->payment_params->vlink,
'DuplicateSalesReferenceMethod' => 'ShowOriginalApplication',
/*'SalesReference' => $order->cart->order_id,*/
'SalesReference' => $this->order->order_id,
);

Seems to fix the issue and instantiate the SalesReference which was the issue shown in the console.

So, thanks for your detailed help once again and apologies for the delay in getting back to you.

Attachments:
Last edit: 5 years 10 months ago by Bobwales.
The following user(s) said Thank You: nicolas

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

Time to create page: 0.066 seconds
Powered by Kunena Forum