Post and redirect to URL

eelcodejong 22 Jul, 2013
Hi all,

I am very sorry if this problem is already answered but I haven't found any posts about this problem so I thought I'd give it a go🙂

For an iDeal module (kinda like paypall) I need to post data from a form to a URL. Since I also want the form to be validated and I need to calculate a hash code I want to use cURL for this. But I am not sure if this is even possible.

I have tried the standard cURL and cURL[GH] and when I debug get the following response:
[quote]cURL [GH]
cURL OK : the cURL function was found on this server.
cURL Target URL: https://testcheckout.buckaroo.nl/html/
Names + values (urldecoded)
Brq_amount : 2.50
Brq_culture : nl-NL
Brq_currency : EUR
Brq_description : Donatie
Brq_invoicenumber : 51ed2da50a23d
Brq_payment_method : IDEAL
Brq_service_ideal_action : pay
Brq_service_ideal_issuer : ABNANL2A
Brq_signature : 4f4997696f8d7517945481fba3bf6a8d
Brq_websitekey : M7GyStRMWZ
cURL Values: Brq_amount=2.50&Brq_culture=nl-NL&Brq_currency=EUR&Brq_description=Donatie&Brq_invoicenumber=51ed2da50a23d&Brq_payment_method=IDEAL&Brq_service_ideal_action=pay&Brq_service_ideal_issuer=ABNANL2A&Brq_signature=4f4997696f8d7517945481fba3bf6a8d&Brq_websitekey=M7GyStRMWZ
cURL Options: Array ( [13] => 60 [19913] => true [47] => true [10016] => 'https://testcheckout.buckaroo.nl/html/' )
cURL:Resource id #110
cURL info: Array ( [url] => [url=https://testcheckout.buckaroo.nl/html/]https://testcheckout.buckaroo.nl/html/[/url] [content_type] => text/html; charset=utf-8 [http_code] => 200 [header_size] => 278 [request_size] => 119 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 1.077556 [namelookup_time] => 0.013078 [connect_time] => 0.016185 [pretransfer_time] => 0.030695 [size_upload] => 0 [size_download] => 2488 [speed_download] => 2308 [speed_upload] => 0 [download_content_length] => 2488 [upload_content_length] => 0 [starttransfer_time] => 1.077523 [redirect_time] => 0 [certinfo] => Array ( ) )[/quote]

Can anybody tell me what am I doing wrong with this? I have been working on this for a couple of days now and can't seem to figure it out. Also I am a total newbie on cURL so that makes it even more confusing😶

Hope my question is clear and someone has the answer.

Kind regards,

Eelco
GreyHead 22 Jul, 2013
Hi Eelco,

I don't see any errors there. Are you getting any response from the payment gateway?

For iDeal you have to set up a second 'hidden' action that will handle the confirmation hand-shake separately from the user transaction.

Have you looked at my Mollie action ? You might find it easier to modify that instead of starting from scratch?

Bob
eelcodejong 23 Jul, 2013
Hi Bob,

Thanks for your reply. I get an error message from Buckaroo itself stating it could not process the received request. But the data I send via the HTML gateway should be valid.

I have asked Buckaroo the same question and they say that cURL is not the correct solution because I need to build up a form on my webpage and then send the customer to their URL with a POST action. If I want to use cURL I need to redirect the client myself to their site. I guess that is the hidden action you are talking about?

Any idea how I can do that or is this also something I can do with CFv4 Mollie [GH] action? If so I'll give it a go, though Ill have to set up a paypall account first 🙂

Thanks,

Eelco
GreyHead 23 Jul, 2013
Hi Eelco,

Caution: I know nothing about Buckaroo!

The Mollie service works, at least partly, in the way you describe; what it does is to save the transaction data, transfer the user to a second form that then submits with POST to Mollie and sends the user there to confirm the transaction. While the user is at Mollie they send an 'invisible' hand-shake transaction back to your site to confirm that the details are correct. Then they confirm the payment and send the user back again.

You can do a POST with the user in a couple of ways. One is to process the form in ChronoForms and then use a 'confirmation' form at the end of the On Submit process where you show the user the details and get them to click a 'Confirm' button that is actually submitting the form to Buckaroo. You can also use an 'auto-submitting' form with JavaScript to skip the user click step. More about those in this (paid ) document.

Bob
eelcodejong 25 Jul, 2013
Hi Bob,

I made a quick fix by creating an HTML form and a seperate PHP script with cURL and a header function to redirect the user to the received URL from Buckaroo. This because the client wants to use this donation module fast. And its working now though without validation, mail and a seperate database.

I am gonna get the documentation and Mollie service and check if I can adapt that. My goal is still to get this donation module done with chronoforms due to all the extra's like inserting data in a database and validation.

If I got more questions I know where to find you :wink:

Thanks for the support so far!

Eelco
eelcodejong 30 Jul, 2013
Back with another question...

After submit with Chronoforms v4 I get this response in cURL info:
cURL info: Array ( [url] => https://www.abnamro.nl/nl/ideal/identification.do?randomizedstring=6493971441&trxid=1150000245272208 [content_type] => text/html; charset=ISO-8859-1 [http_code] => 200 [header_size] => 1545 [request_size] => 652 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 2 [total_time] => 2.29007 [namelookup_time] => 2.7E-5 [connect_time] => 0.002857 [pretransfer_time] => 0.0099 [size_upload] => 0 [size_download] => 14642 [speed_download] => 6393 [speed_upload] => 0 [download_content_length] => 221 [upload_content_length] => 0 [starttransfer_time] => 0.158849 [redirect_time] => 2.128839 [certinfo] => Array ( ) )


Now I want to redirect the user to the URL mentioned in the Array
[url] => https://www.abnamro.nl/nl/ideal/identification.do?randomizedstring=6493971441&trxid=1150000245272208


In my current php script I do that by saving the URL to a string and then I use header to redirect the user.
$urlEndpoint = curl_getinfo($curl_connection, CURLINFO_EFFECTIVE_URL);
header('Location: '.$urlEndpoint);


How can I do this in chronoforms, using cURL [GH]
Or is this also what's done with the Mollie plug in?

Eelco
GreyHead 30 Jul, 2013
Hi Eelco,

If you need to Redirect the User then you can use the Redirect URL action (to set a dynamic URL) plus the Redirect User action (to actually do the redirection). You can use the Redirect User action alone if the URL is static i.e. it doesn't depend on the values in the form data.

You can also use a Custom Code action with PHP if you are comfortable with that:
<?php
$app =& JFactory::getApplication();
$url = 'some_url';
$app->redirect($url);
?>


Only use cURL if you need to send the data *without* the user.

Bob

PS The Mollie action does handshake validation invisibly with cURL then sends the user to the Mollie site using a form page.
eelcodejong 30 Jul, 2013
Hi Bob

Thanks for the fast reply.

If I understand correctly the option to redirect a user using cURL is only possible with a static URL. Since the URL in this ideal module is built up by Buckaroo based on choices made by the user earlier in the form (f.e. choosing a bank and an amount) using redirect actions will not work for me.

Is it possible to load the URL from the cURL info array into a variable so I can add Custom Code to the form? I am referring to the URL found in this piece of code I get back after debugging:

cURL info: Array ( [url] => https://www.abnamro.nl/nl/ideal/identification.do?randomizedstring=6493971441&trxid=1150000245272208 [content_type] => text/html; charset=ISO-8859-1 [http_code] => 200 [header_size] => 1545 [request_size] => 652 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 2 [total_time] => 2.29007 [namelookup_time] => 2.7E-5 [connect_time] => 0.002857 [pretransfer_time] => 0.0099 [size_upload] => 0 [size_download] => 14642 [speed_download] => 6393 [speed_upload] => 0 [download_content_length] => 221 [upload_content_length] => 0 [starttransfer_time] => 0.158849 [redirect_time] => 2.128839 [certinfo] => Array ( ) )


Eelco
GreyHead 30 Jul, 2013
Hi Eelco,

We may be getting at cross-purposes here. You can't redirect a user with CURL - you can only send data. And that data can be dynamic - it is very rarely static.

You could probably get the cURL debug code but what is there that is useful?

Bob
eelcodejong 30 Jul, 2013
I think I understand now, I am just beginning with cURL so not totally sure of its exact purpose and possibilities. So if I want to redirect a user to the URL as shown in my previous post I can probably better use standard Post action instead of cURL.

Gonna try and get that to work now 8)

Thanks...
GreyHead 30 Jul, 2013
Hi Eelco,

If the other site will accept GET i.e. data in a URL then you can use the ReDirect User + Redirect URL actions; if they need POST, and some do, then you need to use a second form.

Think of cURL as a way of sending data behind the scenes invisibly to the user. For example, if they check a box to join your mailing list, you can use cURL to send the info to your list service.

Bob
eelcodejong 31 Jul, 2013
Hi Bob,

Buckaroo only accepts POST so I have tried to get it to work with two forms. In the second form I use the method as described in a previous post on this site: http://www.chronoengine.com/forums.html?cont=posts&p=73564#p73564. This is not working though, I get an error from Buckaroo but nobody at Buckaroo seems to be able to tell me what the error is about. :? So I have downloaded the Mollie action you talked about earlier. Hopefully that can help me out otherwise Ill have to go look for other options cause this doesnt seem to be able with chronoforms or at least I have no clue how I should get it to work.

Problem: When I try and install the Mollie action file (gateway_mollie_gh_actions.zip) I get a server error (500). But when I install another action (f.e. ChronoForms v4 action email_gh.zip) it works great. Do you have any idea what might have gone wrong here?

Thanks,

Eelco
GreyHead 01 Aug, 2013
Hi Eelco,

Are you unzipping the 'unzip_first' file to get to the separate actions in it? There are two separate action, a form and a PDF file included.

What exactly is the error you get from Buckaroo?

Bob
eelcodejong 02 Aug, 2013
Hi Bob,

Yeah I unzipped the file and tried to install gateway_mollie_gh_actions.zip via the chronoforms Install Action button as described in the pdf file also found in the main zip file. I get a 500 error so it's probably an issue with my webserver or something. Though I find it strange that I can install other actions (like email_gh and curl_gh) without any problems. :?

The error from Buckaroo was:

"There is a technical error, please contact the website administrator"

So not much info there, but after some testing and tweaking I finally got the form working with a hidden 2nd form.

Now I am trying to get the data saved in a DB, still got some issues there but Ill start a new topic for that if I cant figure it out today :wink:

Eelco
eelcodejong 02 Aug, 2013
Database issue is solved! Problem was that I needed it to save not only form fields but also other variables which where calculated after the form submit. So I added those columns using AceSQL and now it works like a charm!

So no questions for me anymore except why the mollie action wont install.

Thanks for the help so far Bob!
GreyHead 02 Aug, 2013
Hi Eelco,

Great to see you got this working.

You can always install and action by opening the zip file and copying the folder inside into the /administrator/components/com_chronoforms/form_actions folder. That's really all that the installer does.

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