eZ Community » Forums » Developer » Workflow before checkout
expandshrink

Workflow before checkout

Workflow before checkout

Thursday 30 June 2011 11:03:07 am - 9 replies

Hello, everybody!

I have a major situation here. I'm developing a webshop with the possibility of credit card payment. It should be working like this:

-> User chooses a product

-> He/she gets redirected to a payment system

-> After the credit card payment, he gets redirected back, and reviews his/her order

Now, the first two parts work fine, no problem here. I have created a module which redirects the user to the payment system, and when the transaction is made, he/she is redirected back. The problem lies in closing the workflow, and displaying the order correctly.

Currently, the shop works with two gateways. The first one is a Cash On Delivery Gateway which works fine. The second is my credit card gateway which also works fine. Now, since I'm using the xrowecommerce extension for the Cash On Delivery method, and my own extension for the Credit Card method (xrowecommerce works out of the box, so to speak), I'm having trouble when it's time for checkout of the user. The user gets redirected to a success page of my module and then, from there, should be redirected to the checkout of the xrowecommerce. I figured out that I have to activate the order for the checkout to work (not to try to get an authorization for 3 attempts and then fail miserably), and empty the current basket. I did that, and it redirects me to the order view. But, it doesn't close the Before Checkout workflow which was set up, and it doesn't send an e-mail to the user, or display the correct type of payment! Maybe I'm missing a step here? Somehow I feel that the solution is staring me in the face and that it's a piece of cake, but I have absolutely no idea what to do.

So, please, if someone would be kind enough to lend a hand, that would be highly appreciated.

Details:

eZ Publish installation v.4.3

Extension xrowecommerce

Thank you for any type of valuable input,

Tomislav

Friday 01 July 2011 12:35:43 pm

OK, I have tried to solve my issue by myself, and I have successfully closed the workflow. But, now, when I click on the webshop link in the Administration, I get an unexpected error message. The code I used is:

$http = eZHTTPTool::instance();
$sig = $http->getVariable('sig'); 
$tid = $http->getVariable('tid'); 
$card = $http->getVariable('card');
 
if($tid) {
    $basket = eZBasket::currentBasket();
    $orderID = $basket->attribute('order_id');
    $order = eZOrder::fetch($orderID);
    
    $order->activate();
    $paymentObj = eZPaymentObject::fetchByOrderID($orderID);
    $workflowProcessID = $paymentObj->attribute('workflowprocess_id');
    $paymentObj->approve();
    $paymentObj->continueWorkflow($workflowProcessID);
    $http->redirect('xrowecommerce/checkout');
}

Any ideas?

Modified on Friday 01 July 2011 12:36:00 pm by Tomislav Buljević

Friday 01 July 2011 2:12:11 pm

After further investigation, it seems as though the variable $paymentObj inserts something into the database which is wrong. And then the Webshop tab in the administration doesn't work. Maybe it would help to fetch a xrowecommerce payment object and then approve that one? Maybe it doesn't need approving at all? After I restore the database, I'll have further info.

I'm restoring the backup of the state before as we speak, hope to come to a breakthrough.

Friday 01 July 2011 6:12:28 pm

Hi Tomislav !

I would advise to post your question in the xrowecommerce extension directly : http://projects.ez.no/xrowecommerce/forum/general

Cheers,
ps : i love your Confessions of a n00b series of posts, keep-up !

Friday 01 July 2011 7:42:55 pm

Thanks for your advice, Nicolas, but it seems that I am unable to login with my current ez.no password to projects.ez.no. So I guess I'm stuck with this forum. The provider has restored the backup, so I'll make my own backup now, and try, try again. If anybody has anything in mind in relation to my issue, feel free to reply to this thread!

PS. And it's nice to hear that you like my articles. Thanks. big-smile.gif Emoticon

Modified on Friday 01 July 2011 7:43:47 pm by Tomislav Buljević

Monday 04 July 2011 8:02:00 am

It seems that each time I post on this forum, it has to be something either so obscure nobody has heard about it, or I put in so much text that it becomes unclear to the average poster. Anywho, I almost always solve the issue by myself. This one I solved with the help of a friend.The problem wasn't in the database. It was in the code. You see, I use xrowecommerce for my webshop solution. And xrowecommerce has its own payment object. Now, I was using the eZ payment object which was more convenient for me because it already has a workflow process id as an attribute, and I can manipulate it then. But the webshop Administration was set up that only xrow payment objects are shown, and when it tries to show an eZ payment object, it gloriously crashes. So I implemented a small but important function into the xrowecommerce function collector, which reads my own payment object according to the payment method, and it works. No crashing, no errors, no issues, it just works. I'd just like to thank everybody who tried to help, even if they just glanced through this thread. big-smile.gif Emoticon

Modified on Monday 04 July 2011 8:02:20 am by Tomislav Buljević

Tuesday 05 July 2011 10:44:36 am

Thanks for your advice, Nicolas, but it seems that I am unable to login with my current ez.no password to projects.ez.no. So I guess I'm stuck with this forum. The provider has restored the backup, so I'll make my own backup now, and try, try again. If anybody has anything in mind in relation to my issue, feel free to reply to this thread!

PS. And it's nice to hear that you like my articles. Thanks. big-smile.gif Emoticon

Hi Tomislav, 

It is good to hear you solved your issue. In forums generally, people are not always presenting a ready-baked solution, but sometimes helping the initial poster with a bunch of questions stimulates the brain on other reflection tracks. This proved successful in your case.

Concerning logging-in on projects.ez.no, username and password are the same as on share.ez.no. There was a minor user sync issue in the past days, it might be fixed now, helping you participate to xrowecommerce's forum. Can you sign-in now ?

Cheers,

Tuesday 05 July 2011 10:46:14 pm

Hey Tomislav,

 

I got the same problem with my event...

I can avoid the loop in checkout.php and close the order with eZShopOperationCollection::activateOrder( $orderID ); but I can't approve the complete workflow. Any ideas?

Wednesday 06 July 2011 12:38:56 am

got it... I have to load the checkout Template in the paymentgateway, I had skipped this...

Wednesday 06 July 2011 8:13:16 am

Well, what I have done for the payment gateway is: I created my own module in which I send a filled out form to the payment service, and then I get some data from the payment service after the payment has gone through. After that, I inserted the code described in my previous post and then I just had to input my own function for the retrieval of the payment object in PHP for the Administration Interface. After that, it worked.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from