News:

Support the VirtueMart project and become a member

Main Menu

Order confirmation email sent before PayPal payment processed

Started by davidm, May 01, 2008, 12:57:41 PM

Previous topic - Next topic

ladumeni

Glad to here you are getting up and running !

1. The order_number should be return by paypal. When clicking on "return to merchant" The redirection url should contain &order_number=42_960eda3802d57edd763077248714a is this not the case ? Check your form on the last checkout page, it should contain a line like


<input type="hidden" name="return" value="http://www.yoursite.com/index.php?option=com_virtuemart&amp;page=checkout.result_confirmation&amp;order_number=63_dd9ce0f5aa4e09ca25b3f0cc03bed" />




2. didn't implement that but should be fairly easy. Look at the $post_variables array. Add any vars you which to post to paypal there with their respective values

3. Worldpay. Intergration might take a while ... ;)

Cheers, Larsen

ralphonz

Hi,

Thanks for a great patch.  Everything is installed.  However, when i make a transaction, I get 'order not found' followed by the order number when Paypal returns me to my site.  Also Pay pal notification emails are sent out but no invoice is sent. 
If i view the orders in the VM back-end I see that they are still on 'pending' rather than confirmed.  Once I change them to 'confirmed' the invoice and download code for the product is sent.  Why am i still having to change order status to confirmed manually??

If anyone could shed some light on this that would be great.

Many thanks

UPDATE:  The order number is contained in the URL upon redirection- the compleate URL is:

http://www.mysite.com/index.php?option=com_virtuemart&page=checkout.result_confirmation&order_number=161_853d496edfd780c837d4d7af8319

Ralph

blisscloset

Hi ladumeni,

Thanks for the great work.

Will you be able to provide the code that posts the details (name/item/sku/quantity) of all the purchased items to PayPal?

ralphonz

Hi,

I checked the database table jos_vm_orders_temp and no orders are being created here, hence the 'order not found message' upon return from paypal.  Does anyone with a bit more knowlage know why this might be??

Thanks in advance

Ralph

ladumeni

Hey,


If the order is visible through the backend of VirtueMart, then the confirmation has been correctly received from PayPal (before that the order is only in the temp table). I'm not sure if this works correctly for you and if there is only an issue with the redirection. So please follow these steps to narrow down the error:


1.The order is saved in the table jos_vm_orders_temp when you reach the last step of the checkout procedure. At the moment you see the step 4 of 4 there should be an entry in the jos_vm_orders_temp table (it will later be removed once confirmation by PayPal reaches your site). If this is not the case, something is wrong with the "Payment Extra Info" code of the payment module.

To debug this change line 9 of the "Payment Extra Info" code from

$NOTIFY_DEBUG = false;


to

$NOTIFY_DEBUG = true;

and follow the checkout procedure until you reach the last step (before the redirection to PayPal) and check the jos_vm_orders_temp table for a new entry. Please report if you have an entry and what you see on the last checkout Page (you should have some additional debug info displayed).


2. When returning to you site the "order not found" error appears if:

      a) your order is not in the real orders table:

SELECT order_status, order_id FROM #__{vm}_orders WHERE ";
$q .= "#__{vm}_orders.user_id= '" . $auth["user_id"] . "' ";
$q .= "AND #__{vm}_orders.order_number= '$order_number' ";



    b) your order is not in the TEMP table

$sql = "select * from #__{vm}_orders_temp WHERE order_number='".$order_number."'";

So do you have the temp order before you are redirected to paypal and does it disappear once confirmed by paypal ?


3. In order to have the right status, make sure the "Order Status for successful transactions" is set correctly in the payment module configuration (I use "Confirmed" but depends if you set up additional status).

4. Have you patched the administrator/components/com_virtuemart/classes/ps_checkout.php file correctly ? The patch avoids creating a new ordernumber when generating the real transaction (A OrderNumber was already generated when creating the temp order and this one must be used for the real order). So please check if the ordernumber in the temp table is the same as the ordernumber in the jos_vm_orders table once confirmed.

Hope this helps

Larsen



ladumeni

@blisscloset: sorry but no plan on developping this in the near future as our client didn't need such a feature... 

ralphonz

Hi,

Thanks for all that info.  However it was my stupidity that caused the error! I was logged into the wrong database because my browser logged me in automatically! therefore I had created the new table in the wrong one - wooops  :-\

The database entries are now being created as they should be.  Payment is going through with paypal however upon return i get the message-
"The payement of your order hasn't yet been confirmed by the payement gateway. Please refresh this page and wait for the confirmation to reach the site. For troubleshoting please contact us directly"

I have checked the paypal IPN using the test tool in the sandbox site and this is sending IPN's to http://www.mysite.com/administrator/components/com_virtuemart/notify_gen_transaction.php successfully.
I am not sure if it should but the test does not cause the script to send any emails out. I get the same results for notify.php

The order number in the vm_orders_temp table match the order number in the return url, but this order is not transfered to the vm_orders table, as a result no order is showing in the vm backend. I know it is not creating a new order number as there are no other orders for that date.

Any help is really appreciated. Thanks

Ralph

ladumeni

The entire Transaction creation (the move from temp table to the vm_order table, including the mail to the customer) is generated on receiving the IPN confirmation from PayPal. It seems the confirmation is not reaching your site correctly....

a) Use the notify_gen_transaction.php for the notification. Do you receive any email from your system  with subject like "PayPal IPN XXX" ? Also check your php error log as any error produced during the confirmation through PayPal will not be seen...

b) Not quite sure how you define that the test tool is working ... Do you receive emails from your system ? Is a transaction created ?

Need a bit more info to help ....

ralphonz

a) I am using notify_gen_transaction.php for the notification, I don't receive any emails from my system at all. I could not find anything in the error logs, but did find these lines in the activity logs?:

Quotesonic-rites.com: [06/Aug/2009:16:17:51 +0100] 216.113.191.33 - - "POST /administrator/components/com_virtuemart/notify_gen_transaction.php HTTP/1.0" 200 17 "-" "-"


Quotesonic-rites.com: [06/Aug/2009:16:19:08 +0100] 94.195.82.180 - - "POST /administrator/components/com_virtuemart/notify_gen_transaction.php HTTP/1.1" 200 29 "http://www.sonic-rites.com/index.phpoption=com_virtuemart&Itemid=302&checkout_stage=4&lang=en&page=checkout.index&payment_method_id=17&ship_to_info_id=a3a8108ca3628a4dce18ad31fd02ab89&shipping_rate_id=" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/530.19"


b) Using the IPN test tool in the paypal sandbox to send a fake transaction, I get a 'IPN sent successfully' message on the paypal site but no mail is sent out.

On the paypal site, under profile>Instant payment notification preferences i have the following URL enabled: http://www.mysite.com/administrator/components/com_virtuemart/notify_gen_transaction.php - which has permissions set at 666.  What else can I change to ensure that the paypal IPN reaches the site?

Thank you so much for your time and help looking into this.

ralphonz

one more thing is that when I tested this under my real paypal account (rather than sandbox) I got the same errors and the paypal IPN history shows the IPN as 'sent'?

ladumeni

hey ralphonz,

To really debug your problem we need to have correct logging. The notify_gen_transaction.php script is filled with  lines like:

debug_msg( "1. Finished Initialization of the notify.php script" );   

which should generate debug information into your php_error log file. My log looks like this :


[28-Jul-2009 19:23:25] 1. Finished Initialization of the notify.php script

[28-Jul-2009 19:23:25] 2. Received this POST: orderID=63_69356ecc44b1d5da4f67ce5f26f&amp;currency=CHF&amp;amount=78.3&amp;PM=CreditCard&amp;ACCEPTANCE=test123&amp;STATUS=9&amp;CARDNO=XXXXXXXXXXXX1111&amp;ED=0311&amp;CN=larsen&amp;TRXDATE=07/28/09&amp;PAYID=4942121&amp;NCERROR=0&amp;BRAND=VISA&amp;IPCTY=CH&amp;CCCTY=US&amp;ECI=12&amp;CVCCheck=NO&amp;AAVCheck=NO&amp;VC=NO&amp;SHASIGN=4B4779E54A14BCBEAC00EB096B2206D779448A2C&amp;order_number=63_69356ecc44b1d5da4f67ce5f26f&amp;IP=85.218.99.179&amp;

[28-Jul-2009 19:23:25] 3 Matched ip_adress: 212.35.124.164

[28-Jul-2009 19:23:25] 5. Checking Ammount and currency 



etc.

To check if you the errors are logeed correctly simply add on line 32


debug_msg( "TESTME" );   

And call yourself the notify_gen_transaction.php  file. You should thus see in your php error log file and entry "TESTME". If this doesn't work you need to check your server setup to properly log php errors... Please refer to php/apache manual to set that up.

If this is working, then the notification from Paypal should also generate this log message and the others mentioned earlier. If this is not the case, then PayPal is not reaching your site correctly which is more of a network/firewall/wrong URL issue...

Let me know what you see in your log ...

Regards Larsen

ralphonz

Hey there,

Thanks for the help,

I added the line to the script, when i call the page i get

Quote[Mon Aug 10 11:08:04 2009] [error] [client 94.195.82.180] FastCGI: server "/var/www/fcgi/php-cgi" stderr: TESTME
[Mon Aug 10 11:09:16 2009] [error] [client 216.113.191.33] FastCGI: server "/var/www/fcgi/php-cgi" stderr: TESTME


I get this same error message when using paypal sandbox to complete a transaction and when using the IPN simulator to send an IPN message to notify_gen_transaction.php, however I do not see any other errors or messages in the log - only TESTME.

After the transaction I still see the "The payement of your order hasn't yet been confirmed by the payement gateway" message.

Thanks


ladumeni

The error log you pasted here looks like an apache log. It isn't the php error log file I'm talking about. Setup php error log through your php.ini file :

error_reporting  =  E_ALL & ~E_NOTICE
display_errors = On
log_errors = On
error_log = "/var/log/yourfilename.log"

and generate any error (ex. syntax error). You should find a trace of that error in the file set up under "error_log" (here "/var/log/yourfilename.log").

ralphonz

Hi,

The php settings on our host (streamline.net) are fixed and cannot be modified according to their support department.  We don't have access to the php.ini file.  I have put in a request that they change it but its not looking likely :-(



ladumeni

IF you add another line like

debug_msg( "TESTME 2" ); 

Do you have both lines in your error log file ? You should then also see a line like "1. Finished Initialization of the notify.php script" ...

If you see both lines ("testme" and "testme 2") and don't see the "finished Init...." line then there is a prob initiating the framework neccesary. Move line  119

debug_msg( "1. Finished Initialization of the notify.php script" );             

further up until you see the line and figure out where the script stops (last line where the debug message is displayed)...

Let me know if you can figure this out ....