ccavenue api与codeigniter集成

时间:2013-08-07 11:08:49

标签: codeigniter ccavenue

我对codeigniter很新,我正在开发一个电子商务应用程序,如flipkart使用codeigniter,现在我想将ccavenue支付网关集成到我们的网站,我已经提到了许多网站,但我无法得到适当的解决方案。 请有人帮帮我,并提供ccavenue api文档。  我没有得到整合ccavenue的codeigniter代码,我已经通过以下网址 http://integrate-payment-gateway.blogspot.in/2012/01/ccavenue-payment-integration-php.html 继续整合ccavenue.but我不知道如何解析php脚本到codeigniter。

2 个答案:

答案 0 :(得分:7)

您可以在此处获取文档。

http://world.ccavenue.com/downloads/CCAVenueWorldIntegrationManual.pdf

您可以从ccavenue帐户获取代码。只要求ccavenue帐户持有人发送包含3种语言代码的代码zip文件夹,你必须使用php文件夹。

要求以下

  1. 整合套件:
    登录ccavenue帐户,然后单击链接下载该工具包。你会在“如何设置你的ccavenue帐户?”中找到这个。

  2. 工作密钥: 转到顶部菜单中的设置和选项链接,然后单击生成工作密钥链接。并选择激活选项。

  3. 商家ID: 您将在创建工作密钥的同一页面中看到它。

  4. 获取代码后,您只需要以codeigniter的方式使用该代码。

    您还可以查看此代码。

    http://technoread.net/webdesign/payment-gateways/item/238-ccavenue-payment-integration-php

答案 1 :(得分:2)

             **Here is your view file subscription.php**

                 <html>
                   <head>
                              <script>
                                 window.onload = function() {
                                 var d = new Date().getTime();
                                document.getElementById("tid").value = d;
                                     };
                              </script>
                     </head>
          <body>
        <form method="POST" name="customerData" action="<?php echo base_url('ws_user/ccavRequestHandler'); ?>">
                                    <input type="hidden" name="tid" id="tid"  />
                <input type="hidden" name="merchant_id" value="your merchent id"/>
                <input type="hidden" name="payment_option" value="OPTNBK">  
                <input type="hidden" name="order_id" value="123654789"/>
                <input type="hidden" name="merchant_param1" value="your custom value"/>
                <input type="hidden" name="merchant_param2" value="<?php echo $userId; ?>"/>
                <input type="hidden" name="amount" value="<?php echo $amount; ?>"/>
                <input type="hidden" name="currency" value="INR"/>
                <input type="hidden" name="redirect_url" value="<?php  echo base_url('webservice/payDone');?>"/>
                <input type="hidden" name="cancel_url" value="<?php  echo base_url('webservice/cancelPayment');?>"/>
                <input type="hidden" name="billing_name" value="<?php echo $addressData[0]->name;?>"/>
                <input type="hidden" name="billing_address" value="<?php echo $addressData[0]->AddressLine1 . ' '.  $addressData[0]->Addressline2;?>"/>
                <input type="hidden" name="billing_city" value="<?php echo $addressData[0]->city_name;?>"/>
               <input type="hidden" name="billing_state" value="<?php echo $addressData[0]->state_name;?>"/>
             <input type="hidden" name="billing_zip" value="<?php echo $addressData[0]->Zipcode;?>"/>
             <input type="hidden" name="billing_country" value="<?php echo $addressData[0]->country_name;?>"/>
             <input type="hidden" name="billing_tel" value="<?php echo $addressData[0]->contact;?>"/>
       </form>
    <script language='javascript'>document.customerData.submit();</script>
  </body>
</html>

这是您的CI功能

         public function ccavRequestHandler()
    {
        $this->load->view('ccavRequestHandler');
    }

这是您的文件ccavRequestHandler.php

         <html>
              <body>
                <?php include('Crypto.php')?>
               <?php 
                   $merchant_data='';
                  $working_key='your working key';//Shared by CCAVENUES
                  $access_code='your access code';//Shared by CCAVENUES
                  foreach ($_POST as $key => $value)
                  {
                    $merchant_data.=$key.'='.urlencode($value).'&';
                  }
                $encrypted_data=encrypt($merchant_data,$working_key); ?>
             <form method="post" name="redirect" action="https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction"> 
            <?php
            echo "<input type=hidden name=encRequest value=$encrypted_data>";
            echo "<input type=hidden name=access_code value=$access_code>";?>
          </form>
         <script language='javascript'>document.redirect.submit()</script>
          </body>
         </html>

以下是您的成功网址

   public function payDone()
    {
                     $encResp=$_REQUEST['encResp'];
                     $working_key='YOURKEY';
                     $decryptValues=explode('&',$this->common->decrypt($encResp,$working_key));
                     $dataSize=sizeof($decryptValues);
                     /*CODE FOR GET YOUR VERIABLE WHEN REDIRECT ON YOUR URL */
                        for($i = 0; $i < $dataSize; $i++) 
            {
                $information=explode('=',$decryptValues[$i]);

                if($information[0] == 'merchant_param1')
                {
                    $address = $information[1];
                }
                if($information[0] == 'merchant_param2')
                {
                   $userid = $information[1];

                }
                if($information[0] == 'order_status')
                {
                   $order_status = $information[1];

                }
            }
        /*CHECK PAYMENT IS SUCCESS OR FAIL */
           if($order_status == 'Success')
                                  {
         /* DO what ever you want after successful payment */                                                    Redirect('webservice/paymentSuccess');
                                  }
                                  else 
                                  {
                           /* do whatever you want after failure */
                                     redirect('webservice/paymentFail');
                                  }
    }