Forums

Accepting payments and storing information

petersen 10 Jun, 2008
I'd like to create a registration form where the user needs to pay to join the site. In simplest terms, it doesn't have to be integrated with Joomla, but needs to store registration details in the database. We're looking at using Google Checkout/Secpay for payment processing. Can someone give me a simple plan of action?

I wsa thinking it would be as follows:

1) User enters details
2) User submits form
3) User directed to payment page
4) User pays
5) User redirected back to site and details entered into database.

Is this possible?
petersen 10 Jun, 2008
I've found this FAQ

which I think is what I'm after.

In terms of post payment processing, how do I update the db when I get a success back?
GreyHead 10 Jun, 2008
Hi petersen,

Create a second form to handle the return and give the url of this to the payment provider.

Bob

PS There's an Authorise.net plugin for ChronoForms that may well help you with this.
petersen 11 Jun, 2008
Ah I get it. Just use the second form for processing like you would with a normal page. I'll take a look at the Authorize method.

Thanks Bob
GreyHead 11 Jun, 2008
Hi petersen,

Yes that's it.

You could use the same form if it helps. Include &task=send in the url and add some other parameter - like &pay_return=true - that you can use to identify where the return call is coming from. You use this with a php switch in the OnSubmit code to process the reply.

Bob
petersen 11 Jun, 2008
Lovely. Just needed to get my head around how it would work. I think we'll be using Secpay so I might try and sort it as a plugin if I get chance.
Max_admin 11 Jun, 2008
Hi Petersen,

if the user will not pay on your site and at the same form then the Authorize plugin will not help you as it uses some method to post payment details to Authorize.net and get the response behind the scenes, user add all payment data at the form itself!

as Bob mentioned, to make things easy you will need a new form to process the payment gateway response, you will need to write more code if you want to tie the first form submission to the new processing form data!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
petersen 25 Jun, 2008
I have created a form which has my secpay details in another form in my onsubmit (after sending) code. I wish to grab the insertid from the previous form and use it as my tranaction id. How can I grab it?

I've got
<?php
//Get return ID
global $return_id; 
$return_id = $database->insertid();
?>
<p>Gardening club is available to all customers for £10 a year. 
Join today and start benefiting from 10% off* all plants.</p>
<form action="https://www.secpay.com/java-bin/ValCard" method="post">
<input type="hidden" name="merchant" value="####" />
<input type="hidden" name="trans_id" 
value="<?php echo $return_id; ?>" />
<input type="hidden" name="amount" value="10.00" />
<input type="hidden" name="callback" value="####" />


<input type="hidden" name="options" 
value="cb_post=false,dups=true,test_status=true" />
<div class="formrow submit">
<input name="submit" value="Proceed to Payment" type="image" 
src="images/proceedtopayment.gif" class="submit" />
	</div>
</form>
petersen 25 Jun, 2008
I've since seen that I can add the code to grab the id by adding the

global $return_id; 
$return_id = $database->insertid();


into the Autogenerated code. However, I can get the value of $return_id in either onsubmit (before or after). Is this possible?
GreyHead 25 Jun, 2008
Hi Petersen,

You can do this with one form without creating a second one in the OnSubmit code.

Just gather the variables that you want into the $_POST array and use the secpay url as a ReDirect url. The ReDirect will be done at the end of the form processing and will pass whatever is then in the $_POST array. (At least I think that will work, usualy I do it by building an url but SecPay don't seem to support that.)

If you do that you can add something like:
$_POST['trans_id'] = $return_id;
into the end of the Autogenerated code.

Bob
petersen 25 Jun, 2008
I've put the code into my form as follows:
<fieldset>
  <legend>Your Details</legend>
  <div class="formrow">
    <label for="title">Title<span class="req">*</span></label>
    <select name="title" id="title" onchange="showother(this.id,'othertitlefields');">
      <option value="">Please choose</option>
      <option value="Mr">Mr</option>
      <option value="Mrs">Mrs</option>
      <option value="Miss">Miss</option>
      <option value="Ms">Ms</option>
      <option value="Other">Other</option>
    </select>
  </div>
  <div class="formrow" id="othertitlefields" style="display:none;">
    <label for="othertitle">Other Title<span class="req">*</span></label>
    <input type="text" name="othertitle" value="<?php echo JRequest::getVar("othertitle",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow half">
    <label for="firstname">First Name<span class="req">*</span></label>
    <input type="text" name="firstname"  
value="<?php echo JRequest::getVar("firstname",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow half">
    <label for="surname">Surname<span class="req">*</span></label>
    <input type="text" name="surname"  
value="<?php echo JRequest::getVar("surname",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow">
    <label for="address1">Address<span class="req">*</span></label>
    <input type="text" name="address1"  
value="<?php echo JRequest::getVar("address1",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow">
    <label for="city">Town/City<span class="req">*</span></label>
    <input type="text" name="city" 
value="<?php echo JRequest::getVar("city",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow">
    <label for="county">County<span class="req">*</span></label>
    <input type="text" name="county" 
value="<?php echo JRequest::getVar("county",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow half">
    <label for="postcode">Postcode<span class="req">*</span></label>
    <input type="text" name="postcode"  
value="<?php echo JRequest::getVar("postcode",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow">
    <label for="tel">Telephone No.<span class="req">*</span></label>
    <input type="text" name="tel" 
value="<?php echo JRequest::getVar("tel",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow">
    <label for="email">Email<span class="req">*</span></label>
    <input type="text" name="email" 
value="<?php echo JRequest::getVar("email",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow">
    <label for="previousnumber">Previous Membership Number</label>
    <input type="text" name="previousnumber" 
value="<?php echo JRequest::getVar("previousnumber",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
</fieldset>
<hr />
<fieldset>
<legend>Your Gardening Needs</legend>
  <p>Please help us to get a better understanding of 
your gardening needs by answering the following:</p>
  <p>How often do you shop at your Garden Centre?</p>
  <div class="formrow radio">
    <label for="weekly">Weekly</label>
    <input type="radio" name="howoften" value="weekly" />
    <label for="fortnightly">Fortnightly</label>
    <input type="radio" name="howoften" value="fortnightly" />
    <label for="monthly">Monthly</label>
    <input type="radio" name="howoften" value="monthly" />
    <label for="lessfrequently">Less Frequently</label>
    <input type="radio" name="howoften" value="lessfrequently" />
  </div>
  <div class="formrow widelabel">
    <label for="wheredoyoushop">Where do you most often shop 
for gardening products?</label>
    <select name="wheredoyoushop" id="wheredoyoushop" 
onchange="showother(this.id,'othershopfields');">
      <option value="">Please choose</option>
      <option value="Wyevale">Wyevale</option>
      <option value="DIYCentre">DIY Centre</option>
      <option value="Other">Other</option>
    </select>
  </div>
  <div class="formrow" id="othershopfields" style="display:none;">
    <label for="othershop">Other</label>
    <input type="text" name="othershop" 
value="<?php echo JRequest::getVar("othershop",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow widelabel">
    <label for="addditionalserviceswanted">Which additional 
products, services or facilities would you like to see here?</label>
    <input id="additional" type="text" name="addditionalserviceswanted" 
value="<?php echo JRequest::getVar("previousnumber",null,"POST","STRING",JREQUEST_NOTRIM); ?>" />
  </div>
  <div class="formrow widelabel small">
<input type="checkbox" name="joinmailinglist" value="Yes" id="terms" />
    <label for="joinmailinglist">From time to time we would 
like to provide you with details of special offers or events 
from Wyevale or other carefully selected organisations. 
Please tick the box if you do not wish to be added to our mailing list.</label>
    
  </div>
</fieldset>
<hr />
<fieldset>  
  <div class="formrow">
    <span>To help us increase security, please enter the security code below.</span>
  </div>
  <div class="formrow">
    <label for="chrono_verification">Enter Code:</label>
    {imageverification} 
  </div>
  <div class="formrow submit">
    <input name="submit" value="Proceed to Payment" type="image" 
src="images/proceedtopayment.gif" class="submit" />
  </div>

<input type="hidden" name="merchant" value="####" />
<input type="hidden" name="trans_id" value="<?php echo $return_id; ?>" />
<input type="hidden" name="amount" value="10.00" />
<input type="hidden" name="callback" value="http://localhost:81/wyevalecompetitions/" />
<input type="hidden" name="options" value="cb_post=false,dups=true,test_status=true" />
</fieldset>
The form redirects to secpay but looks like it doesn't have any form fields. Do I need to repopulate the POST array? If so, how?
This topic is locked and no more replies can be posted.