Need help with Joomla? We are available for hire to help with Joomla customization, upgrades, maintenance, and custom development.
Explore our services
Questions about Payment Form extension

Captcha (or ReCaptcha) for Payment Form too

  • azurelink
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
14 years 11 months ago #10527 by azurelink
Hello Tuan,

Is it possible to add a captcha feature to the Payment Form? I know you added it to Joom Donation.

Thanks,
azurelink

Please Log in or Create an account to join the conversation.

More
14 years 11 months ago #10536 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Captcha (or ReCaptcha) for Payment Form too
This is a planned feature and I will add it to next release of the extension (in one or two weeks) .

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • azurelink
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
14 years 11 months ago - 14 years 11 months ago #10546 by azurelink
Replied by azurelink on topic Re: Captcha (or ReCaptcha) for Payment Form too
Thanks for your reply Tuan,

I'm actually in need of a solution for the time being. And I'm more interested in using reCAPTCHA — you didn't specify what your plans involved. So if you could please help me with some direction I would appreciate it.

I've figured out that I can display the ReCAPTCHA text character field on my confirmation form by placing the code quoted below at about line 211 on the confirmation form (/components/com_pmformviews/confirmation/tmpl/default.php):
Code:
<tr> <td class="title_cell">Enter anti-spam text:</td> <td class="field_cell"> <?php require_once('includes/recaptcha/recaptchalib.php'); $publickey = "your_public_key"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> </td> </tr>

I've placed the reCAPTCHA library file (recaptchalib.php) on the server.

Where do I place the following server side code?:
Code:
<?php require_once('path_to_file/recaptchalib.php'); $privatekey = "your_private_key"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // Your code here to handle a successful verification } ?>

It says to put it at the top of the form processing script, which in the confirmation form is a little more complicated than I can figure out.

Please advise.

Thanks,
Azurelink
Last edit: 14 years 11 months ago by azurelink.

Please Log in or Create an account to join the conversation.

More
14 years 11 months ago #10547 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Captcha (or ReCaptcha) for Payment Form too
Hi

You can add the code to components/com_pmform/controller.php file, in the function process_payment . Have a look at that function and add the code to !

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • azurelink
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
14 years 11 months ago #10549 by azurelink
Replied by azurelink on topic Re: Captcha (or ReCaptcha) for Payment Form too
Hi Tuan,

Cool! Thanks.

So where in the function should I put it? I don't want to break it.
Right on the line below the opening curly bracket like the below?
Code:
function process_payment() { require_once('path_to_file/recaptchalib.php'); $privatekey = "your_private_key"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { JRequest::checkToken() or jexit( 'Invalid Token' ); $post = JRequest::get('post', JREQUEST_ALLOWHTML) ; $model = & $this->getModel('Payment') ; $model->processPayment($post) ; }

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc