Forums / Developer / Workflow before checkout

Workflow before checkout

Author Message

Tomislav Buljević

Thursday 30 June 2011 2:03:07 am

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

Tomislav Buljević

Friday 01 July 2011 3:35:43 am

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?

Tomislav Buljević

Friday 01 July 2011 5:12:11 am

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.

Nicolas Pastorino

Friday 01 July 2011 9:12:28 am

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 !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Tomislav Buljević

Friday 01 July 2011 10:42:55 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. :D

Tomislav Buljević

Sunday 03 July 2011 11:02:00 pm

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. :D

Nicolas Pastorino

Tuesday 05 July 2011 1: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. :D

"

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,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

scrieler _

Tuesday 05 July 2011 1: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?

scrieler _

Tuesday 05 July 2011 3:38:56 pm

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

Tomislav Buljević

Tuesday 05 July 2011 11:13:16 pm

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.