How to integrate citrus payment gateway in zend?

I am trying to integrate citrus payment gateway to my application which is written in zend. I am using citrus hostel checkout. I am generating signature in controller and then pass these values to view where a form is created. Controller code:

$formPostUrl = "https://sandbox.citruspay.com/sslperf/your-vanityUrlPart";  
$secret_key = "xxxxxx"; // your secret key
$vanityUrl = "xxx"; // your vanity url
$merchantTxnId = uniqid(); 
$orderAmount = "1.00";
$currency = "INR";
$TransactionData= $vanityUrl.$orderAmount.$merchantTxnId.$currency;
$securitySignature = hash_hmac('sha1', $TransactionData, $secret_key); 
$data = [
    'formPostUrl' => $formPostUrl,
    'vanityUrl' => $vanityUrl,
    'merchantTxnId' => $merchantTxnId,
    'orderAmount' => $orderAmount,
    'currency' => $currency,
    'securitySignature' => $securitySignature,
    'returnUrl' => $this->hostName.'/'.'paymentResponse' 
]; 
return new ViewModel ( $data );

View Code:

<form align="center" method="post" action="<?php echo $formPostUrl;?>">
    <input ng-model="amount" type="number"class="form-control" id="orderAmount" name="orderAmount" placeholder="Enter the amount here.." required min="1" />
    <input type="hidden" id="merchantTxnId" name="merchantTxnId" value="<?php echo $merchantTxnId;?>" />
    <input type="hidden" id="currency" name="currency" value="<?php echo $currency;?>" /> 
    <input type="hidden" name="returnUrl" value="<?php echo $returnUrl;?>" />
    <input type="hidden" id="secSignature"  name="secSignature" value="<?php echo $securitySignature;?>" />
    <input type="Submit" value="Pay Now"/>
</form>

But the problem here is that securitySignature is created using amount and that code is written in controller but I have to take amount from user like a form which should be in view. I can't create securitySignature in view because it requires security_key which I can't write in view for security reasons. Is there any way from view I could send amount to controller and then in controller make a POST request to formPostUrl which also redirect me to formPostUrl just like in form we make a post request which also redirect to that url.

Answers


Try out the steps below,

  1. Create an intermediate submit handler on your controller
  2. Gather the UI params there and add your server side/hidden params on that.
  3. Point your UI form to the new intermediate submit handler
  4. Link the call to the payment gateway using curl from there (Eg: https://stackoverflow.com/a/5676572/1304559).

P.S: You may need to store the state of the second request in logs or db or something just in case, for audit.

Hope it helps!


Need Your Help

vaadin-combo-box / vaadin-combo-box-overlay change background color / Polymer API

javascript html css polymer vaadin

I'm trying to override the background color present in vaadin-combo-box-overlay element.

Google sheets api adding multiple rows

google-api google-sheets google-spreadsheet-api google-form

I'm trying to figure this out and I must be overlooking something basic. (It took me WAAAY longer than it should have just to realize I hadn't added the trigger.)