在轨道中集成ccavenue支付网关

时间:2015-12-16 17:09:04

标签: ruby-on-rails ruby payment-gateway ccavenue

我正在尝试将ccavenue支付网关集成到我的rails应用程序中。但是我找不到任何适当的文档。它们提供的只是4个集成文件。我无法弄清楚如何将所有这些结合在一起。

1)ccavRequestHandler.html.erb

<html>
<head>
<title> Iframe</title>
</head>
<body>
<center>
<%
  merchantData=""
  working_key=""   #Put in the 32 Bit Working Key provided by CCAVENUES.  
  access_code=""   #Put in the Access Code in quotes provided by CCAVENUES.

  params.each do |key,value|
      merchantData += key+"="+value+"&" 
  end

  crypto = Crypto.new
  encrypted_data = crypto.encrypt(merchantData,working_key)

%>
  <iframe  width="482" height="500" scrolling="No" frameborder="0"  id="paymentFrame" src="https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction&encRequest=<%=encrypted_data %>&access_code=<%=access_code %>"></iframe>
</center>

<script type="text/javascript" src="assets/javascripts/jquery-1.7.2.js"></script>
<script type="text/javascript">
      $(document).ready(function(){
        $('iframe#paymentFrame').load(function() {
         window.addEventListener('message', function(e) {
             $("#paymentFrame").css("height",e.data['newHeight']+'px');    
         }, false);
       }); 
      });
  </script>
</body> 
</html>

2)ccavResponseHandler.html.erb

<html>
<head>  
  <title>Response Handler</title>
  <%= csrf_meta_tags%>
</head>
<body>
<%  
  workingKey=""#Put in the 32 Bit Working Key provided by CCAVENUES.   
  encResponse=params[:encResp]
  crypto = Crypto.new 
  decResp=crypto.decrypt(encResponse,workingKey);
  decResp = decResp.split("&")
%>
<center>
    <font size="4" color="blue"><b>Response Page</b></font>
    <table border="1">
<tr>
  <td><b>Parameter Name</b></td>
  <td><b>Parameter Value</b></td>

  <%decResp.each do |key|%> 
    <tr>
      <td><%=key.from(0).to(key.index("=")-1)%> </td>
      <td><%=key.from(key.index("=")+1).to(-1)%> </td>
    </tr>
  <%end%>
</table>
</center>
</body>
</html>

3)crypto.rb

#*****************************************************************
#           * COMPANY    - AVENUES INDIA PVT Ltd.,
#*****************************************************************

#Name of the Program : AES Encryption/Decryption
#Created by          : AVENUES INDIA PVT Ltd., TC-Team
#Created On          : 16-02-2014
#Version             : Version 1.0
#Contribution       : eLitmus Evaluation Pvt Ltd
#***************************************************************** 



class Crypto < ActiveRecord::Base

  INIT_VECTOR = (0..15).to_a.pack("C*")    

  def encrypt(plain_text, key)
      secret_key =  [Digest::MD5.hexdigest(key)].pack("H*") 
      cipher = OpenSSL::Cipher::Cipher.new('aes-128-cbc')
      cipher.encrypt
      cipher.key = secret_key
      cipher.iv  = INIT_VECTOR
      encrypted_text = cipher.update(plain_text) + cipher.final
      return (encrypted_text.unpack("H*")).first
  end

  def decrypt(cipher_text,key)
      secret_key =  [Digest::MD5.hexdigest(key)].pack("H*")
      encrypted_text = [cipher_text].pack("H*")
      decipher = OpenSSL::Cipher::Cipher.new('aes-128-cbc')
      decipher.decrypt
      decipher.key = secret_key
      decipher.iv  = INIT_VECTOR
      decrypted_text = (decipher.update(encrypted_text) + decipher.final).gsub(/\0+$/, '')
      return decrypted_text
  end
end

4)dataForm.html.erb

<html>
<head>
</head>
<body>
    <form method="POST" name="customerData" action="/transaction/ccavRequestHandler">
        <table width="40%" height="1" border='1' align="center"><caption><font size="4" color="blue"><b>Integration Kit</b></font></caption></table>
            <table width="40%" height="100" border='1' align="center">
                <tr>
                    <td>Parameter Name:</td><td>Parameter Value:</td>
                </tr>
                <tr>
                    <td colspan="2"> Compulsory information</td>
                </tr>
                <tr>
                    <td>Merchant Id :</td><td><input type="text" name="merchant_id" value="2954"/></td>
                </tr>
                <tr>
                    <td>Order Id    :</td><td><input type="text" name="order_id" value="123654789"/></td>
                </tr>
                <tr>
                    <td>Amount  :</td><td><input type="text" name="amount" value="1.00"/></td>
                </tr>
                <tr>
                    <td>Currency    :</td><td><input type="text" name="currency" value="INR"/></td>
                </tr>
                <tr>
                    <td>Redirect URL    :</td><td><input type="text" name="redirect_url" value="http://merchantdomain/transaction/ccavResponseHandler"/></td>
                </tr>
                <tr>
                    <td>Cancel URL  :</td><td><input type="text" name="cancel_url" value="http://merchantdomain/transaction/ccavResponseHandler"/></td>
                </tr>
                <tr>
                    <td>Language    :</td><td><input type="text" name="language" value="EN"/></td>
                </tr>
                <tr>
                    <td colspan="2">Billing information(optional):</td>
                </tr>
                <tr>
                    <td>Billing Name    :</td><td><input type="text" name="billing_name" value="Charli"/></td>
                </tr>
                <tr>
                    <td>Billing Address :</td><td><input type="text" name="billing_address" value="Room no 1101, near Railway station Ambad"/></td>
                </tr>
                <tr>
                    <td>Billing City    :</td><td><input type="text" name="billing_city" value="Indore"/></td>
                </tr>
                <tr>
                    <td>Billing State   :</td><td><input type="text" name="billing_state" value="MP"/></td>
                </tr>
                <tr>
                    <td>Billing Zip :</td><td><input type="text" name="billing_zip" value="425001"/></td>
                </tr>
                <tr>
                    <td>Billing Country :</td><td><input type="text" name="billing_country" value="India"/></td>
                </tr>
                <tr>
                    <td>Billing Tel :</td><td><input type="text" name="billing_tel" value="9876543210"/></td>
                </tr>
                <tr>
                    <td>Billing Email   :</td><td><input type="text" name="billing_email" value="person@gmail.com"/></td>
                </tr>
                <tr>
                    <td colspan="2">Shipping information(optional)</td>
                </tr>
                <tr>
                    <td>Shipping Name   :</td><td><input type="text" name="delivery_name" value="Chaplin"/></td>
                </tr>
                <tr>
                    <td>Shipping Address    :</td><td><input type="text" name="delivery_address" value="room no.701 near bus stand"/></td>
                </tr>
                <tr>
                    <td>shipping City   :</td><td><input type="text" name="delivery_city" value="Hyderabad"/></td>
                </tr>
                <tr>
                    <td>shipping State  :</td><td><input type="text" name="delivery_state" value="Andhra"/></td>
                </tr>
                <tr>
                    <td>shipping Zip    :</td><td><input type="text" name="delivery_zip" value="425001"/></td>
                </tr>
                <tr>
                    <td>shipping Country    :</td><td><input type="text" name="delivery_country" value="India"/></td>
                </tr>
                <tr>
                    <td>Shipping Tel    :</td><td><input type="text" name="delivery_tel" value="9595226054"/></td>
                </tr>
                <tr>
                    <td>Merchant Param1 :</td><td><input type="text" name="merchant_param1" value="additional Info."/></td>
                </tr>
                <tr>
                    <td>Merchant Param2 :</td><td><input type="text" name="merchant_param2" value="additional Info."/></td>
                </tr>
                <tr>
                    <td>Merchant Param3 :</td><td><input type="text" name="merchant_param3" value="additional Info."/></td>
                </tr>
                <tr>
                    <td>Merchant Param4 :</td><td><input type="text" name="merchant_param4" value="additional Info."/></td>
                </tr>
                <tr>
                    <td>Merchant Param5 :</td><td><input type="text" name="merchant_param5" value="additional Info."/></td>
                </tr>
                <tr>
                    <td>Promo Code  :</td><td><input type="text" name="promo_code" value=""/></td>
                </tr>
                <tr>
                    <td>Vault Info. :</td><td><input type="text" name="customer_identifier" value=""/></td>
                </tr>
                <tr>
                    <td>Integration Type    :</td><td><input type="text" name="integration_type" value="iframe_normal"/></td>
                </tr>
                <tr>
                    <td></td><td><INPUT TYPE="submit" value="CheckOut"></td>
                </tr>
            </table>
          </form>
    </body>
</html>

这4个文件是他们提供的唯一文档..

我还可以看到在html.erb文件中他们希望我们把钥匙放?安全吗? 他们提供的宝石真的已经过时,因此甚至没有提及它。我真的无法弄清楚从哪里开始..可以有人给我一个关于如何做到这一点的粗略想法???

0 个答案:

没有答案