VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Payment VM 1.1 => PayPal / PayPal Pro VM 1.1 => Topic started by: davidm on May 01, 2008, 12:57:41 PM

Title: Order confirmation email sent before PayPal payment processed
Post by: davidm on May 01, 2008, 12:57:41 PM
I am using Joomla 1.5 and VirtueMart 1.1. I have VirtueMart set to "Silent Account Creation" and PayPal as a single Payment Method.

The shopper goes through the checkout process and, on confirming the order on the last checkout page, is correctly redirected to the PayPal site. However, it seems that order confirmation emails are sent (both to the shopper and the store owner) before the payment is made. These emails appear to be sent as soon as the shopper is redirected to the PayPal site.

I would really like to change this so that the order confirmation emails are only sent if the payment is successful. Does anyone know how I can get it working like that or what the problem might be?

I think I am going to have big problems with user confusion, order management and stock management unless I can find a solution to this.

Thanks
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: willowtree on May 01, 2008, 13:07:08 PM
not sure if its changed in 1.1, but in 1.0 the order is set to pending before paypal payment is processed, and only set to confirmed when the payment is processed by paypal.

there are other posts about this on the forum somewhere,

hth
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: davidm on May 01, 2008, 16:04:36 PM
Thanks hth for the quick response - that was very helpful. I found the following 1.0 discussions:

http://forum.virtuemart.net/index.php?topic=22819.0
http://forum.virtuemart.net/index.php?topic=17490.0
http://forum.virtuemart.net/index.php?topic=19236.0

These have helped me understand why Virtuemart handles pending transactions the way it does, but I think some challenges remain:

1. When the "No Account Creation" problem (http://forum.virtuemart.net/index.php?topic=39156.0) is fixed, I would really like to use that setting. If no account has been created for the user, it doesn't make sense to send a pending email with a link because the shopper doesn't have an account to use to complete their order. If they didn't complete their PayPal payment and still want to purchase then they will need to start again.

2. In my experience, most ecommerce sites only send a confirmation when the purchase has been made. Shoppers may miss the pending status and get confused.

3. In the case where there are items for sale with very limited stock, 'purchases' made without payment remove the item from stock even though the items are not actually sold.

In order to help with these issues whilst still allowing confirmation pending emails for those that like them, my suggestions would be to:

a) have a configuration option making it possible to either enable or disable order confirmation emails when the order is in a pending state (confirmation orders on completion should, of course, be sent)

and

b) have an optional background process that performs housekeeping on old pending orders. At its simplest, this could just delete pending orders that are older than x minutes. Or a more advanced solution might (optionally) first send an email to shoppers about pending orders older than y minutes giving them z days to complete their order before it is deleted.

Whilst not essential, I think these changes might help me and others who have had difficulty with the way pending orders are handled. Overall though, I must say that I think VirtueMart is fantastic. I am not being critical - Virtuemart is great software and I really appreciate all the work that has been put into 1.1.  Thanks!
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Bob Bloom on May 05, 2008, 22:04:07 PM
As a wonderful client referred to this thread, I wanted to add my two cents.

When you click the order confirmation in checkout, function add( &$d ) is processed in /administrator/components/com_virtuemart/ps_checkout.php. It's description, ripped from the source code, is "This is the main function which stores the order information in the database".

The "INSERT" statement which sticks the new order into the database is different in VM 1.1. However, the result is the same. Here's the field values, verbatim from the source code:

// Collect all fields and values to store them!
$fields = array(
'user_id' => $auth["user_id"],
'vendor_id' => $ps_vendor_id,
'order_number' => $order_number,
'user_info_id' =>  $d["ship_to_info_id"],
'ship_method_id' => @urldecode($d["shipping_rate_id"]),
'order_total' => $order_total,
'order_subtotal' => $order_subtotal,
'order_tax' => $order_tax,
'order_tax_details' => serialize($order_tax_details),
'order_shipping' => $order_shipping,
'order_shipping_tax' => $order_shipping_tax,
'order_discount' => $payment_discount,
'coupon_discount' => $coupon_discount,
'coupon_code' => @$_SESSION['coupon_code'],
'order_currency' => $GLOBALS['product_currency'],
***SEE THIS ONE!!** --> 'order_status' => 'P',
'cdate' => $timestamp,
'mdate' => $timestamp,
'customer_note' => htmlspecialchars(strip_tags($d['customer_note']), ENT_QUOTES ),
'ip_address' => $ip
);


What is hard-coded: 'order_status' => 'P', That is, order status = pending.

Then, if you keep scrolling down, near the end of the function:
// Send the e-mail confirmation messages
$this->email_receipt($order_id);



So, an email is sent out to your customer with order = pending.

If you want to suppress the "pending" email completely, and deny me my hourly fee, then change $this->email_receipt($order_id); to //$this->email_receipt($order_id);

-Bob



Title: Re: Order confirmation email sent before PayPal payment processed
Post by: davidm on May 06, 2008, 07:55:33 AM
Thanks, Bob! That's a great help!
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: chac416 on June 09, 2008, 16:54:41 PM
doesn't look like it worked out for me :S
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: chac416 on June 13, 2008, 18:03:15 PM
Quote from: willowtree on May 01, 2008, 13:07:08 PM
not sure if its changed in 1.1, but in 1.0 the order is set to pending before paypal payment is processed, and only set to confirmed when the payment is processed by paypal.
there are other posts about this on the forum somewhere,
hth
Ok, is it possible to take off the pending part of the paypal process.
I do not want the order to be put on pending.
either complete transaction or nothing.
how to?  help anyone?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: chac416 on June 13, 2008, 18:43:05 PM
Hmmmm, I did a smarter change I guess...
Maybe you guys can test it more to see if it works well....
instead of commenting out the email_receipt, just make it run when the order is confirmed.
So i did this:


if ( $order_status == "C" ) {
  $this->email_receipt($order_id);
}


Then I tried with Paypal, and it did not send out an email with a pending status. it was recorded in the database as a pending order thou which is fine. it won't create confusion for the customer.

now i still need to test if it does send out a confirmation order when confirmed...

if anyone tries it then let me know how it goes... thanks

----
Quote from: Bob Bloom on May 05, 2008, 22:04:07 PM
As a wonderful client referred to this thread, I wanted to add my two cents.
When you click the order confirmation in checkout, function add( &$d ) is processed in /administrator/components/com_virtuemart/ps_checkout.php. It's description, ripped from the source code, is "This is the main function which stores the order information in the database".
The "INSERT" statement which sticks the new order into the database is different in VM 1.1. However, the result is the same. Here's the field values, verbatim from the source code:
// Collect all fields and values to store them!
$fields = array(
'user_id' => $auth["user_id"],
'vendor_id' => $ps_vendor_id,
'order_number' => $order_number,
'user_info_id' =>  $d["ship_to_info_id"],
'ship_method_id' => @urldecode($d["shipping_rate_id"]),
'order_total' => $order_total,
'order_subtotal' => $order_subtotal,
'order_tax' => $order_tax,
'order_tax_details' => serialize($order_tax_details),
'order_shipping' => $order_shipping,
'order_shipping_tax' => $order_shipping_tax,
'order_discount' => $payment_discount,
'coupon_discount' => $coupon_discount,
'coupon_code' => @$_SESSION['coupon_code'],
'order_currency' => $GLOBALS['product_currency'],
***SEE THIS ONE!!** --> 'order_status' => 'P',
'cdate' => $timestamp,
'mdate' => $timestamp,
'customer_note' => htmlspecialchars(strip_tags($d['customer_note']), ENT_QUOTES ),
'ip_address' => $ip
);

What is hard-coded: 'order_status' => 'P', That is, order status = pending.
Then, if you keep scrolling down, near the end of the function:
// Send the e-mail confirmation messages
$this->email_receipt($order_id);

So, an email is sent out to your customer with order = pending.
If you want to suppress the "pending" email completely, and deny me my hourly fee, then change $this->email_receipt($order_id); to //$this->email_receipt($order_id);
-Bob
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: draftvader on June 25, 2008, 18:02:12 PM
Just launched our store and I was talking to the first customer as he ordered.  He received the "pending" e-mail (as I have done in testing) before making any payment.  He commented that this could be confusing.

So, I guess what I am trying to say is that I am with everybody else here and would love a tested solution to this problem.

Many thanks for the GREAT system though!!!
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: bulabula on July 02, 2008, 03:58:18 AM
I commented out that line and it works great. My customers now get the Purchase Order (which I changed to Purchase Receipt in english.php) after they have paid on Paypal and come back to the site and at the same time they get a separate email that says "the status of your order has been changed: confirmed".
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: mccosha on July 23, 2008, 11:30:52 AM
Hey, great post - helped a lot !
How would I go about making the word "PENDING"  RED and in larger font ?
It will make it easier to emphasize it to the customer... I don't want to turn the email off, but it has caused some confusion though...

Joomla 1.5 VM 1.1

Thanks

Ariane
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: sunmade on July 24, 2008, 19:32:47 PM
Where exactly do you comment out the code?  I don't seem to have /administrator/components/com_virtuemart/ps_checkout.php  and am only using paypal as my method of payment.  Thanks in advance!

Quote from: Bob Bloom on May 05, 2008, 22:04:07 PM
As a wonderful client referred to this thread, I wanted to add my two cents.
When you click the order confirmation in checkout, function add( &$d ) is processed in /administrator/components/com_virtuemart/ps_checkout.php. It's description, ripped from the source code, is "This is the main function which stores the order information in the database".
The "INSERT" statement which sticks the new order into the database is different in VM 1.1. However, the result is the same. Here's the field values, verbatim from the source code:
// Collect all fields and values to store them!
$fields = array(
'user_id' => $auth["user_id"],
'vendor_id' => $ps_vendor_id,
'order_number' => $order_number,
'user_info_id' =>  $d["ship_to_info_id"],
'ship_method_id' => @urldecode($d["shipping_rate_id"]),
'order_total' => $order_total,
'order_subtotal' => $order_subtotal,
'order_tax' => $order_tax,
'order_tax_details' => serialize($order_tax_details),
'order_shipping' => $order_shipping,
'order_shipping_tax' => $order_shipping_tax,
'order_discount' => $payment_discount,
'coupon_discount' => $coupon_discount,
'coupon_code' => @$_SESSION['coupon_code'],
'order_currency' => $GLOBALS['product_currency'],
***SEE THIS ONE!!** --> 'order_status' => 'P',
'cdate' => $timestamp,
'mdate' => $timestamp,
'customer_note' => htmlspecialchars(strip_tags($d['customer_note']), ENT_QUOTES ),
'ip_address' => $ip
);

What is hard-coded: 'order_status' => 'P', That is, order status = pending.
Then, if you keep scrolling down, near the end of the function:
// Send the e-mail confirmation messages
$this->email_receipt($order_id);

So, an email is sent out to your customer with order = pending.
If you want to suppress the "pending" email completely, and deny me my hourly fee, then change $this->email_receipt($order_id); to //$this->email_receipt($order_id);
-Bob
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: willowtree on July 25, 2008, 10:28:12 AM
try

/administrator/components/com_virtuemart/classes/ps_checkout.php
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: winmonaye on August 29, 2008, 09:23:48 AM
I am testing with paypal standard with sandbox and comment out the "$this->email_receipt($order_id);" but still sending out email after redirected to paypal.

And one more thing is, even thought i could comment out this, when change to confirm, only status change notification is send out, not whole confirmation order detail, right?

This is very confusing and please help if someone know work around.

Thank you,
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MikeUK on September 05, 2008, 01:11:40 AM
.
Important note: please be careful with Bob Bloom's fix above. It will disable email confirmations for all payment methods. The customer will then receive an email after the Paypal transaction saying 'Order status changed'. This will make no sense as they have not received an order.


Quote from: chac416 on June 13, 2008, 18:43:05 PM
Hmmmm, I did a smarter change I guess...
Maybe you guys can test it more to see if it works well....
instead of commenting out the email_receipt, just make it run when the order is confirmed.
So i did this:

if ( $order_status == "C" ) {
  $this->email_receipt($order_id);
}

No, that won't work. This stage is too early in the process - this is before being forwarded to PayPal, so the order can never be confirmed at this point.

Quote from: chac416 on June 13, 2008, 18:03:15 PM
Quote from: willowtree on May 01, 2008, 13:07:08 PM
not sure if its changed in 1.1, but in 1.0 the order is set to pending before paypal payment is processed, and only set to confirmed when the payment is processed by paypal.
there are other posts about this on the forum somewhere,
hth
Ok, is it possible to take off the pending part of the paypal process.
I do not want the order to be put on pending.
either complete transaction or nothing.
how to?  help anyone?

That has giving me an idea. You might be on to something. Perhaps orders should start with a  status like 'Pending' for Cash on Delivery orders, and 'Awaiting Payment' for Paypal orders, with the paypal transaction returning 'confirmed', 'failed' or 'cancelled'. Pending would then be used for Cash on Deliver orders, etc only.

That way, with the sending emails before the Paypal transaction, at least the email would be an order confirmation with 'Awaiting Payment', then after a successul transaction the customer would recieve the 'changing order status' email saying 'Confirmed' (or 'failed', 'cancelled'). I think this would make much more sense to the customer. It then frees up Pending to mean what it should - that the order has been confirmed by the customer but there is still asction due (the customer pays later).

Any thoughts on this? Obviously it would mean changing the database and selecting the initial order status with a condition depending on if it is paypal or other payment method.

FYI, I'm not keen on the idea of the order confirmation being sent after the Paypal transaction (there was fix for this in another thread). I tried it but if the transaction hits any problem the customer is sent no record at all. With the above, the customer can return to view the order and click on the 'pay by paypal' button within the order details.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: cinos on January 12, 2009, 15:08:48 PM
bumping this.

This needs to be addressed as a very important topic.

Any solutions yet?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Frederik on January 19, 2009, 18:06:21 PM
I have talked to several people who have chosen another shopping cart solution because of this issue. I am afraid that I am about to do the same thing. It is a shame as I think VM is a really great solution.

Can we expect this issue to be solved in a future update?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MikeUK on January 19, 2009, 19:53:32 PM
Quote from: Frederik on January 19, 2009, 18:06:21 PM
Can we expect this issue to be solved in a future update?

Quote from: cinos on January 12, 2009, 15:08:48 PM
This needs to be addressed as a very important topic.
Any solutions yet?

I think at this stage it's down to us. This isn't a 'fix it' issue. As yet there hasn't been much discussion on how this might be better done. just a few ideas with no real response. Do either of you have on thoughts on a better way to do it?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: cinos on January 20, 2009, 11:49:06 AM
Well the best way, I would have thought, would be to allow us to set at what stage an email is sent.

With paypal payments, thanks to notify.php the status of an order is updated automatically to 'Confirmed' once payment has been issued. So instead of having the email sent out when an order has a pending status, there might be an option for us to send the email out on Confirmed status instead.

This could be a simple drop box selection, where we could just pick the status suitable for us.

That way everyone is happy. :)
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: kiper on January 20, 2009, 22:21:39 PM
I second this. It would be a great solution if there was a possibility to select at which stage to send the order confirmation mail and that this isn't locked to the payment modules but rather integrated with VM.
I have clients using different payment modules and they all want to send one confirmation mail AFTER payment has been confirmed.
Would be one of the best additions to VM.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MikeUK on January 20, 2009, 23:21:46 PM
Quote from: cinos on January 20, 2009, 11:49:06 AM
Well the best way, I would have thought, would be to allow us to set at what stage an email is sent.

With paypal payments, thanks to notify.php the status of an order is updated automatically to 'Confirmed' once payment has been issued. So instead of having the email sent out when an order has a pending status, there might be an option for us to send the email out on Confirmed status instead.

This could be a simple drop box selection, where we could just pick the status suitable for us.

That way everyone is happy. :)

In my personal opinion, this would be overkill. It's not a bad idea, but I think that might be something for later versions, and depends if someone has the time to do that. Initially, it seems there are more immediate concerns. The few so far that have expressed a preference are suggesting it would be better with the email being sent after confirmation, without the pending email.

Obviously, this may create other problems depending on what payment methods are used.

My previous post was also to point out that this is not a feature request thread, so putting these ideas into action, as well as the ideas themselves, is done to us.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Frederik on January 21, 2009, 00:08:39 AM
Maybe it is an overkill with the option to choose when to send out the mail, but it would work very nicely for me.

In the perfect world I would also like to have the cart emptied only when the status changes to confirmed (at the same time as the confirmed mail goes out). That way the customer can go back and keep adding products up till the moment when the payment is actually completed. And if something goes wrong in the payment the cart still remains. I realize it is possible to re-enter the order from the pending mail, but it would be easier just to have the cart unchanged. That would be absolutely perfect  8)

Thanks a lot for the replies...

Frederik
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: cinos on January 21, 2009, 01:14:29 AM
If you can work out a way to simply send the email after the payment has been confirmed then that will make me very happy. ;)

As it is the email is just a bit too...'pushy', when sent on status pending. Especially if the person decided not to pay for good reasons.

It's a bit too much: "Could you pay us please!"
Rather than: "Thanks for the order, payment was recieved with thanks"
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MikeUK on January 21, 2009, 13:29:14 PM
Yes, I agree about the pending email. I also think it is too soon between emails which could cause confusion. When a Paypal order, for example is successful, then the customer gets possibly three emails. One for pending, one for status change, and one from paypal. I've no doubt there could be a better system than this. However, this only relates to payment processors, I'm not sure it applies to everyone.

I also think Frederik's idea re. the cart is a good one.

But, more importantly, I don't think this thread will get anywhere if everyone is just expecting everyone else to do it. I'm happy to help because I think this would be useful.


Title: Re: Order confirmation email sent before PayPal payment processed
Post by: opwdecks on January 21, 2009, 14:54:09 PM
The pending email(s) should just be removed altogether for PayPal IMO. It just adds confusion to my staff and customers.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Frederik on January 21, 2009, 21:07:22 PM
Mike - I wouldn't mind helping as well but I am afraid my programming skills lacks the quality needed :-)
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: mpoweringu on January 21, 2009, 23:52:22 PM
OK, I have to admit that I haven't read EVERY post in this particular topic, but I read enough to know that many of you are having the same issue that I am in trying to prevent a "Pending" order email from going to the customer.

Well, I THINK I've got it somewhat figured out for VM 1.1.2 (and ONLY this version) but I've got to head out for a bit.  I'll try and get back on here tonight to post what I did. It basically requires two changes to the ps_checkout.php file.

It is currently hardcoded, however, I think I should easily be able to turn it into a configurable option on the backend... maybe in the template configuration controls?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MikeUK on January 22, 2009, 09:59:11 AM
Quote from: Frederik on January 21, 2009, 21:07:22 PM
Mike - I wouldn't mind helping as well but I am afraid my programming skills lacks the quality needed :-)

I guess there are not so many that could honestly say they have all the skills necessary for high quality programming. I think that not everyone realises that a number of the VM core team are not developers. But you can see there input all over the forum in different forms (whether coding or other).

Not for me to say if you should help or not. But from experience with threads such as this, the ones that tend to achieve something are those that have a high degree of input and cooperation. The ones that don't tend to get forgotten. At the moment, this thread is nowhere near popular enough or ideas-filled enough to get somewhere.

I'm only going on about this because I do think it is an important aspect of VM, but I also understand that the important thing is that many others feel the same way. So far it doesn't look like that is the case, considering how many VM systems must be using Paypal or similar.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: cinos on January 22, 2009, 13:30:54 PM
It might also be because alot of people are unaware that the emails are going out like this.

I myself didn't realise until I cancelled an order (paypal_sandbox) and discovered that the confirmation email had still been sent out.

It's a stealthy process. :-\
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MikeUK on January 22, 2009, 14:20:33 PM
Maybe, but I really hope that this is a very very small number. Who wouldn't test a shop from the admin and user side before going live? Especially where money is involved. Such people probably wouldn't be smart enough to find this forum anyway. :)

As you say yourself, you were using the sandbox, so you were testing. I can't think of any major project  I've worked on, especially where large open-source software was involved,where the first version was 100% as I'd expected.

Out of interest ( a question for anyone here), what is your paypal config relating to pending, confirmed, etc options?

Title: Re: Order confirmation email sent before PayPal payment processed
Post by: angek on January 23, 2009, 04:02:44 AM
Quote from: mpoweringu on January 21, 2009, 23:52:22 PM
OK, I have to admit that I haven't read EVERY post in this particular topic, but I read enough to know that many of you are having the same issue that I am in trying to prevent a "Pending" order email from going to the customer.
Well, I THINK I've got it somewhat figured out for VM 1.1.2 (and ONLY this version) but I've got to head out for a bit.  I'll try and get back on here tonight to post what I did. It basically requires two changes to the ps_checkout.php file.
It is currently hardcoded, however, I think I should easily be able to turn it into a configurable option on the backend... maybe in the template configuration controls?

are you referring to the email_receipt() function in the ps_checkout.php file?
In the email_receipt function there are a number of calls to vmMail (for plain text emails and for html emails) which could be wrapped in conditional statements to check the order_status before sending the email. Specifically the following:

around line 2041 you should have this block of code:
if (ORDER_MAIL_HTML == '0') {

$msg = $shopper_header . $shopper_message . $shopper_footer;

// Mail receipt to the shopper
vmMail( $from_email, $mosConfig_fromname, $shopper_email, $shopper_subject, $msg, "" );

$msg = $vendor_header . $shopper_message . $vendor_footer;

// Mail receipt to the vendor
vmMail($from_email, $mosConfig_fromname, $vendor_email, $vendor_subject, $msg, "" );

}

Now change it to:
if (ORDER_MAIL_HTML == '0') {

$msg = $shopper_header . $shopper_message . $shopper_footer;

// Mail receipt to the shopper
        if (strtolower($order_status) != 'pending'){
    vmMail( $from_email, $mosConfig_fromname, $shopper_email, $shopper_subject, $msg, "" );
        }
$msg = $vendor_header . $shopper_message . $vendor_footer;

// Mail receipt to the vendor
vmMail($from_email, $mosConfig_fromname, $vendor_email, $vendor_subject, $msg, "" );

}



then on line 2160 you should have these 2 lines of code:

$shopper_mail = vmMail( $from_email, $mosConfig_fromname, $shopper_email, $shopper_subject, $shopper_mail_Body, $shopper_mail_AltBody, true, null, null, $EmbeddedImages);

$vendor_mail = vmMail( $shopper_email, $shopper_name, $vendor_email, $vendor_subject, $vendor_mail_Body, $vendor_mail_AltBody, true, null, null, $EmbeddedImages);


change it to:
if (strtolower($order_status) != 'pending'){
    $shopper_mail = vmMail( $from_email, $mosConfig_fromname, $shopper_email, $shopper_subject, $shopper_mail_Body, $shopper_mail_AltBody, true, null, null, $EmbeddedImages);
}

$vendor_mail = vmMail( $shopper_email, $shopper_name, $vendor_email, $vendor_subject, $vendor_mail_Body, $vendor_mail_AltBody, true, null, null, $EmbeddedImages);


This should prevent the email confirmation going out to customers when their order status is pending while still allowing the store owner to still receive the pending order emails.

I haven't tested this properly so if someone would like to give it a go and report back their findings then I'd be happy to code up some configurable options rather than having everything hardcoded.

By the way I'm using virtuemart 1.1.3 on Joomla 1.0.15 but should be the same for vm 1.1.3 for Joomla 1.5.x
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Frederik on January 23, 2009, 10:38:49 AM
Very nice. I don't have the time today but I'll test it first thing tomorrow and get back to you. Can't wait... Thanks a lot :-)
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Frederik on January 23, 2009, 17:15:30 PM
I have implemented the changes and the customer is now receiving a confirmation mail and no pending mail. That is a huge leap forward 8)

There is still some minor issues as I see it:

The confirmed mail the customer is receiving is just saying "status has changed". The customer isn't receiving the order details and the link to the order details as it was in the pending mail.

Also the text doesn't make sense as the confirmation mail is the first mail the customer is receiving. I take that it is an easy fix which I probably can do myself.

The shop is only receiving a pending mail and no confirmation mail. Personally I would much rather have the confirmed mail as a shop owner instead of the pending mail.

The VM page telling "the order is confirmed" before the payment is done, needs to be changed as it is saying: "a mail has been sent to...." I would change the overall message to something like: "a new payment window has been opened..." and so on and nothing about the order is confirmed which I find a bit confusing

I am using VM 1.1.3 and Joomla! 1.5.9

Very nice work Angek :)

Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MikeUK on January 23, 2009, 21:46:03 PM
I might be wrong, but I think a potential problem here is that this bit of code isn't used after confirmation. So it won't send a pending email, nor a confirmation email. The status change email is a separate process I think.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Frederik on January 26, 2009, 14:40:30 PM
I don't think I ever received a confirmation mail - just the pending mail and the status change mail.

I have spend hours to try and figure out where the code for the pending mail is produced and if it could be reused for a confirmation mail with no luck. Is there somebody that can lead me in the right direction? Does a documentation for the checkout procedure exist?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MikeUK on January 26, 2009, 14:50:38 PM
Sorry, yes, forget the confirmation email bit. If that was there, it would be problem solved!

The pending email is sent from ps_checkout.... a line point to a function called email_receipt I think.

The thing is, I believe that by the time the order is confirmed, it doesn't go back here.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Frederik on January 26, 2009, 15:02:15 PM
Where exactly does the status change? Not in the ps_checkout or..?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: angek on January 27, 2009, 02:19:45 AM
Quote from: Frederik on January 23, 2009, 17:15:30 PM
I have implemented the changes and the customer is now receiving a confirmation mail and no pending mail. That is a huge leap forward 8)
There is still some minor issues as I see it:
The confirmed mail the customer is receiving is just saying "status has changed". The customer isn't receiving the order details and the link to the order details as it was in the pending mail.
Also the text doesn't make sense as the confirmation mail is the first mail the customer is receiving. I take that it is an easy fix which I probably can do myself.
The shop is only receiving a pending mail and no confirmation mail. Personally I would much rather have the confirmed mail as a shop owner instead of the pending mail.
The VM page telling "the order is confirmed" before the payment is done, needs to be changed as it is saying: "a mail has been sent to...." I would change the overall message to something like: "a new payment window has been opened..." and so on and nothing about the order is confirmed which I find a bit confusing
I am using VM 1.1.3 and Joomla! 1.5.9
Very nice work Angek :)

thanks for the feedback. I've got some free time over the next couple of days so I'm going to try and sort out the confirmation email and text and post back.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: angek on January 28, 2009, 02:04:47 AM
Quote from: Frederik on January 26, 2009, 14:40:30 PM
I don't think I ever received a confirmation mail - just the pending mail and the status change mail.
I have spend hours to try and figure out where the code for the pending mail is produced and if it could be reused for a confirmation mail with no luck. Is there somebody that can lead me in the right direction? Does a documentation for the checkout procedure exist?
I too have never seen a confirmation email or at least not a confirmation email as I would have expected. The confirmation email only indicates that the order status has changed and nothing more. Ideally it should resemble the purchase order  but renamed to invoice or something similar.
What I've been able to figure out is as follows:
order is placed and the checkout process begins. We go through all the steps until we reach the final step where we click the "confirm order" button. This process adds the order to the database, sends the purchase order to the customer and shop owner then redirects to paypal for payment.
The payment is processed and the notify.php script is executed which handles the response POST info from paypal.
require_once ( CLASSPATH . 'ps_order.php' );
$ps_order= new ps_order;
$ps_order->order_status_update($d);
$mailsubject = "PayPal IPN txn on your site";
$mailbody = "Hello,\n\n";
$mailbody .= "a PayPal transaction for you has been made on your website!\n";
$mailbody .= "-----------------------------------------------------------\n";
$mailbody .= "Transaction ID: $txn_id\n";
$mailbody .= "Payer Email: $payer_email\n";
$mailbody .= "Order ID: $order_id\n";
$mailbody .= "Payment Status returned by PayPal: $payment_status\n";
$mailbody .= "Order Status Code: ".$d['order_status'];
vmMail($mosConfig_mailfrom, $mosConfig_fromname, $debug_email_address, $mailsubject, $mailbody );

In the notify.php script there's a call to order_status_update() function which is defined in the ps_order.php script. The order status should be updated to "Completed", stocklevels checked and updated if required and so forth.
Finally notify_customer() is called and an email is sent to the customer informing them that their order has been updated from "Pending" to "Completed".
If this logic is correct (please correct me if it's not) then we need
to do a couple of things to get this all working the way we want:
1. disable the email alert when the order is initially confirmed (final stage of the check out process).
2. modify the notify.php script so that it sends out a "final" confirmation email to the user and shop owner. (this is the pending email rehashed to remove all the "pending" phrases and changing "purchase order" to "invoice or something similar). or modify the checkout.result.php script (which is the return url as defined in the extra payment info section of the paypal configuration "return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),) to send the confirmed email (invoice) to the customer and shop owner.
The other thing I have found is that under test conditions the IPN stuff doesn't work (www.eliteweaver.co.uk/testing/ipntest.php no longer exists - I can't seem to get to it :( so order statuses are not being updated on successful test transactions.)
Am I right in my assumptions and the process flow? If so would the solution I have proposed work without affecting anything else?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: angek on January 28, 2009, 04:02:42 AM
I've started coding the changes I mentioned in my post above but I need help with something. If anyone has a live site that uses paypal as the payment method can they please verify that the order_status is automatically updated from "Pending" to "Confirmed" once a successful payment has been made and that 2 emails are sent one being the purchase order and the other the status changed confirmation so that I can get the conditional statements correct please.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: cinos on January 29, 2009, 15:27:16 PM
I have only tested my site on the paypal sandbox, but I can tell you that that is indeed what happens. I can't think of a reason why it would be any different for the live site. :)

Though the confirmation email is sent first and then the email regarding the status change is sent once notify.php is updated (payment successful).
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: angek on January 29, 2009, 20:37:56 PM
Thanks for the info. I should have finished coding up the changes by close of business today and will post a patch file. Given that I'm somewhat new to vm I may have missed something so all feedback would be greatly appreciated.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: angek on January 30, 2009, 00:22:22 AM
guys, here's a brief doc outlining the proposed patch that I'm creating. I'm in the process of testing the patch file and will post it here once I'm done.

[attachment deleted by admin]
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: tantan on January 30, 2009, 02:31:25 AM
Angek,

Many thanks, great job ...

Title: Re: Order confirmation email sent before PayPal payment processed
Post by: angek on January 30, 2009, 02:54:51 AM
dont thank me yet ;)
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on January 30, 2009, 04:00:48 AM
Brilliant stuff,

I always found it odd that this was never a properly implemented option, especially for instant payment methods.

I understand the pending order email's use for cheques/cod/po's etc but when you take someone's credit card details the email should only go out after the transaction has been completed.

I suppose to cover all edge cases, it would be good to send the invoice on confirmed and a different email on pending - so that a user knows the order has been placed and either - in the case of echeques they need to wait or in the case of an error, that it needs attention.

I look forward to trying this out myself.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: angek on January 30, 2009, 04:27:48 AM
OK guys, here's the alpha release of the patch.
Please be sure to back up the components/com_virtuemart and administrator/components/com_virtuemart directories before applying this patch.

Your feedback, suggestions etc are most welcome.

[attachment cleanup by admin]
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on February 01, 2009, 08:19:57 AM
All seems to be working nicely, but the customer is still getting the status changed email.

Any thoughts?

Thanks again for a great improvement to VM.

I'm going to look into putting this in place with PayPal Pro in the next couple of days, it will be the UK version, but will keep you posted.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: angek on February 02, 2009, 03:39:32 AM
cool,
I'll recheck the notification stuff.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: cinos on February 02, 2009, 16:12:08 PM
Just tried it out and I'm getting the same problem as Datatonic in that the status changed email is still sent (the one informing of the change from pending to confirmed).

Also the customer is not actually getting the invoice email. :(

Basically I (the seller) recieve the pending purchase order and the customer (when payment has been recieved) gets a status change email and a paypal payment confirmation email. No invoice.

Anyone else finding this?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: cinos on February 02, 2009, 16:36:49 PM
Just restored the back up and the purchase order is being sent to the customer again. Albeit at the old, bad time (pending status).

Another problem I noticed with the patch was that the option to surpress the email didn't appear to make a difference, regardless of whether it was turned off or on. Though this was most likely because the email was actually not sending in the first place. :)
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on February 03, 2009, 03:33:13 AM
Hi, there seems to be another problem.

The purchase order is being suppressed to the customer for all payment methods, rather than just PayPal.

I've decided to go down another route, using your idea as a starting point.

My aim is to have things run as follows:-


When link in Confirmed Status email is clicked, they are taken to a page that does similar to the current operations you have in Checkout.Result.php, whereby both Vendor and Customer are sent an invoice.

This for me covers all bases and does what I need.

Hope you get the status email and purchase order suppression sorted. 

Thanks again for all your work on a very useful mod.

Ro.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on February 04, 2009, 03:16:46 AM
Hi I have gone down another route and sucessfully implemented it.

In this method the customer receives the purchase order as normal (although this could be shut off)

They then receive the order status change email.

In the order status change email, if their order status is confirmed they are presented with a link to a new checkout.invoice.php page.

If their order status is anything other than confirmed, they are shown the original link.

If they are not logged in they are prompted to do so, and as Virtuemart seems to be refusing to re-direct at login for me, I have added a javascript backlink to the com_user page.

Then when they return to (or go straight to if already logged in) the checkout.index.php page, they are presented with some text stating that their invoice has been processed and sent.

This page calls a new class ps_send_invoice.php which sends out the Invoice Email to the customer.

It is a very long winded way of doing things and I'm sure I'll change it, it just seemed to be the best way of dealing with things, as I have PayPal, PayPalPro and Purchase Order as payment methods.  I also have purchase codes associated to orders that are only displayed in the confirmation email and order details once an order is confirmed.

If anyone would like the files, let me know.

Ro.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: brandonjp on February 06, 2009, 04:35:00 AM
Well done, Datatonic!!  Based on this thread...I think we'd all be interested, especially if it actually works.  You should post them on this thread.

Quote from: Datatonic on February 04, 2009, 03:16:46 AM
Hi I have gone down another route and sucessfully implemented it.

In this method the customer receives the purchase order as normal (although this could be shut off)

They then receive the order status change email.

In the order status change email, if their order status is confirmed they are presented with a link to a new checkout.invoice.php page.

If their order status is anything other than confirmed, they are shown the original link.

If they are not logged in they are prompted to do so, and as Virtuemart seems to be refusing to re-direct at login for me, I have added a javascript backlink to the com_user page.

Then when they return to (or go straight to if already logged in) the checkout.index.php page, they are presented with some text stating that their invoice has been processed and sent.

This page calls a new class ps_send_invoice.php which sends out the Invoice Email to the customer.

It is a very long winded way of doing things and I'm sure I'll change it, it just seemed to be the best way of dealing with things, as I have PayPal, PayPalPro and Purchase Order as payment methods.  I also have purchase codes associated to orders that are only displayed in the confirmation email and order details once an order is confirmed.

If anyone would like the files, let me know.

Ro.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on February 06, 2009, 12:53:38 PM
Shall do.

Have now changed it a little so that there is no clicking involved for the customer.

Have also changed notify customer so that differant messages are sent for differant statuses.

Will have it finished in a day or so then will post the code.

RO.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on February 07, 2009, 02:25:55 AM
Ok this is now finished and tested as working on my system.  Joomla 1.5.9 and Virtuemart 1.1.3.  I have stripped the files of all other mods I have made, so they are additions to the vanilla 1.1.3 files.

The files in the zip are as follows:-

/administrator/components/com_virtuemart/languages/common/english.php

Changes are to include the new status change methods and include the new invoice label.  If you have modified the default file in any way you will need to merge my changes into your version.  If you have a vanilla install you can simply overwrite it.

/administrator/components/com_virtuemart/classes/ps_order.php

Changes are changing the messages and if required URL's used in the order status changed emails.  Call added to new class and function to send invoice on order status changing to confirmed.

If you have modified the default file in any way you will need to merge my changes into your version.  If you have a vanilla install you can simply overwrite it.

/administrator/components/com_virtuemart/classes/ps_send_invoice.php

Brand new file (basically a cloned and edited ps_checkout.php but it does the job nicely.  Simply copy this into the classes folder.

/components/com_virtuemart/themes/default/templates/order_emails/invoice_email.tpl.php

Brand new file basically a cloned and confirmation_email.tpl.php but it does the job nicely.  Simply copy this into the order_emails folder or if you would like to edit the layout, please go ahead.

What this achieves is as follows:-

Purchase order emails are still sent out when order pending.
When order status changes to Confirmed order status email is sent out and invoice generation is triggered and the invoice email is sent out.

I am sure with some more work, you could disable the order status and or purchase orders but for my purposes I wanted them to stay.


[attachment cleanup by admin]
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MikeUK on February 07, 2009, 09:13:24 AM
Looks like you've been busy! :)

I presume the clone of ps_checkout is stripped down and put there to allow it to be called one further time after order status changes to confirmed (with the then unnecessary bits taken out)?

Nice solution.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on February 07, 2009, 14:11:45 PM
I told you things had been hectic!

Nope it is pretty much as is, as I was time pressed and just wanted it working! 

I also wanted a solution that was a minimal hack of core files.  Would be great if someone trimmed it down though.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on February 10, 2009, 04:13:32 AM
#####UPDATE#####

Due to sleepless nights and far too much coffee I've just noticed that I posted the wrong version on here.  The original zip had my version in it with a load of hacks.  This will break it for those without them.  So the new attachment has them without them and will work.  Really sorry!

###########
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: katiepants on February 10, 2009, 05:30:45 AM
Datatonic, you are a GENIUS! I love you!!!! This is EXACTLY the process I was looking for. Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you!!!!!!
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: sanjeewasam on March 10, 2009, 07:34:59 AM
Thanks all for the great work. I cannot see the final version posted by Datanoic with his post dated February 10, 2009, 04:13:32 am.
#####UPDATE#####

Due to sleepless nights and far too much coffee I've just noticed that I posted the wrong version on here.  The original zip had my version in it with a load of hacks.  This will break it for those without them.  So the new attachment has them without them and will work.  Really sorry!

###########
could u please direct me to the correct place
thank you!
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on March 10, 2009, 12:00:43 PM
Hi there, I updated the original post, with the new version.  So grab it from there.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: sanjeewasam on March 10, 2009, 15:01:27 PM
Thank Dataonic. I checked your solution with my live site and it works well. Thanks again. I also changed the order type descriptions within virtuemart so it is much clear to customers. for instance "pending"-> "Accepted subject to payment", "confirmed"-> "payment confirmed" and "shipped"-> "order shipped/electronically delivered".

This is a cosmetic change but I guess it gives more clarity to a third party.

Was wondering whether someone could tell me where in ps_order.php the actual order printing begins. if we could add a conditional statement to check whether order status is P (pending) and make the output for status red and bold "pending" it would be clearly visible to anyone. Then I guess this is as good as any solution.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: sanjeewasam on March 11, 2009, 05:21:11 AM
I managed to achieve what I wanted by making changes to /components/com_virtuemart/themes/default/templates/order_emails/invoice_email.tpl.php and order_email.tpl.php and /administrator/components/com_virtuemart/languages/common/english.php files. If anyone wants to know please let me know
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: lwheelr on March 12, 2009, 16:59:03 PM
Is there a way to suppress the initial Pending email for PayPal only?

Thanks,

Laura
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on March 13, 2009, 11:02:48 AM
Purchase order email or order status email?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: DisgruntledGoat on March 13, 2009, 13:38:56 PM
I've been looking for a similar solution, so thanks for the hack!

Question: will this (with some extra coding on my part) allow for sending a separate email to another address as an order? The site I am developing requires an order email sent to a depot for the actual product to be sent out. The email can be the same format as for the admin, but the depot address may be different (depending on the location they picked). If you have any tips (which files to hack etc) I'd really appreciate it!
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on March 13, 2009, 15:00:27 PM
I'm at Joomla Day UK this weekend, I'll have a look when I'm back home Monday.  I'll need this myself soon, so I'm sure I can expand it to encompass this.  Will let you know mid next week.

Cheers

Ro.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: lwheelr on March 13, 2009, 16:09:24 PM
The customer is receiving an email that is sent if the order is incomplete - I'm assuming that it is an order status email. My clients would like to suppress that email so that nothing is sent unless the payment is completed.

Laura
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: DisgruntledGoat on March 13, 2009, 17:55:57 PM
Yeah I've just uploaded the hack, and discovered that the emails are still being sent before the paypal payment is taken. I'll see if I can figure it out...
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on March 14, 2009, 02:04:43 AM
Yes they are pretty easy to supress - the call to the purchase order is in ps_checkout.php and the call to the pending order email is in ps_order.php.

Got my head firmly stuck in Joomla this weekend - will write up how to do it properly next week.

Ro.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: lwheelr on March 14, 2009, 04:51:52 AM
Would appreciate that - because while I understand the theory of coding, and I can find and edit code if I know what I'm looking for, I can't read it or write it to save my life! :)

Laura
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: demsey on March 16, 2009, 09:41:51 AM
Hi

Datatonic thanks for that solution.

I have a few questions.

At this time I am testing VM 1.1.3 and Joomla 1.5.9 Everything looks all right but I had a few small problems.

- When I am receiving email after order, my links to specific orders were wrong. Instead of full link with domain address my link started from index.php or /administrator/index.php....

I have no idea why. What I did is:

That two lines in ps_send_invoice.php line 1803-4:
$shopper_order_link = $sess->url( SECUREURL ."index.php?page=account.order_details&order_id=$order_id", true, false );
$vendor_order_link = $sess->url( SECUREURL ."index2.php?page=order.order_print&order_id=$order_id&pshop_mode=admin", true, false );


Changed:
$shopper_order_link = $sess->url( SECUREURL ."index.php?page=account.order_details&order_id=$order_id", true, false, true);
        $vendor_order_link = $sess->url( SECUREURL ."http://www.mydomain.com/administrator/index2.php?page=order.order_print&order_id=$order_id&pshop_mode=admin", true, false, true );


And now everything is working correctly. I am receiving email with correct links. My question is why I have to do this. You don't have that problem.

My second question is: After order registered user is receiving three emails:
- Order with Pending status
- Invoice with Confirmed status
- and info about changed status from Pending to Confirmed

but non-registered user is receiving only one email:
- Info about changed status from Pending to Confirmed

I would like to send same emails to any type of user.

And last question is: When I try refund some orders from PayPal in my system status has been changed to Cancelled. I prefer to call that Refund. Just tell me where is the class or function responsible for that.

I hope you can help me to resolve those small problems.

Demsey
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: lwheelr on April 12, 2009, 04:38:19 AM
Anyone want to take pity on a Desperate web tech from Wyoming?

I really need a clue on how to suppress the email notice that goes out before the order is complete.

I have no idea what I'm looking for, or in which file. I have four websites that need it, and no budget for a coder.

Any help deeply appreciated.

Laura
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: jaddi01 on May 20, 2009, 11:52:37 AM
Quote from: demsey on March 16, 2009, 09:41:51 AM
...
And now everything is working correctly. I am receiving email with correct links. My question is why I have to do this. You don't have that problem.

My second question is: After order registered user is receiving three emails:
- Order with Pending status
- Invoice with Confirmed status
- and info about changed status from Pending to Confirmed

but non-registered user is receiving only one email:
- Info about changed status from Pending to Confirmed

I would like to send same emails to any type of user

Demsey

I'd like to know how to stop the order status email from going out automatically.  I'm also getting the 3 mentioned above.  Any ideas?

Thanks

John
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: jaddi01 on May 22, 2009, 10:07:45 AM
Just to let you guys know, if you have issues where the subtotal is displaying inc VAT/TAX and the tax for shipping is not being added on the Invoice email (as was the case with me)

eg.
(http://www.usedsurveyingstuff.com/Purchase_order.jpg)
, use the following threads:

https://forum.virtuemart.net/index.php?topic=48981.0
http://forum.virtuemart.net/index.php?topic=46209.0

Basically edit the ps_send.invoice.php replacing the following code:
Replace this:

} else {
$sub_total += ($dboi->f("product_quantity") * $dboi->f("product_final_price"));
$shopper_message .= $CURRENCY_DISPLAY->getFullValue($dboi->f("product_item_price"), '', $db->f('order_currency'));
}

with

} else {
$sub_total += ($dboi->f("product_quantity") * $dboi->f("product_item_price"));
$shopper_message .= $CURRENCY_DISPLAY->getFullValue($dboi->f("product_item_price"), '', $db->f('order_currency'));
}


and...

$order_shipping = $db->f("order_shipping");
$order_shipping_tax = $db->f("order_shipping_tax");
$order_tax = $db->f("order_tax");

to this

$order_shipping = $db->f("order_shipping");
$order_tax = $db->f("order_tax") + $db->f("order_shipping_tax");


Hope this helps someone in the same position.

John
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on June 04, 2009, 23:03:53 PM
I found that there have been some discussions already about when to send the confirmation email to the buyer. This thread  invokes similar objectives:

http://forum.virtuemart.net/index.php?topic=24147.0

The solution in this thread works correctly but is in my opinion incomplete. A client who clicks on the "confirm order" button will instantly have his transaction saved, the articles "In Stock" amount   reduced his cart emptied and the confirmation email sent. Thanks to Datatonic the email isn't sent any more but a customer who hits the back button before finishing the payment will return to the site with an empty cart (reducing the stock in the shop)  and plenty of confusion ...

For those (as I am) who are only interested in the orders actually paid by the customer, the final checkout process (registering the transaction, reduce stock etc.) should only be triggered once the confirmation from paypal received. I noticed this bug report which has similar comments:

https://dev.virtuemart.net/cb/issue/2625

I analyzed how this could be implemented and would like some feedback from the Virtuemart team about feasibility.
New checkout process:

1)Configuration option in the admin "Payment Method Form" when "HTML-Form based (e.g. PayPal)" is selected :

=> "Generate Transaction on confirmation only"

2)If option 1) is selected the "confirm order" form is taken from the "Payment Extra Info" instead of generating the form with the
<input type="hidden" name="func" value="checkoutProcess" />.

The form is directly posted to https://www.paypal.com/cgibin/webscr

3)On confirmation by paypal (notify.php) the checkout process is triggered through the usual ps_checkout->process() function.

The change in core files should be miner. As I need this for my clients and possible other payment modules I will have to implement it. If other people (and the Virtuemart team) think this feature is worthwhile I would be happy to hear any suggestions/compatibility issues  in order to eventually have this incorporated to Virtuemart (instead of posting "hacks").

Cheers,

Larsen
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: alldigit on June 11, 2009, 20:43:30 PM
Well, believe it or not i read all 6 pages of this thread.  And thank you in the last post which linked to the developers posting where it appears the decision has been made to do nothing to address this.  I don't understand.  I have never seen another shopping cart behave this way.

Could a VM representative please post here your official stance on this topic so that we can make a decision and inform our clients if a solution will come from VM, private programmer or selecting another cart.  What a crazy use of time to have to read through 6 pages of post to find out that VM developers plan to do nothing.  At least one of the developers in the developers forum recognizes that there are Angry Users out there.  Thank you for your concern and recognizing that communication will help.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Datatonic on June 11, 2009, 21:23:02 PM
Larsen - I'm a bit clearer now and about to do some more joomla sites with ecommerce involved so might look at tackling this at some point.

Alldigit - that's the rub with Open Source.  If you send me a pm or post on here what you are looking to achieve, you never know, I or someone else might have a solution.

Ro.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: alldigit on June 11, 2009, 22:11:36 PM
Thank you datatonic, i've passsed the info on to my client for him to consider.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on June 13, 2009, 14:59:38 PM
As I still haven't received any answer from virtuemart team (I also pm the dev responsible) i'll go ahead and do as I think best. I'll have a solution ready in about 3 weeks (off for vacation tomorrow ;) ) and will be glad to share it here.

Datatonic - If you have any suggestions to the points of entries (I would like this "hack" to work for other HTML post based payement methods) just let me know. I'm guessing using the form pasted in the DB is the way to go ....
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: quantum_leap on June 18, 2009, 18:03:13 PM
Good luck, I am also waiting for a solution to that problem!
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: techmatters on June 21, 2009, 13:24:58 PM
A big thanks to Datatonic for your work so far on this issue.
Ladumeni, you have very clearly expressed the process that needs to happen. Both I and many other VM users will be waiting for your solution. Thank you for your generosity and willingness to share this with others.

We worked exclusively with oscommerce in the past and battled through this very same issue of "what" is handled "when" with Paypal's IPN, but oscommerce got this sorted out years ago (exactly as Ladumeni described). After "upgrading" our ecommerce offerings with VM, I am surprised to find these sorts of processes poorly thought out. The way the currency converter works is another similar problem (but not one for this discussion  ;) )

Thank you both again, for your professional approach to this problem. We ALL look forward to your solution.

Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Pjries on June 26, 2009, 11:03:01 AM
I'm also looking forward to a solution to this and very grateful for all of the work you're doing. Reading through the developers comments about this issue, it may be a misunderstanding on their part of how some merchants want to operate. 

Just because an order is placed, doesn't mean that a payment will be made, no matter how much integrity we may assume a shopper has. Lots of online carts are abandoned before payment and the way this cart works makes it even easier to do that, at least when using PayPal as the payment option.

It is, as others have said, confusing for shoppers who have completed their payments, to come back to their e-mail inbox to find that their order is "Pending".  For one of my clients, we just commented out the status in the "Purchase Order" which we have renamed Order Confirmation.  We could also add some explanation for why that e-mail has been sent, in the template. But it does make more sense, to have the option of sending the detailed order information *after* payment is confirmed by PayPal, rather than before.

It really is a shame that the developers don't agree, but it's gratifying that the community is able to respond in the way you all have. Many, many thanks to all of you for all of your efforts.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: jaddi01 on June 26, 2009, 16:34:50 PM
I can only agree!  If the dev's disagree it won't get done. Then again, I cannot understand their reservations at all.  It seems so logical to do it the way we are asking.  Funny how community driven projects are only community projects when it suits.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: aravot on June 26, 2009, 22:01:55 PM
Please write in tracker http://dev.virtuemart.net/cb/issue/2625 how this should work.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ralphonz on July 09, 2009, 11:53:37 AM
Wow, thats alot of reading....

Any solution yet for no email being sent until order is confirmed?

Also i would like to mention here that when selling downloads, that order status is remaining on 'Pending' even after payment with paypal is completed and the confirmed?  This means the status has to be changed manually for every order.

Looking forward to a solution soon - thanks for everyones work so far.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on July 15, 2009, 13:00:11 PM
Ok, so I went ahead an implemented a "patch" for modifiyng the checkout process as described earlier.

As this patch is a bit out of scope from the original thread we've added a dedicated page to our site: http://www.b-planet.com/VirtueMart/paypal-patch.html (http://www.b-planet.com/VirtueMart/paypal-patch.html)

Please use our forum for any additional information : http://forum.b-planet.com/viewforum.php?f=4 (http://forum.b-planet.com/viewforum.php?f=4)

I've tested it throughly on the sandbox system and it works very well for me. I don't have a production evironment handy right now but shouldn't make any diffrence.

Cheers

Larsen


Title: Re: Order confirmation email sent before PayPal payment processed
Post by: jaddi01 on July 15, 2009, 13:31:22 PM
Great stuff!  Looks good.  I'm presuming this patch will work with all Paypal related payment processors that use the virtuemat HTML (paypal or similar) option?  At least I hope so as I'm using my own SagePay module.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on July 15, 2009, 13:44:35 PM
The patch should work with any payement method, but the php code in the payement extra info needs modifications to work ....
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: wastedspace on July 16, 2009, 12:17:27 PM
I tried to download the patch today, but on the download screen it says 'Sorry, your download limit has been reached'(!). I haven't even downloaded it yet! Anyone else seeing this?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: wastedspace on July 17, 2009, 14:09:16 PM
Just checked the site again, and download link seems to be working now :)
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MoneyMagnets on July 23, 2009, 09:27:00 AM
Hi everyone,

I'm using Angek's patch for testing and I've got something a little strange that someone may be able to help me with.....

I had the test mode set to Yes and the new field set to Yes (to send invoice) and it worked with the invoice being sent visa email. However my testing set up was wrong since I wasn't getting confirmation from paypal.

So I set the test mode to No and still used the sandbox. The New field for the invoice is still set to Yes but this time for a new order instead of receiving the invoice the user received an email for order status change to pending and then when the payment was confirmed they received another order status change. They didn't receive an invoice at all.

Has anyone else got that patch working in a live environment?
If so how?
What have I missed since it was working fine in test mode?

Thanks for any help. I wouldn't have got this far with Virtuemart if it wasn't for the posters on this forum!

Regards,
Karen     
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: wastedspace on July 23, 2009, 11:07:40 AM
Hi MoneyMagnets,

Have you updated your IPN settings in your Paypal account? I had set my IPN Notification URL in Paypal to the notify_gen_transaction.php url, however...

I too haven't managed to get this patch working right. Everything seems to be working apart from the fact I still get the Purchase Order email before any payment has been made. I was under the impression that the PO email was going to be sent out AFTER payment confirmation...

If anyone has got this working in test mode & live, please let us know if you had to make any tweaks.

Many thanks!

Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MoneyMagnets on July 24, 2009, 06:52:47 AM
Hi WastedSpace,

Do I have to change the IPN for paypal sandbox? Every thing other the patch is working fine for the paypal sandbox. The issue happened when I switched the test mode to No, which I understand is what I am meant to do for sandbox testing....

This is new to me so I may have something wrong...

Regards,
Karen   

   
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MoneyMagnets on July 24, 2009, 07:49:21 AM
I set up an IPN on my sandbox account and it didn't make any difference....
That's assuming I'm doing it right  :)   
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on July 24, 2009, 20:57:52 PM
Hi MoneyMagnets/WastedSpace,

I'm not quite sure if you guys are talking about my patch as described here http://www.b-planet.com/VirtueMart/paypal-patch.html (http://www.b-planet.com/VirtueMart/paypal-patch.html) or a previous patch posted on this forum....

You should normaly always (production and sandbox) set "Test Mode" to "no". If you still get an Purchase Order email sent out before the payement then the file checkout.index.php wasn't correctly patched (you can check the source code on the last checkout page. It should contain a form with the paypal URL in it)...

You shoudn't need to change your IPN Notification URL in Paypal to notify_gen_transaction.php as this is sent with the form via a hidden field
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MoneyMagnets on July 25, 2009, 01:22:43 AM
Hi ladumeni ,

I did specify that I was using AngeK's patch.

I have since restored my files since I couldn't get that patch to work (and don't understand the coding enough to be able to change it myself although I did have a look).

Thanks for clarifying about the IPN.

I'm going to try your Bplanet patch later today  :)

Regards,
Karen   
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: wastedspace on July 28, 2009, 19:10:43 PM
Quote from: ladumeni on July 24, 2009, 20:57:52 PM
Hi MoneyMagnets/WastedSpace,

I'm not quite sure if you guys are talking about my patch as described here http://www.b-planet.com/VirtueMart/paypal-patch.html (http://www.b-planet.com/VirtueMart/paypal-patch.html) or a previous patch posted on this forum....

You should normaly always (production and sandbox) set "Test Mode" to "no". If you still get an Purchase Order email sent out before the payement then the file checkout.index.php wasn't correctly patched (you can check the source code on the last checkout page. It should contain a form with the paypal URL in it)...

You shoudn't need to change your IPN Notification URL in Paypal to notify_gen_transaction.php as this is sent with the form via a hidden field

Hi ladumeni,

Apologies to MoneyMagnets. I thought AngeK's patch was the b-planet one. I am indeed talking about the b-planet patch. I still cannot get it to work properly. The source code on the last page doesn't actually display the paypal url, nor the paypal form. Yet it goes to Paypal.

I have checked, and definitely uploaded the patched checkout.index.php page. Is there any way you can help me get it working?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on July 28, 2009, 19:38:07 PM
In the configuration of the payement module, have you set the "Generate Transaction on Confirmation" to "yes" ?

The first step is defenetily to get the form apear on the last checkout page....
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: wastedspace on July 28, 2009, 21:57:37 PM
Yes, I have now. And I see the Paypal form. When I submit an order through the sandbox, everything seems to work (ie. Paypal says it was a successful transaction), but when returning to the store, it says 'failure' - 'The payement of your order hasn't yet been confirmed by the payement gateway', etc. And also the order doesn't appear in the Orders list in Virtuemart. And no emails were sent to my customer email from VM.

There appears to be an entry in the temp table in the database however.

Any ideas? I presume it shouldn't matter if the customer is a registered user on the site or not?

Thanks :)
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on July 28, 2009, 23:59:37 PM
Hey wastedspace,

So the first step works, now it seems there are some problems with the notify_gen_transaction.php script. Questions:

a) Is this file on your server and is it accessible to be called by PayPal (to make sure call the file directly using a browser)?

b) For the IPN notification to work you need to set set up your Paypal sandbox correctly:
   
1. Enter into your sandbox business account
2.  Go to "my account" -> "profile" -> "Instant payment  notification" -> "Edit IPN settings" and enter your notification url (example: http://yoursite.com/administrator/component/com_virtuemart/notify_gen_transaction.php).  Finally check "Receive IPN messages (Enabled) ยป and save.

c) If your mail is set up correctly (joomla notifications) you should receive emails with status notifications (the emails have subject like "PayPal IPN XXXX"). Do you receive any if yes please post content?

d) Look at your php error log. There should be some entries if an error has been triggered through the notify script. Can you see any entries similar to "1. Finished Initialization of the notify.php script" ?

Cheers, larsen
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: wastedspace on July 29, 2009, 15:38:10 PM
Yes to all of the above, apart from c & d. Now I used to get Payapl IPN emails with the standard Paypal module. But not with this patched version.

I've looked in my error log, and there are a number of PHP notices (mostly about constants already being defined), but noticed one error that could be significant:

PHP Parse error:  syntax error, unexpected $end in mysitepath/administrator/components/com_virtuemart/notify_gen_transaction.php on line 572

I didn't however see any entries similar to "1. Finished Initialization of the notify.php script"...

Cheers,

Ali.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on July 29, 2009, 16:13:25 PM
Indeed that error is significant. Very strange as this file has only 567 lines. I just downloaded the patch from our site to make sure there was no corruption and everything works fine here. If you call directly
http://www.yoursite.com/administrator/components/com_virtuemart/notify_gen_transaction.php do you get that error displayed ?

Try to upload again the notify_gen_transaction.php file just to make sure there is no corruption ...

Larsen
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: wastedspace on July 29, 2009, 17:00:56 PM
Thanks Larsen,

I think that was it. A corrupted file. I re-uploaded the notify file, and now receiving the purchase order AFTER payment, and also an email notifying me of the status update to confirmed. AND the order is 'confirmed' in the order list in VM. Woohoo!

A couple of points though:

1. After clicking the 'return to merchant' button on Paypal, it takes me back to the site, but I see an error - 'Order not found , 42_960eda3802d57edd763077248714a !'. I presume it's trying to find the order in the temp table in the database? But I guess you delete the order entry upon a successful transaction? So should the code be looking for the order in the main orders table instead?

2. I'd prefer when you first get taken to Paypal, to list the multiple items in your basket. I already have code that does this for the normal Paypal module, but I'll have a go an integrating it into the 'payement_extra_info.php' code...

Excellent work though! And many thanks for your prompt help.

Now I've also got to get this working with Worldpay... Will it be fairly seamless?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on July 29, 2009, 18:01:35 PM
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
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ralphonz on August 04, 2009, 15:25:57 PM
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
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: blisscloset on August 04, 2009, 16:45:06 PM
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?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ralphonz on August 05, 2009, 16:54:54 PM
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
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on August 06, 2009, 00:06:30 AM
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


Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on August 06, 2009, 00:09:24 AM
@blisscloset: sorry but no plan on developping this in the near future as our client didn't need such a feature... 
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ralphonz on August 06, 2009, 15:55:23 PM
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
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on August 07, 2009, 20:27:11 PM
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 ....
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ralphonz on August 09, 2009, 15:35:50 PM
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.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ralphonz on August 09, 2009, 16:02:03 PM
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'?
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on August 09, 2009, 17:18:23 PM
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
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ralphonz on August 10, 2009, 12:20:51 PM
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

Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on August 10, 2009, 17:52:24 PM
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").
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ralphonz on August 11, 2009, 13:27:17 PM
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 :-(


Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on August 12, 2009, 16:52:48 PM
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 ....
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on August 12, 2009, 17:03:22 PM
Hey Ralphonz,

Lets continue this discussion in our forum as it is pretty offtopic here and probably specifique to your configuration:

http://forum.b-planet.com/viewtopic.php?f=4&t=7

Cheers

Larsen
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: cornevdh on August 27, 2009, 18:52:16 PM
Hi you guys!!!

What a nice topic!! And congrats to the guys who were able to hack the Paypal payment method.

BUT I NEED HELP.... PLEASE, PLEASE

I have the exact same problem! BUT.... I am not using Paypal, I am making use of Netcash, which is a South African company.

I really hope someone can help me out... I am making use of Joomla 1.5.11 and VirtueMart 1.1.3

Thank you in advance!!! :)
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: toolbox978 on September 07, 2009, 23:23:02 PM
This is a MAJOR problem.  We had several order confirmations come through without ever receiving payment for them, and the products were shipped to the customer before we realized the mistake.  It seems once an individual purchases an item, they are redirected to Paypal and they try to submit a payment.  Then they discover their credit card is not accepted for whatever reason, but the order still gets processed on our website as if payment did go through.

We need a fix to this problem quickly or we may have to find completely different software.   :(
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: MikeUK on September 07, 2009, 23:32:55 PM
I'm surprised you don't get 'cancelled' as an order status if the customer cancels the transaction. There is some discussion in another thread about problems some people have with not getting a status 'confirmed' with a successful transaction, but 'pending' instead. But in my experience it is unusual to ship before confirming payment has been made.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: mikiretter on September 19, 2009, 21:31:35 PM
Hello ladumeni,

I tried to install your patch and got to the last stage were I confirm the order and then for some reason the page gets stuck with a message: "Connection lost, retrying connection".

Have you got any idea as to what might have caused this?

Thanks  :)

Miki
www.musicatova.com
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: madela on September 30, 2009, 23:09:26 PM
Hi,

I'm also having the same problem "Connection lost, retrying connection" seems to be stuck in a loop. I'm using a multilanguage site. Also there is no text showing for the option Generate Transaction on Confirmation just the yes or no selection.

Would very much like to find the way to have it working properly.

Thank you


Madela
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on January 15, 2010, 19:33:58 PM
Hy everyone,

Just wanted to let you all know we have been through a couple of versions of this (http://www.b-planet.com/VirtueMart/paypal-patch.html) patch and had more then 850 downloads.

The patch work flawlessly and there is an active forum supporting it here:

http://forum.b-planet.com/ (http://forum.b-planet.com/)

Regards

Larsen
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: wrangler on January 25, 2010, 19:19:26 PM
Sorry, this patch didn't work for me either. I am ALSO stuck in the "connection lost retrying connection" thing after confirming the order, as well as many others as I read. I have downloaded the latest patch, have gone through the instructions in detail but to no avail.

I read on the b-planet forums that this may be caused by mod_rewrite due to SEF components installed. I have turned off sh404, turned off built-in Joomla SEF, turned off server mod_rewrite, still no luck.
Sorry, it doesn't work.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: ladumeni on January 29, 2010, 16:07:52 PM
Hello Wrangler,

Sorry to hear you weren't able to use the patch. Why don't you come over to the dedicated forum and post your problem there? I'll be pleased to help you out.

We use the patch on many of our clients sites in multilanguage mode(joomfish), with multiple currencies and with full URL rewriting enabled (mostly with sh404sef or standard joomla SEO) without any problems, so I'm confident we can also resolve your problem ...

Regards

Larsen
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: wrangler on January 29, 2010, 16:41:55 PM
Thanks Larsen

Just sent a message on to the other board.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: wrangler on January 29, 2010, 19:01:30 PM
Problem solved.
It was a thing about folder permissions, in fact my "Components" folder was world-writeable (777). Switching that to 755 solved my problem and I was redirected to paypal succesfully.
This is a great patch :)
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: jaddi01 on January 31, 2010, 09:02:14 AM
Just wish I could get this to work for SagePay that I'm using.  I posted on the other board but never received a reply.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: alpertheidiot on April 04, 2010, 03:31:08 AM
Jaddi,

http://forum.virtuemart.net/index.php?topic=58729.0
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: jaddi01 on April 04, 2010, 09:04:28 AM
Thanks for the link but that refers tointegrating SagePay Server as a payment method.  I already use "SagePay forms" for payment with a module a few of us put together over the forum here.  What I want is control over the emails that the user gets when placing and order.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: Max99 on May 23, 2010, 22:15:56 PM
Me too. We have always used Sage Pay VSP Form and wish to continue doing so.

Went a long way down this road before realising the confirmation email problem.
It certainly strikes me (along with many others it seems) as a very odd implementation of the confirmation email idea. At least is would be nice if it were configurable (and also emails editable).

Has anybody managed to convert this method (PayPal patch)for Sage Pay VSP Form, or would anyone be able to help in doing so?

Many thanks.
Title: Re: Order confirmation email sent before PayPal payment processed
Post by: aussieute on January 18, 2011, 03:44:04 AM
Is there an update on this for those of us who aren't PayPal users?

This is appearing to be a payment module issue not a VM issue as such

Each gateway needs it's own coding changes to ensure that cancelled orders are just that and no emails are sent to the site owner.