Forums

[solved] email,save to database then transfer topayment site

mypethamster 06 Dec, 2009
I've created forms, with no problems, setup email, and update data to database, but how do you, after doing these, do you either go directly to a selected payment site (paypal or nochex), or to another form (similar to 'thank you for applying, now to complete application pay the deposit fee' ) where you collect some of the details name, address etc and send to selected payment site.

form 1: is in a module, where you select location, and start date. (submit: go directly to form 2)

form 2: tells you that your choice is available, and gives alternative locations (checkboxes) matching date. (submit: go to form3)

form 3: is where you enter you details, name, address, country blah, blah and when you submit it sends email, and saves (including data from form1 and form2) to database.

but i can't figure out how to email, save to database and then go to selected payment site option, without losing the email, and save to database feature?.

I've tried several different ways, and just can't get it to work, and its starting to make my head spin, that I thought I'd ask the pros who built this application.

what am i missing here? i'm so close to finishing it.

suggestions please.
GreyHead 06 Dec, 2009
Hi MyPetHampster,

Use the ReDirect Plugin on the last step.

Bob
mypethamster 06 Dec, 2009
Thanks greyhead, I beat you to the redirect plugin option, after leaving it for a few hours, and then returning. It works, but it sends the values by the GET method instead of POST. Is this the only option it will allow, when using redirect?

I'm planning using ssl, to encrypt data from site to paypal and nochex sites.

another question:

Is it possible to add two radio options, relating to the specific payment sites, on the 'enter details' form, and change page redirect depending on option selected?

I know this can be done in JavaScript, but i'd rather not use this to achieve this.

Thanks in advance,
GreyHead 07 Dec, 2009
Hi MyPetHampster,

If you need to use POST then I think that you can do that with the cURL plugin (which is very similar to the ReDirect Plugin). I just forget how you transfer the user to the other site with the cURL plugin but I'm sure that I had that working a while back.

I'm sure that the radio buttons can be set up easily enough but I think that you'd then need to handcode the cURL/ReDirect code ino the OnSubmit after boxes as there isn't any easy way I can think of to configure more than one version of the plugin.

Bob
mypethamster 07 Dec, 2009
OK! thought i had it working to what i required using:

<?php
$MyForm =& CFChronoForm::getInstance();

if($_POST['paymentsite']=="paypal")
{
$url = "https://www.sandbox.paypal.com/cgi-bin/websc";
$url .= "&cmd=_xclick";
$url .= "&business=testmerchant@yahoo.co.uk";
$url .= "&item_name=Placement securement";
//$url .= "&item_number=1001";
$url .= "¤cy_code=GBP";
$url .= "&amount=".$_POST['amount'];
$url .= "&email=".$_POST['email'];
$url .= "&return=http://testsite.co.uk/";
// $url .= "&return=some_url";
$url .= "&cancel_return=http://testsite.co.uk/";
}
if($_POST['paymentsite']=="nochex")
{
$url = "https://secure.nochex.com/";
$url .= "?merchant_id=ukgadgetsrus-demo2"; //test merchant id
$url .= "&description=Placement securement";
$url .= "&amount=".$_POST['amount'];
$url .= "&email_address=".$_POST['email'];

//$url .= "&test_success_url=http://www.ukrs.com/sucess.htm"; //test return
$url .= "&test_transaction=100"; //test identifier


}


if ( $debug ) {
echo "url: ";print_r($url);echo "<br />";
echo "<br /><a href='$url'>Click to continue</a><br />";
} else {
$MyForm->formrow->redirecturl = $url;
}
?>

Good: goes straight to paypal site description, price and no sign of $url values, all seem to encrypted.

bad: goes straight to nochex site description, price, but failed with values listed in address.

So if you can provide link to CURL to post data and take the user to payment site, that would be great! i have looked, but all i have found is, 'I am creating curl with user transfer' and 'something about you googling and using a curl feature' but not the actual code itself.

I also wish to know, what is required to make the last form, which emails, saves date, and go straight to payment site work with SSl, as i converted the page to ssl, but when you submit, it opens a blank page(form page) it says 'i am not allowed access to this page'???. I think this relates to the action reference to page without ssl (https://ssl.com/blahblah);

any advice welcome, different setup of forms, I know i definitely require the curl solution.

would it be better, to email, save user details->confirmation or thank you page, then go to payment site? still avoiding GET using POST only.

I thought i was near the end, but now the treadmill is running in reverse.

Mega thanks in advance.
mypethamster 10 Dec, 2009
The Main problem I found, was with the shared 'ssl.com' ref not being included within the action ref, as in 'https://ssl.com/example.com' it would revert back to https://example.com.

To fix this i ended the form name with suffix of _sssl, and edited the file chronoform.php, at 'examplesite/components/com_chronocontact/libraries/chronoform.php' to look for this suffix, and if found insert 'ssl.com' or whatever shared ssl ref, into the address.

Second problem, when email sent, and database saved, the redirection resulted in the values appearing in address, at it uses GET, instead of POST, when sent to thank you page(again a ssl 'https://ssl.com/' page).

As the first form, remains ssl now! i can use a session to store these values (being both ssl, as sessions are domain reliant meaning a session set in https://example.com, cannot be read in http://example.com, and visa versa), and access these values in the second form to populate the fields required for payment site.
redrings 10 Dec, 2009

Hi MyPetHampster,

If you need to use POST then I think that you can do that with the cURL plugin (which is very similar to the ReDirect Plugin). I just forget how you transfer the user to the other site with the cURL plugin but I'm sure that I had that working a while back.

Bob



Hello Bob,

I need to use POST to get to my payment gateway, but I've run into a problem when attempting to use cURL to send the data.

The 'action' url for my payment gateway looks like this:
https://www.paymentgateway.com:8443/C20271test_upay/web/index.jsp

When I submit the form I get this:
Not Found
The requested URL /C20271test_upay/tapp was not found on this server.
Apache/2.2.9 (Ubuntu) mod_ssl/2.2.9 OpenSSL/0.9.8g PHP/5.2.6-2ubuntu4.3 with Suhosin-Patch Server at webtest.bus.okstate.edu Port 80

The url in the address bar at this point is: http://www.mytestingsite.com/C20271test_upay/tapp - notice that the root of the url is my test server instead of the payment gateway.

Any idea what I'm doing wrong?

Thanks!
GreyHead 11 Dec, 2009
Hi redrings,

The error could be something to do with the the query over the security certificate that I see in FireFox.

The cURL Plugin does a post to the other site but does not redirect the user so you should continue to see your own site URL.

Bob
GreyHead 11 Dec, 2009
Hi MyPetHampster,

I spent some time this morning Googling around looking for solutions.

There is no cURL option to redirect the user :-(

There are very few options to redirect using POST at all :-(
[list]
  • There an obscure and unreliable option using a 307 redirect
  • There a code snippet here (look for Garbett's post in the middle of the page) that might be usable
  • There are some techniques using Javascript to autosubmit a 'hidden' form - basically you create a new form with the info in hidden filds and add a script to submit it on page load.
  • [/list]I think all of these would work in the right circumstances but none of them fill me with confidence.

    ReDirect Using GET is still probably the simplest option and is no less secure than these versions. I checked that nochex support GET

    One alternative is to redirect the user with GET and then use an API like the PayPal IPN to validate the transaction. You interact with that using cURL (the nochex version is here. But this may mean that you need to re-think some of the workflow.

    I'm afraid that SSL / URL problems make my eyes glaze over so I don't have any useful suggestions there. Max or Fredrik may well know more than I do.

    Bob

    PS For the dedicated I found a long list of posts on PHP POST + Redirect here. A few may be useful!!
    redrings 11 Dec, 2009

    There is no cURL option to redirect the user :-(



    I see, I think that is my problem - I need it to redirect as they have to fill in their credit card information on the payment gateway site. Unfortunately it will only accept POST data. Seems like there should be an easier way of having chronoforms send the email and log the data before using an a different submit url.

    Anyway, thanks for the explanation.
    GreyHead 11 Dec, 2009
    Hi redrings,

    Which payment gateway are you using? PM or email me if you prefer. I'd be interested to see if there is a work-around.

    Bob

    PS This seems to be a very frequent problem generally, not restricted to ChronoForms or to Joomla.
    redrings 11 Dec, 2009
    So my next idea was to create two forms, for example - uPayTest and uPayTest2

    The first form, uPayTest, I tried using the Redirect plugin and redirecting to the second form, uPayTest2. I thought that by doing this I could log the info in the db and send the email and use the second form as a 'confirmation page', which then submits the POST data to the uPay payment gateway.

    However, I can't seem to get the second form to read the data from the first form. The first form (http://webtest.bus.okstate.edu/redesign/index.php?option=com_chronocontact&chronoformname=uPayTest) submits and redirects (using the redirect plugin) to the second form, but it doesn't seem to be reading the values from the first. Here's my debug info:

    $_POST: Array ( [UPAY_SITE_ID] => 26 [BILL_NAME] => Robert [BILL_EMAIL_ADDRESS] => [phone] => [BILL_STREET1] => [BILL_STREET2] => [BILL_CITY] => [BILL_STATE] => OK [BILL_POSTAL_CODE] => [businessName] => [businessAddress] => [businessCity] => [businessHomeState] => OK [businessZip] => [services] => [yearsInBusiness] => [numberOfEmployees] => [yearlyRevenue] => Select an Option [9366dba26713cb2a025222cf31d99aff] => 1 [1cf1] => 9c40064823d28f78b13120d6c7d7eca1 [chronoformname] => uPayTest )


    I've tried using the both of the following in the form, but both fields remain blank:
    <input name="BILL_NAME" type="text" id="BILL_NAME" size="40" value="<?php $_POST['BILL_NAME']; ?>" />
    <input name="BILL_NAME" type="text" id="BILL_NAME" size="40" value="<?php $_GET['BILL_NAME']; ?>" />
    redrings 11 Dec, 2009
    Okay,

    I forgot to insert all of the field names in the redirect plugin, but now I've run into another problem. It appears that the url with the GET data is keeping it from being able to load the second form (uPayTest2). I'm getting:

    There is no form with this name or may be the form is unpublished, Please check the form and the url and the form management

    The url is:
    http://webtest.bus.okstate.edu/redesign/index.php?option=com_chronocontact&chronoformname=uPayTest2?UPAY_SITE_ID=26&BILL_NAME=Robert&BILL_EMAIL_ADDRESS=&BILL_STREET1=&BILL_STREET2=&BILL_CITY=&BILL_STATE=OK&BILL_POSTAL_CODE=
    GreyHead 11 Dec, 2009
    Hi redrings,

    This will work but the $_POST info isn't automatically transferred.

    I'd do this with a single form using some PHP logic to decide which chunk of HTML is displayed, that way you still have access to the posted data.

    To reshow a form ChronoForms has this code
    $MyForm->showForm($MyForm->formrow->name, $posted);
    . (It looks as though you might be able to call a different form with this but I've never tried ???)

    If you want to use two forms that you could use the multi-page plugin which passes the data in the session info; or code this yourself; or save the info into the database and re-load it in the second form . . . too many options, sorry.

    Bob
    mypethamster 13 Dec, 2009
    you need to echo the posted values to show them.


    <input name="BILL_NAME" type="text" id="BILL_NAME" size="40" value="<?php echo $_POST['BILL_NAME']; ?>" />

    <input name="BILL_NAME" type="text" id="BILL_NAME" size="40" value="<?php echo $_GET['BILL_NAME']; ?>" />

    <input name="BILL_NAME" type="text" id="BILL_NAME" size="40" value="<?php echo $_REQUEST['BILL_NAME']; ?>" /> //reads both GET or POST
    This topic is locked and no more replies can be posted.