Forums

Using a form as a function

tshirley 25 Jul, 2017
Hello,

I have a number of forms that perform independent bespoke business processes with a payment embedded:

Step 1. Some business process
Step 2. Payment (API to the gateway supplier using CURL)
Step 3. More business process depending on the result

Up to now I have simply embedded the payment logic in each form and it works well. But this is becoming tedious and error-prone especially when changes occur. I want to find a way to call the gateway process as a function.

So what I want to do is something like:

Form A redirects to Form Xpay with some payment parameters plus returl=http://formA?event=return
Form B redirects to Form Xpay with some other payment parameters plus returl=http://formB?event=return

Form X runs (it has no html render, just code and events) and then redirects to the value received in returl.

Is there a way to do this? I realise that I could use an Event Switcher in Form Xpay, but this means Form Xpay is not a generic function since it must be edited to add new redirects when I introduce Forms C,D, ....

Ideal solution would be a redirect action that takes a variable url or a curly bracket.

Cheers

Tim
GreyHead 26 Jul, 2017
Hi Tim,

I'm not quite sure I understand what the problem is.

You can include a generic payment function/file into multiple forms and use the form data to set the specific values for that form. If the payment gateway has a PHP API then I'd probably add that to the site and include and call the API functions as needed.

You can add variable values to the CF ReDirect action if that helps. You can save data to the user session, redirect to another form or form event then recover the saved data.

And, yes, you can create a form that just redirects somewhere else.

Bob
tshirley 26 Jul, 2017
Hi Bob,

Thanks as always for the reply.

This is not really a problem, more of a "how to".

I figured out most of it, it is really the question of if it is possible to have a variable Redirect action, so I could pass a parameter into a form which would act as the url in a Redirect. The only way I can see at the moment is to use an Event Switcher but then I have to fix all possible redirects. not a serious problem.

Tim
GreyHead 26 Jul, 2017
HI Tim,

Sorry, I misunderstood a bit.

If you want to redirect in the same site then you can set a fixed domain in the ReDirect action and then change the query string parameters. If you need to change the domain that's possible with a Custom Code action to override the ReDirect action configuration. Does that help?

Bob
tshirley 26 Jul, 2017
Hi Bob,

Yes in all cases the redirect is back to another CF form in the same domain.

So yes I can pass the form name - which is the functionality I am after. I had not before realised that it is possible.

Thanks again.

Tim
This topic is locked and no more replies can be posted.