News:

Looking for documentation? Take a look on our wiki

Main Menu

PayPal always sets the order status to "Pending"

Started by zanardi, May 04, 2014, 16:26:52 PM

Previous topic - Next topic

zanardi

I have searched for a long time in the forum but I can't see this issue reported. So my first question is, am I the only one who has it?

Steps to reproduce:
* fresh install of Joomla 2.5.19 and VirtueMart 2.6.0
* create a new "VMpayment - PayPal" payment method called "PayPal"
* in this payment method configuration, set whatever status different from "Pending" in "Order Status" => "Pending transactions"
* the order will be saved in "Pending" status anyway

I will try to debug the payment plugin, but if anyone has additional information I will appreciate it.

Thank you.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

zanardi

#1
The PayPal plugin is a bit complicated but it seems to me that for "Standard" PayPal product (which is the one I'm using) the custom order status is never take into account. So I have changed the plugin and added the check for custom status.

At line 411 I have added three lines:


$modelOrder = VmModel::getModel('orders');
$order['order_status'] = $this->_currentMethod->status_pending;
$modelOrder->updateStatusForOneOrder ($order['details']['BT']->virtuemart_order_id, $order, TRUE);


After this change it works as expected.

Please note that I haven't tested it yet on production sites, only on my local test site.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

alatak

Hello Francesco,

Quote* in this payment method configuration, set whatever status different from "Pending" in "Order Status" => "Pending transactions"
* the order will be saved in "Pending" status anyway
This is correct.

Please have a look here: http://docs.virtuemart.net/manual/39-paypal/117-paypal-standard.html
QuoteORDER STATUS

PENDING TRANSACTIONS

By default, Pending transactions are set to Confirmed by shopper.

The order in VirtueMart is set to this status, when the order has been received by PayPal, but the payment has not yet been processed.

Some examples of reasons of Pending transactions:


  • Your payment action is set to Authorize and capture, the payment is then in a Pending state until the merchant captures.
    A PayPal Direct Payment transaction can go into a transitional pending state if the transaction is funded by an eCheque.

When an order is created, it is set "Pending status" (P). This status is not configurable. It is  core status.
THe shopper is redirected to Paypal, and the website receives an IPN from Paypal.
The status of the IPN can be:
- pending
- completed
The plugin will set the order status with the ones set in the plugin configuration.
this is done in the processIPN function.


zanardi

Hello!

Thanks for the link. But there is still a problem: the order confirmation email is not sent, even if I add "Pending" to the list of status which should send the confirmation email.
I guess that's because, if the order status is never changed, the relevant hook is never fired and so the email is never sent.
So, if it really should work as you mentioned, we still need to change the plugin code and add this instead:


$modelOrder = VmModel::getModel('orders');
$order['order_status'] = "P";
$modelOrder->updateStatusForOneOrder ($order['details']['BT']->virtuemart_order_id, $order, TRUE);


Do you agree?
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

alatak

Hello

I know there are a lot of discussion about:"should VM2 send emails when an order is created" like it was done in VM1.
Most of the people are happy that it does not anylonger.

zanardi

You know I am *perfectly* aware of all the problems in maintaining a project like VirtueMart so when I post something I try to be very precise.

I don't want to discuss default behaviours. I'm talking about "bugs" as in "VirtueMart does not do what it's expected to do".
In Configuration -> Checkout I have two fields called "Default Order Status to send email to shopper" and "Default Order Status to send email to vendor".
I add "Pending" to this list. PayPal orders are set to "Pending" but the mail is not sent. This only happens for PayPal when using the "Standard" PayPal product.

This is a bug, period. I understand it may be a low priority bug because most people are happy this way, but the bug is there.

I hoped to produce a fix myself, but first we must agree that a bug exists :-)
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

AH

Zanardi

I hope this clarifies things or, I might be completely misunderstanding your needs.  Well here goes....

This does not appear to be a bug, but is a new way set of features.

VM2 Paypal does not set whatever you have chosen to be your "pending status" in the plugin unless the transaction is Pending with Paypal (Valerie has tried to point you to this being very different from the old VM1 pending state, Pending now means Pending with paypal - not pending with the store) and such a status is received via IPN

When an order has been confirmed but nothing has been received from PayPal the status "Confirmed by shopper" is set ("order_status_code"  'U')

If you want to send an order confirmation when the order has been accepted by the customer then just configure this as one of the statuses in the admin/checkout  "Default Order Status to send email to shopper"

That way they will get an email when they have confirmed their order.



Regards
A

Joomla 3.10.11
php 8.0

alatak

Hello Francesco
QuoteYou know I am *perfectly* aware of all the problems in maintaining a project like VirtueMart so when I post something I try to be very precise.
Yes, i am completely aware of that. Francesco, i know you, and i also know everything you have done for VM, and have a great respect for your work.

QuoteI'm talking about "bugs" as in "VirtueMart does not do what it's expected to do".
In Configuration -> Checkout I have two fields called "Default Order Status to send email to shopper" and "Default Order Status to send email to vendor".
I add "Pending" to this list. PayPal orders are set to "Pending" but the mail is not sent.
I agree with you on that point: the "Pending" order status should not be in the list of the configurable order status in the VirtueMart configuration, because it does not send an email in that case.
We left it for backward compatibility reasons: some shops are using this status in their payment order status configuration, instead of using "Confirmed by shopper (U)".

QuoteThis only happens for PayPal when using the "Standard" PayPal product.
The problem is the same for all payment plugins when shoppers are redirected to the payment form.

I talked with Max about this issue yesterday. As i mentioned above, we cannot remove the order status just like that from the list. We decided to do something for the VM3 version which is actually under testing. We have 2 possibilities:
(1) to remove the pending status from the order status list in both the VM config, and the payment config.
or
(2) we add a new parameter in the payment configuration "send email on order created"=> and the code that you gave will send the email:
$modelOrder = VmModel::getModel('orders');
$order['order_status'] = "P";
$modelOrder->updateStatusForOneOrder ($order['details']['BT']->virtuemart_order_id, $order, TRUE);


QuoteVM2 Paypal does not set whatever you have chosen to be your "pending status" in the plugin unless the transaction is Pending with Paypal (Valerie has tried to point you to this being very different from the old VM1 pending state, Pending now means Pending with paypal - not pending with the store) and such a status is received via IPN
Exactly, there is also a confusion between:
- P= pending= the order has been created,
- the order status when a transaction is in pending status => that is why we have created this new orders status "Confirmed by shopper"

AH

If you are coming from  VM1 then at first the flow and wording of the order status is confusing, but Francesco has way too much experience to get confused!

QuoteI talked with Max about this issue yesterday. As i mentioned above, we cannot remove the order status just like that from the list. We decided to do something for the VM3 version which is actually under testing. We have 2 possibilities:
(1) to remove the pending status from the order status list in both the VM config, and the payment config.
or
(2) we add a new parameter in the payment configuration "send email on order created"=> and the code that you gave will send the email:

VM2 is already functionally delivering what is required even for Francesco?

My thoughts on the options above:-

Quote
(1) to remove the pending status from the order status list in both the VM config, and the payment config.

1) NOT if you want to send a mail should the order status be set to Pending (Maybe this needs a language variable change to become "PayPal transaction Pending")

If I set the order status to send a mail on pending are you saying that this does not work when IPN returns pending, Or if I manually set pending (not that anyone should/would)??

Quote
(2) we add a new parameter in the payment configuration "send email on order created"=> and the code that you gave will send the email:

2) This is already achievable with no code change using the status U as one of the email notification selections why is another parameter required

Maybe it is just a case of showing the flow in a flow diagram??

Regards
A

Joomla 3.10.11
php 8.0

zanardi

@hutson @alatak thank you both for your explanation. Yes, I understand the difference between VM1 and VM2 and now I understand a bit more why it's been coded that way. But my issue still stands.

In short: as a shop owner, I want to receive a mail every time someone click on "Confirm order", no matter what. That's something many shop owners need because they will contact customers who did not complete the payment and try to convince them to complete it.

Regarding the solution, let's keep it as simple as possible: whatever you call it, this is just another order status, so I would treat this as such, without adding more complexity.

In other words: from the moment the user clicks "Confirm order" and before he/she does anything on PayPal, the order *exists* and has an *order status*. What's the problem in a) making that configurable in the plugin as another parameter and b) making that compatible with the "Default order to send mail"? It's not a great change, as my code shows. Let me know if we can proceed that way and I will be happy to provide the plugin with the updated code.

P.S. on a side note, if I have occasional fixes / contributions that I want to submit for evaluation, shall I post them here on the forum or is there a better place?

P.S. 2 I appreciate your hard work
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

AH

Zanardi

QuoteIn short: as a shop owner, I want to receive a mail every time someone click on "Confirm order", no matter what. That's something many shop owners need because they will contact customers who did not complete the payment and try to convince them to complete it.

Agreed, we often chase our customers so we dont lose out on sales.

This is achieved without additional coding or additional parameters:-

Configure "Confirmed by shopper"  as one of the statuses in the admin/checkout  that trigers an email communication  "Default Order Status to send email to shopper and or Vendor"

IAm I missing something here Francesco, your additional code provides no additional functional enhancements?
And it will works as per your requirements.
Regards
A

Joomla 3.10.11
php 8.0

alatak

Hello

QuoteQuote
(1) to remove the pending status from the order status list in both the VM config, and the payment config.

1) NOT if you want to send a mail should the order status be set to Pending (Maybe this needs a language variable change to become "PayPal transaction Pending")

in this case "Pending= order created", and not "transaction in pending status".

QuoteQuote
(2) we add a new parameter in the payment configuration "send email on order created"=> and the code that you gave will send the email:

2) This is already achievable with no code change using the status U as one of the email notification selections why is another parameter required
No.
The order changes to status U if there is a paypal notification.
Francesco wants that an email is received when an order is created, the shopper goes to the payment form, and does not pay. In that case, no IPN is sent, and no eamil is sent.

AH

Yep Francesco, I take it all back.

Alatak, you use Pending (P) for 2 completely different order states. Not a great feature!! Just tested and LMAO

Quotein this case "Pending= order created", and not "transaction in pending status".

And there I was thinking it made sense and would set "confirmed by shopper" silly me!

So the current flow makes little sense especially as Pending can mean - 1 of 2 things regardless of whether I want to trigger an email.

1) Pending - you did not do anything at paypal or paypal connection failed
2) Paypal set a Pending txn status and VM set P (as per configuration in plugin default)

So after much time wasting I have to agree with Francesco :-) that this is odd and you should not set a "P" Pending status code.

Confirmed by shopper means just that ("U") the shopper wanted to confirm the order regardless of what happens to the payment process, If I had the choice I would use this as the status code in Francesco's fix.









Regards
A

Joomla 3.10.11
php 8.0

alatak

hello
Quote1) Pending - you did not do anything at paypal or paypal connection failed
2) Paypal set a Pending txn status and VM set P (as per configuration in plugin default)

So after much time wasting I have to agree with Francesco :-) that this is odd and you should not set a "P" Pending status code.
this is exactly what i said. And we just kept it for backward compatibility reasons.
But in VM3, i can change it, and remove the P status from the order list so that it is only used for "order create"

zanardi

@hutson :-)

@alatak yes, you may remove the "Pending" name from the core order status list, but I would still suggest to create an additional parameter in the "Order status" section of PayPal method configuration:

Order Placed = The order status to which orders are set immediately after they have been placed and before PayPal send any type of notification.

So the user can configure that as well, and decide if they want a mail or not. I will try to create, test and share a modified version of the plugin.

--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter