News:

Looking for documentation? Take a look on our wiki

Main Menu

Order status not updating event though transaction successful

Started by qme1ster, June 02, 2009, 12:54:51 PM

Previous topic - Next topic

danathomas76

I am currently having the same issue.  I am going to try the switch on pending to confirmed.  I will tell the business owner to not update the status to shipped until she has seen the Paypal transaction to be confirmed.

currently working with -
Joomla 1.5.10
VM 1.1.3

qme1ster

No matter what I try I still can't seem to shift the order status from pending to confirmed. As mentioned at the start of this thread (now heading in other directions) the transactions are showing up as successful in the buyer and seller payPal accounts, however the emails which are sent out state the order is pending, as does the database.

I've checked my ps_paypal.cfg.php file which is as follows:-


<?php
if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); 

define ('PAYPAL_DEBUG''1');
define ('PAYPAL_EMAIL''shopowner@domain.com');
define ('PAYPAL_VERIFIED_ONLY''0');
define ('PAYPAL_VERIFIED_STATUS''C');
define ('PAYPAL_PENDING_STATUS''P');
define ('PAYPAL_INVALID_STATUS''X');
?>


I believe this is as it should be when in test mode.

I've also just tried the Instant Payment Notification (IPN) simulator in the payPal sandbox. I tested for transaction type "cart checkout" and received the result: "IPN successfully sent. ". But then I thought - well how can we confirm what is actually being sent and received by VM ??

So I found this post http://forum.virtuemart.net/index.php?topic=48421.0 which suggested the following:-

Quoteare you also able to confirm that the post back from paypal actually includes the correct order_status? In your paypal configuration you should have a notify_uri which points to notify.php it is this file that handles the response from paypal.

A simple way to verify this is to create a file called ipntest.php (or whatever you like) and upload it to the root directory of your joomla installation. This file should contain the following:

<?php
$fromname"Your name here";
$from_email "your email here";
$recipient_email "recipients email here";
$subject "Paypal IPN Test";
$body null;
$header "From: ".$fromname" <".$from_email.">\r\n";
foreach($_POST as $var=>$val){
$body .= $var.":".$val."/n";
}
mail($recipient_email$subject$body$header);
?>



Then update your paypal configuration and modify the notify_uri to point to this newly created file. Now make a purchase (I'm assuming you have set everything to test mode Smiley ).

You should receive an email with the info that PayPal returns to your site after the purchase.

Take a look at this email and confirm that the order_status is "Confirmed".

I gave this a try - The email which came through as a result of the above test with ipntest.php contains the following:-

mc_gross:6.97/ninvoice:71_c2f3f218636faa98c574ed16500c8/nprotection_eligibility:Ineligible/naddress_status:unconfirmed/npayer_id:5SANZVPRSZ69U/ntax:0.00/naddress_street:Old Town Road/npayment_date:14:43:21 Jun 16, 2009 PDT/npayment_status:Completed/ncharset:windows-1252/naddress_zip:Bantry 1/nfirst_name:Test/nmc_fee:0.59/naddress_country_code:IE/naddress_name:John Banter/nnotify_version:2.8/ncustom:/npayer_status:verified/nbusiness:shopowner@domain.com/naddress_country:Ireland/naddress_city:Bantry/nquantity:1/nverify_sign:AFcWxV21C7fd0v3bYYYRCpSSRl31AAM4-.ksto8kS7IQpPXS0wxePHiU/npayer_email:info_1237914324_per@domain.com/ntxn_id:04191951KV711614W/npayment_type:instant/nlast_name:User/naddress_state:CO/nreceiver_email:shopowner@domain.com/npayment_fee:/nreceiver_id:XE6F7G235AEQ6/ntxn_type:web_accept/nitem_name:Order Number: 11/nmc_currency:EUR/nitem_number:/nresidence_country:GB/ntest_ipn:1/nhandling_amount:0.00/ntransaction_subject:Order Number: 11/npayment_gross:/nshipping:0.00/n

I'm not 100% sure of the various values contained within the email. There is no mention of "order_status" anywhere. However you can see within this email there is a "npayment_status:Completed", and this seems to tie in with this code snippet in my notify.php file around line 384:-


  // UPDATE THE ORDER STATUS to 'Completed'
                if(eregi ("Completed", $payment_status)) {
                    $d['order_status'] = PAYPAL_VERIFIED_STATUS;


So my interpretation is that yet again the payPal transaction was successful, but still the order status remains stuck at "pending".

Can anyone shed light on what the problem might be- why the order status will not change - even though the IPN is communicating a successful i.e. COMPLETED transaction ??

There seems to be an enormous amount of angst out there with this particular issue - it really would be great if we could solve this once and for all.

In earnest....

Q.


fredzebu

Joomla 1.5.9, vm1.1.2 stable.
I'm testing with Test mode=No, and making $1 purchases. My netbank shows my credit card is being billed. Paypal says transaction successful, and return to merchant site says successful, BUT like everyone else order_status in db and email is Pending.

So, for testing, in administrator/components/com_virtuemart/notify.php, after:
// remove post headers if present.
      $res = preg_replace("'Content-type: text/plain'si","",$res);

I put this code:

## kas debug 22/07/2009
  $docroot=$_SERVER['DOCUMENT_ROOT'];
  $filedescriptor="$docroot"."/"."tmp/paypal.txt";
  if ($filehandle=fopen($filedescriptor, "w"))
  {
    $filedata="order_id=$order_id\n\nres=$res\n\npayment_status=$payment_status\n\n";
    fwrite($filehandle,$filedata);
    fclose($filehandle);
  }
######

File paypal.txt is created and I grab it with FTP. This is what it says:

######################################
order_id=25

res=HTTP/1.1 200 OK Date: Thu, 23 Jul 2009 03:42:47 GMT Server: Apache Set-Cookie: "i removed the cookie"; domain=.paypal.com; path=/ Set-Cookie: cookie_check=yes; expires=Sun, 21-Jul-2019 03:42:48 GMT; domain=.paypal.com; path=/ Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/ Set-Cookie: navlns=0; expires=Wed, 18-Jul-2029 03:42:48 GMT; domain=.paypal.com; path=/ Vary: Accept-Encoding Connection: close Content-Type: text/html; charset=UTF-8  VERIFIED

payment_status=Pending
###################################

NOTE WELL that payment_status=Pending, so that's it. It seems to me that Paypal is returning incorrect POST data.

    $payment_status = trim(stripslashes($_POST['payment_status']));


Can someone else repeat my test and report the results please??



fredzebu

More Research: just found this Paypal Developer forum topic:
http://paypaldev.org/topic.asp?TOPIC_ID=80

###############################################################
Bruce

16 Posts
   
Posted - 11/01/2002 :  09:27:00 
Another basic question from me!!!
If $payment_status is Pending, shouild my script do nothing and wait for the $payment_status="Completed" to be returned from the paypal server.

I am only wanting to process an order when I know that it is verified and payment_staus="completed".

Apologies if this seems a simple question.

Thanx
Bruce

paypal_pb

3472 Posts
   
Posted - 11/01/2002 :  09:49:16 
Yes, you can disregard when payment_status=Pending and just wait for the Completed IPN. In general, you should only fulfill Completed payments.

Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn
Go to Top of Page

paypal_pb

3472 Posts
   
Posted - 11/01/2002 :  17:26:17 
It depends on the situation. A Pending echeck has a very high probability of completing. While you may not want to ship a physical good based on a Pending payment, you might be comfortable granting access to an online service or delivering a digital good.

But if you completely ignore Pending payments, the subsequent IPN with payment_status=Completed resembles a buyer doing an instant payment at that time.

Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn

################################################################


I've also googled to try to find all possible values for payment_status. Zen-cart identifies these:
    payment_status_id:     1
    payment_status_name:    Completed


    payment_status_id:    2
    payment_status_name:    Pending


    payment_status_id:    3
    payment_status_name:    Failed


    payment_status_id:    4
    payment_status_name:    Denied


    payment_status_id:    5
    payment_status_name:    Refunded


    payment_status_id:    6
    payment_status_name:    Canceled_Reversal


    payment_status_id:    7
    payment_status_name:    Reversed

So, based on the Paypal Dev Topic, and the probable values for payment_status returned, I'm inclined to hack notify.php to force payment_status="Confirmed" if it is returned as Pending.

I'll advise my client to always logon to their Paypal acct and check before shipping.

Would love to see this resolved elegantly.

MikeUK

Rather than hacking notify, I'd suggest just changing the Paypal config in VM.

As I posted in a different thread, http://forum.virtuemart.net/index.php?topic=48421.30, I  am curious as to the settings of people that get confirmed and those that don't. I have seen sites with my own eyes receive 'confirmed' and at least one of these is using just the default setup (no custom Paypal mods).

I have posted the rest in the other thread as it was the original and has a lot of interest:  http://forum.virtuemart.net/index.php?topic=48421.30
Get answers faster:
    [li]
Search forum. You might find answer[/li]
[li]Use existing threads. Keep Q + A consolidated[/li]
[li]Troubleshooting? See http://forum.virtuemart.net/index.php?topic=60033.0[/li]
[li]For admin user manual - http://virtuemart.net/documentation/User_Manual/index.html[/li]
[li]For coding (developer manual) - http://virtuemart.net/documentation/Developer_Manual/index.html[/li][/list]

I can build your online shop, setup or customize Virtuemart or help your existing shop maximize its potential. Email / PM for info

ViperFish

I too am also struggling with this issue. Running VM1.1.3 and J!1.5.14.

I created a testipn.php script using this code.
<?php
$fromname"Shop name";
$from_email "sender@email.com.au";
$recipient_email "recipient@email.com.au";
$subject "Paypal IPN Test";
$body null;
$header "From: ".$fromname" <".$from_email.">\r\n";
foreach($_POST as $var=>$val){
$body .= $var.":".$val."/n";
}
mail($recipient_email$subject$body$header);
?>


And this the result.

mc_gross:900.00/ninvoice:65_6705ff25ec262dc5c3bf7ade399db/nprotection_eligibility:Ineligible/naddress_status:unconfirmed/npayer_id:JHGHY6RQFT5DE/ntax:0.00/naddress_street:PO BOx slkdjfl/npayment_date:01:04:47 Nov 26, 2009 PST/npayment_status:Completed/ncharset:windows-1252/naddress_zip:6666/nfirst_name:Test/nmc_fee:21.90/naddress_country_code:AU/naddress_name:John P/nnotify_version:2.8/ncustom:/npayer_status:unverified/nbusiness:seller_1259222635_biz@viperfish.com.au/naddress_country:Australia/naddress_city:sldkfho/nquantity:1/nverify_sign:AXgu3byOTxDEQDNKtOr0pNXGGAFIAIZkb8Ym-6Yj-BWEHD3XSMDo2IHZ/npayer_email:buyer_1259222398_per@viperfish.com.au/ntxn_id:7M9930572K2703636/npayment_type:instant/nlast_name:User/naddress_state:WA/nreceiver_email:seller_1259222635_biz@viperfish.com.au/npayment_fee:/nreceiver_id:A6WQJHA62WRFG/ntxn_type:web_accept/nitem_name:Order Number: 6/nmc_currency:AUD/nitem_number:/nresidence_country:AU/ntest_ipn:1/nhandling_amount:0.00/ntransaction_subject:Order Number: 6/npayment_gross:/nshipping:0.00/n

The payment status is completed. But, looking through the notify.php script I can't find any reference to "Order Number". In this case order number 6. The notify script retrieves the invoice number but not the order number. Here's the code from line 181;

// The Order Number (not order_id !)
$invoice =  trim(stripslashes($_POST['invoice']));


Also it looks like values for "item_name" and "transaction_subject" are missing from the output. Coincidentally(?) these appear immediately before the order number. They also don't appear anywhere in the notify.php script.

So how does the notify script know which order to update?
http://viperfish.com.au <--- New website and portfolio online now.