Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Commerce
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
12 Jul 2011 at 14:36 UTC
Updated:
14 Oct 2013 at 17:07 UTC
Hello,
A customer can easily leave the paiement confirmation page (for example Paypal) without returning to the Drupal Commerce website (it is frequent).
In this case, the checkout process isn't completed, so the order status isn't updated, the order isn't associated to a user account or the corresponding new user account is not created... etc... So it's an orphan order in your database and all your custom rules (like confirmation e-mails) are useless.
That's why I think it is very important to allow Drupal Commerce to complete the order after a new "Success" payment is created for this order by an incoming IPN .
Is there a way to create this behavior ?
What do you think about it ?
Thank you
Comments
Comment #1
rszrama commentedHmm, good point. I'll have to think about it - there isn't an easy answer off the top of my head, and I'll have to decide if it should happen in core or in the payment method module.
Comment #2
gagoo commentedThanks for this answer,
I don't know well the Drupal Commerce coding architecture but I think it would be a good way that the core provides a function to complete the checkout process that others payments method modules, can easily call when they receive an IPN (or other type of paypent confirmation).
So if they call this function after receiving an IPN, the core confirmation page is just a static one, and if they don't call this function, loading this core confirmation page completes the checkout process.
Moreover, I think that changing this behavior you should take care of this issue : http://drupal.org/node/1127198
Keep us informed about it :)
Thx
Comment #3
tahiticlic commentedSubscribe.
Maybe calling directly this commerce_checkout/module function would do the trick :
Comment #4
recidive commentedRyan and me talked about this in IRC, and we've inclined the discussion to doing this as a hook_cron() implementation. To be more specific, this cron would query the database like this:
SELECT co.order_id FROM commerce_order co INNER JOIN commerce_payment_transaction cpt ON co.order_id = cpt.order_id WHERE co.status = 'checkout_payment' AND cpt.amount > 0 AND co.changed < NOW() - 3600;And would then move "Checkout: payment" transations to "Checkout: complete", by calling commerce_checkout_complete().
This would make the user account for anonymous purchases up and running and also trigger the invoice email in one hour if an IPN haven't arrived yet by that time (assuming you also put a call to commerce_checkout_complete() in your payment module which I don't recommend since you make your module dependent on checkout).
For my case this wouldn't suffice as there are cases when customers abandon the payment intentionally, and start a new purchase just after it, like when there's no "Cancel" button and user choose to use another payment method on the last minute.
I come to conclusion that all I needed was a "Complete checkout" operation next to to "edit" on order listings, which may not be a very bad idea.
Also, Ryan said the bellow as a quick and dirty fix for my immediate needs:
It sounds like a "Complete checkout" rule action is not a bad idea at all, I see this being used even with VBO for completing multiple checkouts when this is all you need to do.
Now that I think more about it I think the rule approach is the cleanest (not to say best) way to do that. You have the chance to review and act according to your judgement. And also this wouldn't create nested dependencies between modules.
Comment #5
gagoo commentedI think that the new rule action approach is a good way to solve this issue too. A better one that a hook_cron implementation because, moreover, not everybody has access to the cron tabs configuration of him hoster. So the delay to call cron.php could be random.
Thanks for your brainstorming :)
Comment #6
rszrama commentedWell, don't forget that D7 has a version of the D6 module "Poor man's cron" baked in, which ensures that cron will be called whether the site owner has access to cron tabs configuration or not. Most hosts if they don't allow direct access will have some sort of web interface to this.
The main problem I see w/ a Rules approach is that there isn't really a good event for an order to know when to "complete the checkout" process. We can't do it as soon as a payment notification is received w/ the current architecture of the redirected payment checkout pane, because it depends on the order status being Checkout: Payment when a customer returns from the payment gateway. So, we can do one of two things:
Comment #7
gagoo commentedThanks rszrama,
About cron triggered by the poormanscron module (in D7 core), if I don't make a mistake, the cron task is triggered at max 1 time every X hour(s) on a page request. So for webmasters who don't have acces by anyway to the cron tab, the cron timing depends in fact on the website affluance. If I set the cron to be triggered every hour and my website has no visitor for 3 hours or more, my cron will be launched, 3 hours later or more. So this potential random long time to trigger the cron, and also to complete the checkout process can be very harmful. The customer have too much hours to wonder if its order have been saved or not before he receives any e-mail confirmation. So the customer will phone to me and I don't want too much call !! :p
Concerning the Rule approach, I wonder if one of these existing events could be a good trigger for completing the checkout process : When an order is first paid in full ; After saving a new commerce payment transaction.
I tried to send an tokenized html e-mail triggered on the "After saving a new commerce payment transaction" (a payment is automatically created on incoming IPN) and I noticed one problem. It seems like the data selector for this event don't know what order the payment is refering to. So we can't use order related tokens in the e-mail body, but more important we can't compare the order balance in the conditions.
I think that if the data selector for this event could know what is the order that the payment is refering to, we could associate to it a new "Complete the checkout process" action if the order balance is equal to zero. And moreover, we could create some custom rules to manage the checkout process with multi/partial payments.
For those how use a payment gateway that don't provides IPN (I don't know if it exists) we can switch to a rule that complete the checkout process after returning back from the payment gateway website to our website.
What do you think about this approach ?
Thank you
Comment #8
recidive commentedYes, I agree with @rszrama on cron. There are even free cron services you can use to setup a cron for you website.
The rule action would allow us to implement rules for when changing status of order from "Checkout: payment" to "Checkout: pending" or any later status, for example, to trigger the action. This will not be automated, but would allow us to send user information and order email to user "manually".
@rszrama: I don't understand your option #2 above, can you explain?
I think it's safe to assume an user completed the payment if a. order status = "Checkout: payment" and b. payment status is beetween 'pending' and 'success', but there are not such status in between. I.e. in my case I have two orders for the same customer, one he has abandoned the payment, thus I received a IPN = 'initiated' and then the payment was set to 'pending', and other he has completed the payment and I received the IPN = 'waiting review', and then the payment was set to 'pending' too.
Comment #9
Jason Dean commented+ subscribing
Comment #10
rszrama commentedJust a quick update - I'm actually still undecided on this issue. I want to fix it tomorrow in time for our "1.0 release BoF", but I keep going back and forth as to when to actually "complete" the checkout process. It does seem that an incoming payment notification should be able to do this, in which case we need the return URL from the payment module to still work properly... I'm just still not sure if this is optimal at this point or if we should go with the cron hook until (or if) we update the checkout router to redirect based on the order status...
Comment #11
rszrama commentedHmm, I just realized that we need to fix a longstanding issue pertaining to making checkout page access control extensible. That puts this a little out of scope for what I can do with the 1.0, but I'm planning a 1.1 to come quickly after the 1.0. I'll dig up that issue and see what I can do about allowing the Payment module to hook into there to grant access to the payment URL when you return from the gateway.
Comment #12
damien tournoud commentedSee patch dfe1d4d in the sprint repository.
Comment #13
damien tournoud commentedNew patch 6cfabe0.
Comment #14
rszrama commentedI've committed the patch from #13 and a couple follow-ups providing a better API to support moving some code out of the payment redirection checkout pane.
Comment #15
damien tournoud commentedA few follow-up later, we added two API functions:
commerce_payment_redirect_pane_previous_page()andcommerce_payment_redirect_pane_next_page()that the redirected payment methods are responsible to call when receiving either a successful or a failure notification.Comment #16
damien tournoud commentedAnd done.
Comment #18
bakulaw commentedIm new to drupal commerce .. how can I allow data users to download my files upon payment to paypal?
ThankYou
Comment #19
rszrama commentedSince you're new, I should let you know that you shouldn't go changing titles on old closed issues. Additionally, you want the http://drupal.org/project/commerce_file module I assume.
Comment #20
bakulaw commentedIm sorry for that, but thank you very much for this http://drupal.org/project/commerce_file.
Comment #21
drugan commentedHope it will be useful for you to review this post:
Add "Checkout complete page is viewed" event