1

*Hello everybody

I have a SMTP client in order to send mails after a payment. The problem is that when I use Paypal, the method sendNewOrderNotificationAsync can not find the email adress. In fact, there is no email addresses saved when the Order object is created by the AsOrder method. Do you know where is the problem? Moreover there is no problem when I pay with my own payment I created so I don't understand...

Thank you in advance for your help.

romainf
  • 31
  • 2

2 Answers2

2

The problem happens only if you use express checkout and do not fill in any address before going to paypal. Order is created before redirecting to paypal site, so that it could be maintained after user returns from paypal. At the time of order creation interceptor sends emails, but if there is no address, there is no way to send email. If you would use normal checkout and select paypal as payment option, everything would be fine. As solution for this situation i think its better to send email manually to user after returning from paypal. Then address is created and taken from paypal returned options. Another approach could be to create system job that periodically checks orders and sends emails based on created date and orders status.

Example added send email in PaypalExpressSuccess

Ch.RunWorkflow("ShoppingCartCheckoutWorkflow", order);
Ch.OrderRepository.UnitOfWork.Commit();

//Send email

var recipientAddress = order.OrderAddresses.FirstOrDefault(oa => oa.OrderAddressId == order.AddressId);
if (recipientAddress != null)
{
    IDictionary<string, object> context = new Dictionary<string, object> { { "order", order } };
    UserHelper.SendEmail(context, recipientAddress.Email, "order-confirmation");
}

return RedirectToAction("ProcessCheckout", "Checkout",
    new {id = order.OrderGroupId});

It is now included in our new release. Checkout this commit https://github.com/VirtoCommerce/vc-community/commit/7c8bc663da2023a3796bee6a42f2a2b36e1dfb22

Adomas.NET
  • 126
  • 1
  • 4
  • Thank you for your answer I will try that this afternoon. I will tell you if I have other problems. – romainf Aug 05 '14 at 09:58
0

the email should be available as part of the shipping or billing address, aka paypal address I converted to Order address and then email is set to payee info.

Check the:

OrderClient.FindAddressByName(order, "Billing").Email;
Woland
  • 2,881
  • 2
  • 20
  • 33
  • I don't understand your answer... why is there nothing in orderaddresses with paypal but there is something with my own payment? Where is the line that I have to check? – romainf Aug 05 '14 at 07:59