in reply to Re^2: Coding and Design Advice
in thread Coding and Design Advice

I had in mind the following logic:

1) user selects the event, enters their personal details etc, then clicks on submit

2) 2nd form appears, with a radio button group for payment type. User selects their payment method and enters a membership number if appropriate, then clicks submit.

3) Your script checks the value of the radio button group. If its paypal, it issues a http redirect to paypal, or displays a 'now being redirected to paypal' page then redirects to paypal, and sends the confirmation of booking emails. Otherwise, it sends the confirmation emails and displays a 'thank you' type page.

You could also look at opening a new window to redirect to paypal, and displaying the 'thank you' in the main window, although these days a lot of browsers will refuse a popup.

By 'do the paypal transaction outside the perl script' I take it you mean that you can't gather the users paypal account information in your own form and handle the paypal transaction yourself? I think you're right, the user has to interact with paypal themselves, although I don't know this for certain.

Using this process, you only need a single submit button, rather than a submit for two of the payment types, and a separate paypal button (as long as there's nothing else forcing you to create a separate button).

g0n, backpropagated monk

Replies are listed 'Best First'.
Re^4: Coding and Design Advice
by b310 (Scribe) on Apr 01, 2005 at 11:34 UTC
    Hi,

    I see what you're talking about. In your #3 step, how do I issue a http redirect to PayPal? I never did this before using a script so I'm not sure about the code. Otherwise, your idea would be perfect.

    Can you help me out with the redirect code?

    Thank you for your help and time.
      The HTTP redirect using CGI is quite straightforward:

      use CGI; my $cgi = new CGI; print $cgi->redirect('http://thisistheurltoredirectto.com');

      You will need to do your redirect conditionally upon the content of $cgi->param('paymenttyperadiobutton') and remember that the redirect has to be the first header - don't issue a standard http header beforehand.

      g0n, backpropagated monk
        Hi,

        Yes, it certainly appears straightforward. I also understand that the redirect will be based on the result of the button that is selected.

        As for placing the redirect as the first header, do I place it before my conditional statement or after?

        I'm not sure I follow "has to be the first header".

        Thanks.
Re^4: Coding and Design Advice
by Anonymous Monk on Apr 01, 2005 at 11:38 UTC
    Hi,

    I see what you're talking about. In your #3 step, how do I issue a http redirect to PayPal? I never did this before using a script so I'm not sure about the code. Otherwise, your idea would be perfect.

    Can you help me out with the redirect code?

    Thank you for your help and time.
Re^4: Coding and Design Advice
by Anonymous Monk on Apr 01, 2005 at 11:40 UTC
    Hi,

    I see where your going with this. I didn't think you could redirect within a script. I never did this before. In your step 3, how do I issue a http redirect to PayPal? What would the code look like?

    Thanks.