Page 1 of 1

Replacement for using CheckedOut event on multi page checkou

Posted: Tue Jun 02, 2009 3:59 pm
by jmestep
Mazhar, you and told us how to use the CheckedOut event of the one page checkout to get the order number after the order has been created.
I have some code I'm adapting to the multi page checkout and am unsure about where to put it on the PaymentPage scriplet. Is it possible to get the new order number on that page?

Re: Replacement for using CheckedOut event on multi page checkou

Posted: Wed Jun 03, 2009 8:12 am
by mazhar
Judy those method CheckingOut and CheckedOut are basically handlers for events exposed by our payment forms. You can put this support in ConLib/PaymentPage very easily. All you need is to add those two handlers definitions to code file and then register those methods to respective events exposed by all payment forms. So first add following two methods to your code file

Code: Select all

protected void CheckingOut(object sender, CheckingOutEventArgs e)
{
        
}

protected void CheckedOut(object sender, CheckedOutEventArgs e)
{

}
Now you need to hook above handlers with payment forms. In ConLib/PaymentPage all payments forms are blinded to page in BindPage() method. For sample I am going to register for above two events for credit card payments. You can do so for all payment forms by updating code. So locate following code block in BindPage() method

Code: Select all

phPaymentForms.Controls.Add(new ASP.CreditCardPaymentForm());
creditCardAdded = true;
and then update it as below

Code: Select all

ASP.CreditCardPaymentForm ccPaymentForm = new ASP.CreditCardPaymentForm();
                            
ccPaymentForm.CheckingOut += new CheckingOutEventHandler(CheckingOut);
ccPaymentForm.CheckingOut += new CheckedOutEventHandler(CheckedOut);

phPaymentForms.Controls.Add(ccPaymentForm);
creditCardAdded = true;

Hopefully it will help you.

Re: Replacement for using CheckedOut event on multi page checkou

Posted: Wed Jun 03, 2009 10:12 am
by jmestep
Oh, dear, this sounds like no fun. I've been working on it some this morning, then thought I would check the forum. All I need to do is pick up the new orderid and basket items from the payment page. I see that there is a checkoutResponse.OrderId on a Response.Redirect, but I haven't got the page event order figured out yet. Where is the best place to catch the OrderId?
I'm beginning to think it might be better to move the code to the Receipt page where I first had it and filter out any possible refreshes of the page that would run the routine to calculate my referral amount. I had it there first, then thought I should put it on the One page checkout because I needed to work with that. If I have to do something to each payment form, I think it might be better to move it back to the receipt page?

Re: Replacement for using CheckedOut event on multi page checkou

Posted: Wed Jun 03, 2009 10:21 am
by mazhar
Its up to you. If you put it on RecieptPage then you may need some code make sure that code executes only once. If you want it here on payment page then you will need to make above changes and also need to load and process order between those two line of code

Code: Select all

checkoutResponse = Token.Instance.User.Basket.Checkout(checkoutRequest);
                Response.Redirect( "Receipt.aspx?OrderNumber=" + checkoutResponse.OrderNumber.ToString() + "&OrderId=" + checkoutResponse.OrderId.ToString());
This is the case when order total is 0 so all stuff is free no payments at all.