I am currently using this version for creating online store, I found following problem:
If a user closes the window of confirmation page shown by paypal immediately after completing the payment. The paypal is not able to postback the data to website, hence the order remains in checkout_review status and later moves to cart status. But ipn is being received.
I tried to handle this by creating a function and calling it right after the ipn is saved for an order id in function commerce_paypal_process_ipn($payment_method = NULL, $debug_ipn = array()).
following is the function:
function commerce_paypal_handle_order_state($id,$type='order_id')
{$q= db_select('commerce_order', 'co')
->fields('co',array('status'))
->condition('co.' . $type, $id);
$res=$q->execute();
$st="completed";
while( $query=$res->fetchAssoc())
{if(!($query['status']==$st))
{ db_update('commerce_order')
->fields(
array(
'status' => $st,
)
)
->condition('order_id', $id)
->execute();
watchdog ("Status changed","status or order changed to completed for abandoned order id");
$order = commerce_order_load($id);
$stat= commerce_order_status_update($order, 'checkout_complete', TRUE);
commerce_checkout_complete($order);
$order_status = commerce_order_status_load($order->status);
}
else
print "Its ok".$order_status['state'];
}
}
I checked it working fine. Please check and review and suggest me whether this could be worked out as patch or if there is any suggestion from your part.
Thanks
Comments
Comment #1
Yuri commentedI tested your code, but it does not fire the Rule to send an order confirmation email. Is that correct?
Comment #2
poniesI have this same issue even if the Paypal transaction is completed and the redirect link is used by the customer to return to the seller's store the order remains in review. No payment is recorded. In my case we're selling downloads with commerce_file and a new user isn't created and the license isn't generated because the checkout never completes.
Using the Paypal sandbox, the monies are received and the order is complete on their end. Watching the access log I can see the IPN post come in and seemingly complete successfully with http returning a 200.
This is the access log:
173.0.82.126 - - [30/Aug/2012:09:37:04 -0700] "POST /commerce_paypal/ipn/paypal_wps%7Ccommerce_payment_paypal_wps HTTP/1.0" 200 - "-" "-"On a side note, is there some reason the Paypal sandbox interface is so bad?
Comment #3
rszrama commentedPayPal's sandbox has always been horrid unfortunately.
As to the issue here, I believe this has been resolved since the original post. IPNs trigger the checkout completion process in the event that the customer does not return from PayPal. In fact, until an IPN has been processed successfully, the payment transaction will never be created.
@ponies Can you turn on full IPN logging and try again? It sounds like even though the IPN is coming in it isn't validating for some reason. If it had been processed, the transaction should have been created.
Comment #4
poniesWorking theory is that the paypal e-mail address I entered had a trailing space so the IPN was rejected.
We're launching a site this week but if it's still an issue after that I'll take a swing at patching it.
Comment #5
rszrama commentedOk, thanks; would love to hear how it works out.
Comment #6
rszrama commentedLooks like another issue deals with mismatched e-mail addresses. I'll commit the patch there but expand it to include trimming whitespace.
#1418030-3: Better support business e-mail address comparison / acceptance