在Codeigniter中将POST重定向到外部URL有时会卡住

时间:2014-04-28 21:13:26

标签: php codeigniter curl codeigniter-2 payment-gateway

我有使用CodeIgniter制作的付款API。

我的客户将orderid, amount等数据发布到API(CodeIgniter控制器),并对请求进行身份验证。如果没问题,我会使用$this->load->view加载付款页面。

填写表单后,表单数据被发布到另一个控制器,并从那里使用模型我获取需要保存的相关数据,如数据库中生成的事务ID等,并将卡详细信息提交给我的处理器处理交易的人。

现在我的问题是,从最后一个控制器发布我的数据到处理器时,它会卡住,但有时会有效!

我使用cURL GET传递加密的数据。我尝试了标题位置,我尝试重定向,我尝试了隐藏的表单帖子。但一切都是徒劳的。

我不知道问题是什么。它有时会工作,有时它会被重定向到外部URL。

可能是什么问题?在我使用CodeIgniter之前,我使用了原始PHP,其中工作正常。但是这个MVC模型正在产生问题。有没有人有这样的问题?

代码:

<?php defined('BASEPATH') OR exit('No direct script access allowed');
// error_reporting(E_ALL);
// ini_set('display_errors', 1);

class Triggerpay extends CI_Controller
{
        public function __construct()
        {
                parent::__construct();

                $this->load->model('check_mid');
        }
        public function pay()
        {
                        $remoteIP='23.24.35.5';
                        $merchantid="ESS000";
                        $Password="zyqqby";
                        $currencyCode='356';
                        $tokenex_cipherText = $this->input->post('tokenex_cipherText');
                        $app_data['app_used'] = $appused = $this->input->post('app');
                        $trans_data['token_id'] = $token = $this->genToken($tokenex_cipherText);
                        $expiryMonth = $this->input->post('expiry_month');
                        $expiryYear = $this->input->post('expiry_year');
                        $securityCode = $this->input->post('cvv');
                        $trans_data['cardHolderName'] =$cardHolderName= $this->input->post('name_on_card');
                        $trans_data['trans_amount'] = $amount = $this->input->post('amount');
                        $trans_data['cardProvider'] = $cardProvider = $this->input->post('ccType');
                        $cardType = $this->input->post('cardType');
                        $trans_data['mobileNo'] = $mobileNo = $this->input->post('mobileNo');
                        $trans_data['cust_Email'] = $Email = $this->input->post('email');
                        $app_data['app_id'] = $apikey = $this->input->post('ak');
                        $app_data['orderID'] = $orderID = $this->input->post('orderID');
                        $app_data['trans_refNo'] = $trans_data['trans_refNo'] = $customerReferenceNo = $this->check_mid->get_new_ref_no();
                        //echo "data is ".$app_data['app_used'];
                        if($app_data['app_used'] == 'Checkout')
                                $app_data['merchant_id'] = $trans_data['merchant_id'] = $mer_id = $this->check_mid->get_user_by_apikey($apikey);
                        else if($app_data['app_used'] == 'Buttn')
                                $app_data['merchant_id'] = $trans_data['merchant_id'] = $mer_id = $this->check_mid->get_user_by_button_id($apikey);
                        else if($app_data['app_used'] == 'Invoiz')
                                $app_data['merchant_id'] = $trans_data['merchant_id'] = $mer_id = $this->check_mid->get_user_by_inv_no($apikey);

                        if($cardType=='radio1')
                                {
                                        $cardType='CC';
                                }
                        if($cardType=='radio2')
                                {
                                        $cardType='DB';
                                }              
                        if($cardProvider=='visa_electron')
                                {
                                        $cardProvider='SBIME';
                                }
                        if($cardProvider=='mastercard')
                                {
                                        $cardProvider='MC';
                                }
                        if($cardProvider=='maestro')
                                {
                                        $cardProvider='MAEST';
                                }
                        if($cardProvider=='visa')
                                {
                                        $cardProvider=='VISA';
                                }
                                $trans_data['trans_type'] = $cardType;
                                $cardProvider=strtoupper($cardProvider);
                                $name=$cardHolderName;
                                $this->check_mid->set_trans_data($trans_data, $app_data);
                                $checksum = $merchantid."|".$amount."|".$customerReferenceNo;  
                                $checksum = hash('sha256', $checksum); 
                                $data='tokenNo='.$token.'&securityCode='.$securityCode.'&cardExpiryMonth='.$expiryMonth.'&cardExpiryYear='.$expiryYear.'&cardHolderName='.$cardHolderName.'&transactionAmount='.$amount.'&paymentMode='.$cardType.'&currencyCode='.$currencyCode.'&customerReferenceNo='.$customerReferenceNo.'&cardProvider='.$cardProvider.'&name='.$name.'&mobileNo='.$mobileNo.'&email='.$Email.'&password='.$Password.'&amount='.$amount.'&remoteIP='.$remoteIP.'&checkSum='.$checksum;           
                                $encryption_key = "CE51E07D964";
                                $desEncryptedData = $this->encryptText_3des($data, $encryption_key);
                                $desEncryptedData = urlencode($desEncryptedData);
                                $external['url'] = 'https://payment.edfgffdgfg.com/PGCCDCToken/TokenPayment.jsp?merchantId='.$merchantid.'&data='.$desEncryptedData;
                                //$this->load->view('process',$external);
                                $curl = curl_init();
                                curl_setopt($curl, CURLOPT_URL, $url);
                                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                                curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
                                curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');

                                $auth = curl_exec($curl);

0 个答案:

没有答案