php - 不使用 header 重定向从我的 PHP 将值发布到第三方支付网站

标签 php session post redirect paypal

我有以下 php 代码

<?php

    $token_cipherText=$_POST['tokenex_cipherText'];
    $token=generateToken($tokenex_cipherText);  
    $merchantid="example";
    $Password="example1";
    $remoteIP='11.22.95.5';
    $customerReferenceNo = $_POST['customerReferenceNo'];
    $amount=$_POST['amount'];
    $currencyCode='356';

    $expiryMonth=$_POST['expiry_month'];
    $expiryYear=$_POST['expiry_year'];
    $securityCode=$_POST['cvv'];
    $cardHolderName=$_POST['name_on_card'];
    $cardType=$_POST['selectedRadioValue'];


       if($cardType=='radio1')
    {
        $cardType='CC';
    }
    if($cardType=='radio2')
    {
        $cardType='DB';
    }   


    $cardProvider=$_POST['ccType'];
    if($cardProvider=='visa_electron')
    {
        $cardProvider='visa';
    }
    if($cardProvider=='mastercard')
    {
        $cardProvider='mc';
    }
    if($cardProvider=='maestro')
    {
        $cardProvider='maest';
    }
    if($cardProvider=='sbi_maestro')
    {
        $cardProvider='sbime';
    }
    $cardProvider=strtoupper($cardProvider);

    $name=$cardHolderName;
    $mobileNo=$_POST['mobileNo'];
    $Email=$_POST['email'];
    $merchant_id=$_POST['merchant_id'];

    $sql=mysql_query("select * from card_token where token='$token'");
    $numrows=mysql_num_rows($sql);
    if($numrows==0)
    {
        $sql=mysql_query("insert into card_token value('','$token','$merchant_id',now())");
    }

    $sql=mysql_query("update payment_tools_transactions set token_id='$token', cardHolderName='$cardHolderName', cust_Email='$Email', mobileNo='$mobileNo', trans_type='$cardType', cardProvider='$cardProvider', trans_amount='$amount' where trans_refNo='$customerReferenceNo'");

    $checksum = $merchantid."|".$_POST['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='.$_POST['amount'].'&remoteIP='.$remoteIP.'&checkSum='.$checksum;

    $encryption_key = "CE5D964";
    $desEncryptedData = encryptText_3des($data, $encryption_key);
    $desEncryptedData = urlencode($desEncryptedData); 

    $url='https://payment.paykml.com/PGCCDCToken/TokenPayment.jsp?merchantId='.$merchantid.'&data='.$desEncryptedData;    //URL for CC authentication   
    header("location:$url");

一个 html 表单将一些值发布到此 php 中并执行上面的代码并使用标题 header("location:$url"); 这些参数被重定向到 $url= 'https://payment.paykml.com/PGCDCCToken/TokenPayment.jsp?merchantId='.$merchantid.'&data='.$desEncryptedData;

但我面临的问题是,重定向 url 像 https://payment.paykml.com/PGCDCCToken/TokenPayment.jsp?merchantId=example&data=**********

SESSION CANNOT BE USED SINCE IAM REDIRECTING TO A THIRD PARTY PAYMENT PROCESSING SITE.我不知道我是否可以通过使用 session 隐藏参数。

我的问题是是否有任何替代的发布数据的方式等同于 http header 重定向?这样数据就不会通过url发送了?

我可以通过使用 curl 来成功

//Copy paste all the code till here...
    $encryption_key = "CE5D964";
    $desEncryptedData = encryptText_3des($data, $encryption_key);
    $desEncryptedData = urlencode($desEncryptedData); 


    $url='https://payment.paykml.com/PGCCDCToken/TokenPayment.jsp?merchantId='.$merchantid.'&data='.$desEncryptedData; 
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    //curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    $auth = curl_exec($curl);
    if($auth)
    { 
    header("Location:success.php"); //Redirect to a success page after payment.
    exit;
    }

感谢@Shankar damodar 和@Basid saeed 帮我解决了这个问题

最佳答案

利用cURL做这个过程。

//Copy paste all the code till here...
    $encryption_key = "CE5D964";
    $desEncryptedData = encryptText_3des($data, $encryption_key);
    $desEncryptedData = urlencode($desEncryptedData); 


    $url='https://payment.paykml.com/PGCCDCToken/TokenPayment.jsp?merchantId='.$merchantid.'&data='.$desEncryptedData; 
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    //curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    $auth = curl_exec($curl);
    if($auth)
    { 
    header("Location:success.php"); //Redirect to a success page after payment.
    exit;
    }

关于php - 不使用 header 重定向从我的 PHP 将值发布到第三方支付网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20537761/

相关文章:

PHP 语法错误 - 无法弄清楚

php - PHP5 中的 session ——是否内置 session ?

java - Thrift 中的 session 管理

post - 为什么在Elasticsearch Head UI “any Request”中发布而不是GET

php - 你如何使用php插入到mysql数据库中?

php - CakePHP 使用 Auth 记住我

javascript - 使用 CodeIgniter 和 Ajax 以及多个输入字段在每个输入中上传多个文件

php - Codeigniter - 从许多表中获取数据

php - 用于 PHP session 存储的最佳 MySQL 存储引擎

c# - 是否可以将数据从 C# 应用程序发送到网站/网络服务器?