Hikashop developing a payment plugin gateway

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 10 months ago #184696

Hi,

The URL index.php?option=com_hikashop&ctrl=checkout&task=notify¬if_payment=paypal&tmpl=component&lang=he&Itemid=135 will trigger the function onPaymentNotification of the payment plugin.
That function's role is to verify that the payment notification is legit and confirm the order. By default it doesn't display anything since that URL is normally triggered automatically by the payment gateway and no one sees its result.
It knows that the payment notification is real by contacting back PayPal and asking it if the payment notification is real and PayPal replies back.

The parameter $this->url_itemid contains the Itemid parameter to add in the URLs sent to the payment gateway. It doesn't matter much. The function onAfterOrderConfirmation is called at the end of the checkout, after the user has confirmed that he wanted the order to be created. That's where the payment plugin usually redirects the customer to the payment gateway.

The admin notification email is also sent from the save function of the class.order file. The payment notification (after the payment gateway requests the notification URL) is sent by the modifyOrder function in the parent class HikashopPaymentPlugin that you can find in the file helpers/helper.php in the backend folder of HikaShop.

If you want to add checks to the address form, the best is to develop a small hikashop plugin and implement the onBeforeAddressCreate and onBeforeAddressUpdate triggers in your plugin and set the $do variable to false if there is a problem with the format of the data.

Most of that info is actually available in our developer documentation:
www.hikashop.com/support/support/documen...r-documentation.html
So I invite you to read it, and especially the example payment plugin code which is heavily commented in order to explain what each part of the payment plugins does what.

The following user(s) said Thank You: Saiah

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #184790

Can I simply alter the existing code for manual shipment instead of building a new one?
It would be faster right?
I just don't know where to start with that really.

By the way thank you for your response ,you took some of your time to answer all my questions there ,for that I am grateful.
Anyway when I added ?lc=he_IL to the URL's end in PayPal plugin configs ,like this:

https://www.paypal.com/cgi-bin/webscr?lc=he_IL
I think that made PayPal stop giving payment notifications.
And then suddenly I started getting an error on PayPal page:

An error occurred while processing your request.
Reference #

So I was wondering how to set up the language on PayPal without ruining the functionality of the gateway.

Last edit: 9 years 10 months ago by Saiah.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 10 months ago #184793

Hi,

You sure can directly alter the existing code, but beware that each time you update HikaShop, your changes will be lost as the Joomla installer will overwrite all the files of Hikashop with their new version.
That's why we usually recommend to work with overrides/plugins. It's a bit more time at the beginning but you save time in the long run.

You can see that the lc parameter is added like this in the onAfterOrderConfirmation trigger :

$vars['lc'] = $order->cart->billing_address->address_country->zone_code_2;
If you want to force it to he_IL, you should add such code:
$vars['lc'] = 'he_IL';
Changing the PayPal URL is not a valid method of sending that parameter to PayPal.

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #184878

I think I managed the thing with language.
I added a puppet product with the cost of 1 for testing.
When I pay for it in paypal with credit card the order turns cancelled instead of confirmed , reason:
automatic payment notification received
infromation: Array ( [lc] => he_IL [option] => com_hikashop [ctrl] => checkout [task] => notify [notif_payment] => paypal [tmpl] => ...
in the information part it shows [payment_status]=>completed
what do you think is happening?

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #184879

The thing is that when I pay in PayPal they add taxes so 1 becomes 1.18 could this be the issue and why is it happening?

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #184882

I changed tax in my paypal to inactive
now the order is confirmed.

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #184904

Another issue ,
I have changed order.php save() function to send notification email to email in address class rather than user class.
I also changed some code else where I don't remeber really where ,and it will take me ages to find out ,I'm not such a good programmer!

Anyway the system now does not send emails at all to site owner about any orders confirmed!!
I have disabled sending emails to owner on orders just created.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 10 months ago #184919

Hi,

The payment notification emails are sent automatically when orders are confirmed as long as you didn't remove the email address in the "payment notification email address" option of the HikaShop configuration. So check that option. If the email address there is valid, then the option thing left is that some code has been changed in the onPaymentNotification function of the PayPal plugin.

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #184940

Thanks,
the email is there and is valid ,some code has been changed.
Now please correct me if I am mistaking:
modifyOrder() in helper.php will modify the order and send email to shop owner
on the other hand:
save() in order.php will save the order back to database after it has been modified and will send email to client!?

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #184942

As for the emails not being sent ,now it's alright.

I found the bad code and fixed it.

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #185385

For some reason email sent to owner has only link to order but not full order details as before!
How can this be fixed?
Another question please:
Where does the versifying of address input happen in the code.
For example where it says phone when you type characters instead of numbers it gives error(javascript) where does this happen?
I want to add handling for extra fields I added ,also phone number should be checked for length ,so only 1 or 2 numbers wouldn't pass.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 10 months ago #185431

Hi,

Please open new threads when you have new questions and do not pollute the same thread with things that are not linked to the first subject.

1. HikaShop sends two emails to the owner:
- The order administrator notification, which is sent when the order is created at the end of the checkout and contains all the order details;
- The payment notification email, which is sent by the payment plugin when a payment notification is received and that the other is confirmed (or not because of an error) and it only contains a link to the order details page;

Are you sure that you're not mixing up both emails ?

2. This is handled in the file media/com_hikashop/js/hikashop.js near the end in the function hikashopCheckChangeForm

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #185506

Sorry, I haven't noticed, my next question will be in another post.
the emails are being sent, no problem with that. The issue is that email to shop owner doesn't have the order details directly
in the email but has a link to the back end to see the order. How to fix this so that it shows order details in email.
Or maybe I should ask how or where email to owner is created ,I mean where is it built ,the body of the email?

I will look at the js part of HikaShop and let you know what happens with field validation, thanks.

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #185540

in hikashop.js

}else if(type=='address' && typeof varform.elements['data[address][address_telephone]'] != 'undefined'){
			var phoneField = varform.elements['data[address][address_telephone]'], filter = /[0-9]+/i;
			if(phoneField){
				phoneField.value = phoneField.value.replace(/ /g,"");
				if((phoneField.value.length > 0 && !filter.test(phoneField.value)) || (phoneField.value.length > 0 && phoneField.value.length < 7)){
					alert(hikashopFieldsJs['valid_phone']);
					return false;
				}
			}

change:
|| (phoneField.value.length > 0 && phoneField.value.length < 7)
but when I enter just 0 in phone field it doesn't give alert, just if it was ok!!

Last edit: 9 years 10 months ago by Saiah.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 10 months ago #185659

Hi,

1. The email body for the payment notification email is created in the modifyOrder function of the file administrator/components/com_hikashop/helpers/helper.php

2. I don't see why it would not give an alert in that case only.

The following user(s) said Thank You: Saiah

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #185706

Thanks I will check it out and let you know.
:)

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #185749

Alright so I have learned this:
email on creation of order to owner and customer show order details.
but payment notify email to owner doesn't show order details ,to customer it does.

I followed the code to know where the order details could be formed but no success.
Could it be $order->text ?

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 10 months ago #185780

The order data is not available in that function. You would have to load it yourself based on the order_id:

$orderClass = hikashop_get('class.order');
$orderData = $orderClass->loadFullOrder($order_id, true, false);
www.hikashop.com/support/support/documen...umentation.html#code

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #185811

Thank you so much ,I have actually come upon this during my search.
Is there no way to simply copy the body of the message sent to the client and embed it to the body of message sent to owner ,with minor modification?

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

  • Posts: 48
  • Thank you received: 0
9 years 10 months ago #185813

I tried this in my payment plugin:

$orderClass = hikashop_get('class.order');
$orderClass->loadOrderNotification($dbOrder,'order_admin_notification');
and this did load up the email $dbOrder->mail
so I editted subject and body all fine, but one thing remains:
I need email to be sent html not plain text, so I see that $dbOrder->mail->html=1 but still email is plain text!
How can I tell modifyOrder() to send html not text mail !?

Last edit: 9 years 10 months ago by Saiah.

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

Time to create page: 0.096 seconds
Powered by Kunena Forum