Issue:

When using Paypal WPS, no account is created for the anonymous user after the payment is completed. The user information recieved from the IPN are never stored in the order.

To fix this, I've added the following code in uc_paypal_ipn.

if(empty($order->primary_email))
{
	$order->primary_email = $payer_email;
	uc_order_save($order);
}

Having an e-mail address enables uc_cart_complete_sale_account to create an account for the user.

Now I'm wondering if there are any side effects to this hack. And even more if nobody else noticed this issue.

Comments

longwave’s picture

Have you disabled the customer information pane on the checkout page? That is usually responsible for collecting primary_email during checkout, though when using PayPal WPS I can see why you wouldn't need your customer to enter the email address twice.

Daniel E’s picture

hey longwave, thanks for getting back to me about this. Yes, I have disabled the customer information pane. This works fine with Paypal Express Checkout but it seems like the WPS implementation doesn't consider this case.

So my final live code looks like this (placed before the payment_status switch):

if($payer_email != "")
{
	watchdog('paypal wps', 'order: ' . $order_id . ' status: ' . $payment_status . ' mail: ' . $payer_email);
	$order->primary_email = $payer_email;
	$order->billing_first_name = $payer_email;
	uc_order_save($order);
}
else
{
	watchdog('paypal wps', 'order: ' . $order_id . ' status: ' . $payment_status . ' mail: ' .  'no e-mail address received');
}

This has been tested with a couple of real transactions and worked without flaws so far. I'll see if it works reliably in the next weeks.

longwave’s picture

Title: Paypal WPS + Anonymous Checkout = Not working correctly » Paypal WPS anonymous checkout fails if customer information pane is disabled

Does this work reliably for you? I am wondering about the case where the user clicks back to the site before the PayPal IPN is received, this might cause problems if we do not have an email address by this time..

Daniel E’s picture

After testing this for a couple of months, I can say that it works 98% of the time (which is actually more reliable than Paypal Express has been lately :D). But sometimes it doesn't work and no account is created and I have to answer rude support e-mails :P

longwave’s picture

Yeah, I imagine that 2% where it fails is the case I describe in #3 - many users do not click back after PayPal, and even less will manage to do so before the IPN arrives.

Daniel E’s picture

Do you think it would be possible to poll the IPN status with ajax and have the user wait until the IPN arrives? I think I've seen something like this on bandcamp. If you think it's possible, I'd give it a shot... Thanks

DanZ’s picture

Version: 7.x-3.1 » 7.x-3.x-dev

Do you think it would be possible to poll the IPN status with ajax and have the user wait until the IPN arrives?

Not all the time. Paypal IPNs are not guaranteed to be delivered right away. See https://www.x.com/content/resolved-issue-receiving-instant-payment-notif.... Some IPNs were delayed for more than a day. In theory, they could get lost completely.

If you don't ask for an e-mail address, and the IPN isn't back yet, Ubercart won't know the e-mail address, right?

The TransactionSearch API could be used to look up a transaction, and that contains the e-mail address and other customer information. That could be used as a fallback if the IPN doesn't come through. There might be some caveats for using it, though.

longwave’s picture

Version: 7.x-3.x-dev » 7.x-3.1

We may also be able implement PDT in #1421298: Is there any Paypal PDT support? to deal with the case where users click back from PayPal before the IPN arrives. The Ajax method may work some of the time where the users are particularly fast at clicking back and PayPal is working properly, but as noted above, IPNs can be delayed for 24 hours in some cases, and they are unlikely to want to wait that long!

TR’s picture

Version: 7.x-3.1 » 8.x-4.x-dev
Issue summary: View changes