0) { if( empty($posted['key']) || empty($posted['txnid']) || empty($posted['amount']) || empty($posted['firstname']) || empty($posted['email']) || empty($posted['phone']) || empty($posted['productinfo']) || empty($posted['surl']) || empty($posted['furl']) || empty($posted['service_provider']) ) { $formError = 1; } else { //$posted['productinfo'] = json_encode(json_decode('[{"name":"tutionfee","description":"","value":"500","isRequired":"false"},{"name":"developmentfee","description":"monthly tution fee","value":"1500","isRequired":"false"}]')); $hashVarsSeq = explode('|', $hashSequence); $hash_string = ''; foreach($hashVarsSeq as $hash_var) { $hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : ''; $hash_string .= '|'; } $hash_string .= $SALT; $hash = strtolower(hash('sha512', $hash_string)); $action = $PAYU_BASE_URL . '/_payment'; }} elseif(!empty($posted['hash'])) { $hash = $posted['hash']; $action = $PAYU_BASE_URL . '/_payment';}?>They are loading the form using the following js and using in it during the body onload event. var hash = ''; function submitPayuForm() { if(hash == '') { return; } var payuForm = document.forms.payuForm; payuForm.submit(); } How to replicate the same using Chornoforms? I would prefer if the Form structure and design to be in Chronoforms itself and not create a html form. I have used Chronoforms to create forms and not done any coding for forms using HTML.Can u tell me how this can be done?Regards,Anu"> Custom Payment Gateway Integration - Forums

Forums

Custom Payment Gateway Integration

annekm 06 Nov, 2015
I have created an Application Form using Chronoforms V5. I need to integrate payment gateway when this form is submitted.

I have downloaded the integration kit for the gateway provider. It has php file for the form and 2 php files for success and failure redirection.

In the form's php, they are setting certain variables that are present as hidden fields in the form. I have created these fields in the form.

My query is where to place the php code to set these variables?

Next, on submit the form has to redirect to the gateway url, with the required variables posted. How to go about doing this?
I have also changed the form method to "Post". But on submit the form is not going to payment gateway.

This is the code they have added before the form.
<?php
// Merchant key here as provided by Payu
$MERCHANT_KEY = "JBZaLc";

// Merchant Salt as provided by Payu
$SALT = "GQs7yium";

// End point - change to https://secure.payu.in for LIVE mode
$PAYU_BASE_URL = "https://test.payu.in";

$action = '';

$posted = array();
if(!empty($_POST)) {
    //print_r($_POST);
  foreach($_POST as $key => $value) {    
    $posted[$key] = $value; 
	
  }
}

$formError = 0;

if(empty($posted['txnid'])) {
  // Generate random transaction id
  $txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
} else {
  $txnid = $posted['txnid'];
}
$hash = '';
// Hash Sequence
$hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
if(empty($posted['hash']) && sizeof($posted) > 0) {
  if(
          empty($posted['key'])
          || empty($posted['txnid'])
          || empty($posted['amount'])
          || empty($posted['firstname'])
          || empty($posted['email'])
          || empty($posted['phone'])
          || empty($posted['productinfo'])
          || empty($posted['surl'])
          || empty($posted['furl'])
		  || empty($posted['service_provider'])
  ) {
    $formError = 1;
  } else {
    //$posted['productinfo'] = json_encode(json_decode('[{"name":"tutionfee","description":"","value":"500","isRequired":"false"},{"name":"developmentfee","description":"monthly tution fee","value":"1500","isRequired":"false"}]'));
	$hashVarsSeq = explode('|', $hashSequence);
    $hash_string = '';	
	foreach($hashVarsSeq as $hash_var) {
      $hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : '';
      $hash_string .= '|';
    }

    $hash_string .= $SALT;


    $hash = strtolower(hash('sha512', $hash_string));
    $action = $PAYU_BASE_URL . '/_payment';
  }
} elseif(!empty($posted['hash'])) {
  $hash = $posted['hash'];
  $action = $PAYU_BASE_URL . '/_payment';
}
?>


They are loading the form using the following js and using in it during the body onload event.

<head>
  <script>
    var hash = '<?php echo $hash ?>';
    function submitPayuForm() {
      if(hash == '') {
        return;
      }
      var payuForm = document.forms.payuForm;
      payuForm.submit();
    }
  </script>
  </head>
  <body onload="submitPayuForm()">


How to replicate the same using Chornoforms? I would prefer if the Form structure and design to be in Chronoforms itself and not create a html form. I have used Chronoforms to create forms and not done any coding for forms using HTML.

Can u tell me how this can be done?

Regards,
Anu
Max_admin 08 Nov, 2015
Hi Anu,

They set the action url, if you do this then you can't use any of the Chronoforms "on submit" events.

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
GreyHead 08 Nov, 2015
Hi Anu,

As Max said, the methods you have posted here all redirect the user immediately to the PayU site so ChronoForms loses control and can't do anything with the data.

What you need to do is to have the form submit to ChronoForms - then send either the data + the user, or just the data to PayU to confirm the transaction.

Sending the user + the data can be done a couple of ways.

a. If PayU accepts GET transactions - ie the data is in the URL then you can use the ChronoForms Redirect action to build the url you need and redirect to it.

b. If they only accept POST transactions then you can build a mini-form in a ChronoForms form page that only shows a 'Confirm & Pay' submit button - all the other data is in hidden inputs. (You can also use JavaScript to auto-submit this after a short delay if you prefer not to rely on the User clicking a button).

Make sure that in the On Submit event before any redirect or Custom Code action like this you have checked the data, given it a unique transaction id and saved it to a database table.

Alternatively it looks as though there are a couple of PHP API libraries available - probably one of them could be integrated into a ChronoForms and handle the payment transaction from there - some coding knowledge would be required.

Bob
Jojo 30 Sep, 2016
Hi Bob,

I have created a form which is rental agreement form. It needs user to pay the processing fee on submit. I want to payumoney gateway for that. I have installed payumoney kit, and created the payment method and done the configuration. My query is how to use this payumoney plugin/component on submit event?
GreyHead 30 Sep, 2016
Hi Jojo,

How you do it depends on the PayUMoney API. Normally you can interact with a payment gateway using the ChronoForms cURL action; if not then custom PHP will work. Sometimes this is very simple, sometimes not :-( it all depends on the gateway.

Bob
Jojo 30 Sep, 2016
I am sorry I did not get it Bob. Can you be more specific? n what cURL action? And if i go with custom PHP what code should i put?
GreyHead 01 Oct, 2016
Hi Jojo,

The cURL action is one of the standard CF actions used to send information to another URL - like a payment gateway.

I haven't the slightest idea what PHP you might need as I know nothing about PayUMoney or its API.

Bob

PS I see that they have API docs with PHP examples here - I think that the required authorisation header probably means that you will need to use custom code.
This topic is locked and no more replies can be posted.