- Posts: 25
- Thank you received: 1
How to send confirmation email?
- andersondionizio
-
Topic Author
- Offline
Less
More
12 years 8 months ago - 12 years 8 months ago #139323
by andersondionizio
How to send confirmation email? was created by andersondionizio
I have developed a payment plugin and all is working nice, but it is not finished yet, because I have the following situation:
My payment plugin working without problem and the gateway send notification after user's payment.
The "onPaymentNotification" function get the notification without problem, but i dont know how to send I email to user warning about payment confirmation and delivery his serial and change order status from "created" to "confirmed". With Paypal, notification send email confirmation with serial and change status of the order, but with my plugin only receive notification but do not change status and do not send confirmation email with serial.
I am trying to send to user a confirmation email with his serial, but the code do not work (i've copyed part of code from paypal source):
What is wrong? Please help!
I just want that "onPaymentNotification" function change order status to "confirmed" and send to user a confirmation email with his serial.
Thk
My payment plugin working without problem and the gateway send notification after user's payment.
The "onPaymentNotification" function get the notification without problem, but i dont know how to send I email to user warning about payment confirmation and delivery his serial and change order status from "created" to "confirmed". With Paypal, notification send email confirmation with serial and change status of the order, but with my plugin only receive notification but do not change status and do not send confirmation email with serial.
I am trying to send to user a confirmation email with his serial, but the code do not work (i've copyed part of code from paypal source):
Code:
private static function transactionNotification($notificationCode)
{
... (code above) ...
$parts = explode('|',$transaction->getReference());
$id = $parts[0]; // this is order_id
$nm = $parts[1]; // this is order_number
// all is working ok until here
$url = HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id=' . $id;
$order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', $nm, HIKASHOP_LIVE);
$order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url));
$order_status = $this->payment_params->verified_status;
$history->notified = 1;
$email = new stdClass();
$email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER','PagSeguro','confirmed',$nm);
$email->body = str_replace('<br/>',"\r\n",JText::sprintf('PAYMENT_NOTIFICATION_STATUS','PagSeguro','Pago')).' '.JText::sprintf('ORDER_STATUS_CHANGED',$order_status)."\r\n\r\n".$order_text;
$this->modifyOrder($id, $order_status, $history, $email);
return true;
}
What is wrong? Please help!
I just want that "onPaymentNotification" function change order status to "confirmed" and send to user a confirmation email with his serial.
Thk
Last edit: 12 years 8 months ago by andersondionizio.
Please Log in or Create an account to join the conversation.
12 years 8 months ago #139356
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Replied by Jerome on topic How to send confirmation email?
Hi,
I don't know if you created the variable $history before setting his value "notified", if not it could be useful.
Otherwise, you can simple pass the argument "history" with "true" to activate the notification.
An email will be send to the user if the order status has changed.
Please check that you can right access to the params of the plugin.
should contain the value of the status. If empty it shouldn't work.
Regards,
I don't know if you created the variable $history before setting his value "notified", if not it could be useful.
Otherwise, you can simple pass the argument "history" with "true" to activate the notification.
Code:
$this->modifyOrder($id, $order_status, true, $email);
Please check that you can right access to the params of the plugin.
Code:
$this->payment_params->verified_status
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: andersondionizio
Please Log in or Create an account to join the conversation.
- andersondionizio
-
Topic Author
- Offline
Less
More
- Posts: 25
- Thank you received: 1
12 years 8 months ago #139369
by andersondionizio
Replied by andersondionizio on topic How to send confirmation email?
Hi,
Thanks for information, there were errors on that 2 lines you have showed before.
I have change the code and the error now happen in this line:
Thanks for information, there were errors on that 2 lines you have showed before.
I have change the code and the error now happen in this line:
Please Log in or Create an account to join the conversation.
- andersondionizio
-
Topic Author
- Offline
Less
More
- Posts: 25
- Thank you received: 1
12 years 8 months ago - 12 years 8 months ago #139370
by andersondionizio
Replied by andersondionizio on topic How to send confirmation email?
Hi,
Thanks for information, there were errors on that 2 lines you have showed before.
I have change the code and the error now happen in this line:
Full code:
I think
fall in error, maybe because not find modifyOrder function.
Thanks for information, there were errors on that 2 lines you have showed before.
I have change the code and the error now happen in this line:
Code:
$this->modifyOrder($id, $order_status, true, $email);
Full code:
Code:
if ($transaction->getStatus()->getValue()==3) { // status confirmed
$parts = explode('|',$transaction->getReference());
$id = $parts[0];
$nm = $parts[1];
$url = HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id=' . $id;
$order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', $nm, HIKASHOP_LIVE);
$order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url));
$order_status = 'confirmed';
$email = new stdClass();
$email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER','PagSeguro','confirmed',$nm);
$email->body = str_replace('<br/>',"\r\n",JText::sprintf('PAYMENT_NOTIFICATION_STATUS','PagSeguro','Pago')).' '.JText::sprintf('ORDER_STATUS_CHANGED',$order_status)."\r\n\r\n".$order_text;
// all is working ok without error until here
$this->modifyOrder($id, $order_status, true, $email); // <= error here , why ?
return true;
}
I think
Code:
$this->modifyOrder($id, $order_status, true, $email);
Last edit: 12 years 8 months ago by andersondionizio.
Please Log in or Create an account to join the conversation.
12 years 8 months ago #139407
by nicolas
Replied by nicolas on topic How to send confirmation email?
That will only work if your plugin class extends from HikaShopPaymentPlugin as it's the case with most payment plugins that we have by default in HikaShop.
Otherwise, please provide the exact error message.
Otherwise, please provide the exact error message.
The following user(s) said Thank You: andersondionizio
Please Log in or Create an account to join the conversation.
- andersondionizio
-
Topic Author
- Offline
Less
More
- Posts: 25
- Thank you received: 1
12 years 8 months ago - 12 years 8 months ago #139415
by andersondionizio
Replied by andersondionizio on topic How to send confirmation email?
[error] [client 186.234.16.8] PHP Fatal error: Using $this when not in object context in ...
It is working now! I fixed it. The error was my fault. I was using a static function. :lol:
This problem is solved, when the plugin receive the notification, the status is change correctly and user's email and serial is correctly send.
Now I have only one little problem : when the payment gateway return to my site, only using Chrome, the page brokedown with this message: "This page has a redirect loop" ... Using firefox, have no problem.
It is working now! I fixed it. The error was my fault. I was using a static function. :lol:
This problem is solved, when the plugin receive the notification, the status is change correctly and user's email and serial is correctly send.
Now I have only one little problem : when the payment gateway return to my site, only using Chrome, the page brokedown with this message: "This page has a redirect loop" ... Using firefox, have no problem.
Last edit: 12 years 8 months ago by andersondionizio.
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
12 years 8 months ago - 12 years 8 months ago #139440
by Mohamed Thelji
Replied by Mohamed Thelji on topic How to send confirmation email?
Hi,
1. What is the URL where you redirect your customers after they have completed their payment through the payment gateway ?
2. Can you show me the code of your onPaymentNotification function ?
1. What is the URL where you redirect your customers after they have completed their payment through the payment gateway ?
2. Can you show me the code of your onPaymentNotification function ?
Last edit: 12 years 8 months ago by Mohamed Thelji.
Please Log in or Create an account to join the conversation.
- andersondionizio
-
Topic Author
- Offline
Less
More
- Posts: 25
- Thank you received: 1
12 years 8 months ago #139480
by andersondionizio
Replied by andersondionizio on topic How to send confirmation email?
Hi,
1) www.mydomain.com.br/download/checkout/after_end/order_id-76
2)
1) www.mydomain.com.br/download/checkout/after_end/order_id-76
2)
Code:
function onPaymentNotification(&$statuses) {
$code = (isset($_POST['notificationCode']) && trim($_POST['notificationCode']) !== "" ? trim($_POST['notificationCode']) : null);
$type = (isset($_POST['notificationType']) && trim($_POST['notificationType']) !== "" ? trim($_POST['notificationType']) : null);
if ($code && $type) {
$notificationType = new PagSeguroNotificationType($type);
$strType = $notificationType->getTypeFromValue();
switch ($strType) {
case 'TRANSACTION' :
$credentials = new PagSeguroAccountCredentials();
$transaction = PagSeguroNotificationService::checkTransaction($credentials, $code);
if ($transaction->getStatus()->getValue()==3) {
$parts = explode('|',$transaction->getReference());
$id = $parts[0];
$nm = $parts[1];
$url = HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id=' . $id;
$order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', $nm, HIKASHOP_LIVE);
$order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url));
$order_status = 'confirmed';
$email = new stdClass();
$email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER','PagSeguro','confirmed',$nm);
$email->body = str_replace('<br/>',"\r\n",JText::sprintf('PAYMENT_NOTIFICATION_STATUS','PagSeguro','Pago')).' '.JText::sprintf('ORDER_STATUS_CHANGED',$order_status)."\r\n\r\n".$order_text;
$this->modifyOrder($id, $order_status, true, $email);
return true;
}
break;
default: LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]");
break;
}
}
}
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
12 years 8 months ago #139498
by Mohamed Thelji
Replied by Mohamed Thelji on topic How to send confirmation email?
Ok, I think that reading this
thread
will probably help you.
Please Log in or Create an account to join the conversation.
Time to create page: 0.247 seconds