- Posts: 16
- Thank you received: 0
IPN Listener
- iconoclast
-
Topic Author
- Offline
I am a newbie here and would like to add my PHP script, In the listener file of the component where after the successful payment of PAYPAL, the component turns the order status to confirmed. I want to find that file and that part of code so, I can add more of my custom code there.
Will you please give me the location of the file that handles the information sent fron IPN system of PAYPAL?
By the way this component ROCKS! :lol:
Thank you very much
Please Log in or Create an account to join the conversation.
You don't need to hack hikashop for that (it's better not to, otherwise, you will have to reapply your changes each time). You can create a plugin and define the method onAfterOrderUpdate(&$order,&$send_email) following our developer documentation:
www.hikashop.com/en/support/documentatio...r-documentation.html
That way, in that method, you can just do like this:
if(@$order->order_status=='confirmed'){
// my custom code
}
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
Thank you very much..
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
And maybe it is irrelevant question but is there a way I can use the paypal sandbox system for testing purposes?
I saw a link given to paypal that can be changed, but I'm not sure which url I should use instead of default one.
Thank you very much.
Please Log in or Create an account to join the conversation.
If you want to load the email address of the user, you can use the code:
//first, I need to load the data of the order as it might not contain the user id
$orderClass = hikashop::get('class.order');
$orderInfos = $orderClass->get($order_id);
//then, I load the user data
$userClass = hikashop::get('class.user');
$customer = $userClass->get($orderInfos->order_user_id);
echo $customer->user_email;
The paypal sandbox URL is: www.sandbox.paypal.com/cgi-bin/webscr
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
This is my case scenario:
I have two PDF files that I want to sell.
During the shopping I don't collect any information from the costumer.
After the successful payment I want to send an email to the buyer.
The email will be the same email of payer from the paypal that is get back to me through IPN system (You told me what to do for getting the email address but I couldn't manage to make it work.)
Then I will need the code number of products the buyer purchased to know which product link I should send to customer.
(If the customer buys both of PDFs I should send him/her two links, so maybe there are more than one product code needed to handle).
Also I should get the payment ID from paypal to show on my Thank you page. I don't know what code I should use in my thank you page for showing the payment ID.
Will you please help me on this matter?
Thank you very much.
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
This is my case scenario:
I have two PDF files that I want to sell.
During the shopping I don't collect any information from the costumer.
After the successful payment I want to send an email to the buyer.
The email will be the same email of payer from the paypal that is get back to me through IPN system (You told me what to do for getting the email address but I couldn't manage to make it work.)
Then I will need the code number of products the buyer purchased to know which product link I should send to customer.
(If the customer buys both of PDFs I should send him/her two links, so maybe there are more than one product code needed to handle).
Also I should get the payment ID from paypal to show on my Thank you page. I don't know what code I should use in my thank you page for showing the payment ID.
Will you please help me on this matter?
Thank you very much.
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
I want to know how can I get the given information of the ipn for next usage.
I tested the IPN with my settings and got some information.
Now I want to access that information like:
item_number1= (the product ID)
item_number1= (the product ID)
payer_email= (this is so important for me cuz I dont have any othe contact information from my customer except this)
As you said I can make a plugin to handle but how can I access the information above in my plugin?
Thank you very much and waiting for your reply
Please Log in or Create an account to join the conversation.
On the thank you page the payment might not be validated by PayPal so it doesn't return any information to HikaShop which would enable you to display the payment ID. That information is sent with IPN to HikaShop on a different communication channel later on and securily. And it's at that point that the onAfterOrderUpdate function is triggered by HikaShop. You say that you couldn't make work the code I gave you. Maybe it's because you thought that it would display something on the thank you page where in fact it's not called at that point ?
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
I want the information of the IPN available for me at onAfterOrderUpdate in my plugin.
information such as payer_email , mc_gross , ....
How can I access them on my plugin?
Please Log in or Create an account to join the conversation.
Like this: $price = $_REQUEST;
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
I am getting closer to achieve the results.
I coded the plugin. and now my code should work after the order is confirmed.
I post the code I wrote using your help. Unfortunately the event does not trigger on confirmed order.
Will you please check where did I mistake?
<?php
defined('_JEXEC') or die('Restricted access');
?>
<?php
class plgChristopher extends JPlugin
{
function plgChristopher(&$subject, $config){
parent::__construct($subject, $config);
if(!isset($this->params)){
$plugin =& JPluginHelper::getPlugin('hikashop', 'christopher');
jimport('joomla.html.parameter');
$this->params = new JParameter( $plugin->params );
}
}
function onAfterOrderUpdate(&$order,&$send_email){
if(@$order->order_status=='confirmed'){
$customerEmail = $_REQUEST;
$to = $customerEmail;
$from = "christopher.amirian@gmail.com";
$subject = "Your payment has been verified";
$message = "This is a test";
mail($to, $subject, $message);
}
}
}
?>
As you see I used the same coding rules of the history plugin. The plugin installed ok.
I want to send a simple email after the payment, using the email address I get from the IPN answer.
I followed your instructions and still have problem.
The event does not trigger.
Would be thankful to help me in this matter.
Thank you very much
?>
Please Log in or Create an account to join the conversation.
Because the email is not sent ? In that case, you should try to use the joomla emailing functions and not the php mail function. That way, the system will use the standard joomla mail sending configuration :
$mailer =& JFactory::getMailer();
$config =& hikashop::config();
$sender = array(
$config->get('from_email'),
$config->get('from_name') );
$mailer->setSender($sender);
$mailer->addRecipient(array($customerEmail));
$mailer->setSubject("Your payment has been verified");
$mailer->setBody("This is a test");
$mailer->Send();
Also, you need to have your plugin published in the joomla plugin manager. Is that the case ?
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
Yes I always publish the plugin before I use.
I tested the code and it works when I code it directly to joomla article using Jumi.
But it does not send email when it is coded in plugin.(I used the same code)
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
Please Log in or Create an account to join the conversation.
jimport('joomla.filesystem.file');
JFile::write(HKASHOP_ROOT.'mylogfile.txt','event is triggered');
Then, you will be able to access that log file in your website's root folder via FTP. Also, make sure that this file is writable.
Please Log in or Create an account to join the conversation.
- iconoclast
-
Topic Author
- Offline
- Posts: 16
- Thank you received: 0
Please Log in or Create an account to join the conversation.