首页 > 解决方案 > PHP 会话在后台进程中不起作用

问题描述

我有这段代码,当支付网关成功时,它将重定向到参数中的通知 url。

include 'payment_information_rebill.php';

if(isset($_GET)){
    
    $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => 'url here',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS =>'{
                "merchantId": "' .$_mid. '",
                "orgResponseId": "' .$_responseid. '",
                "requestId": "' .$_requestid. '",
                "amount": "' .$_verifamount. '",
                "clientId": "' .$_clientid. '",
                "clientIp": "' .$_clientip. '",
                "ipAddress": "' .$_ipaddress. '",
                "signature": "' .$_signverify. '"
        }',
        CURLOPT_HTTPHEADER => array(
                'Content-Type: application/json',
                'Idempotency-Key: ' .$_requestid. '',
                'Authorization: Basic auth here'
              ),
    ));
            
    $response = curl_exec($curl);
    
    curl_close($curl);
    $result = json_decode($response, true); // true turns it into an array
}

付款信息 rebill 包含 curl 所需的所有变量,可在购物车页面上使用。但是,当我将 curl 函数放在支付网关的 redirecturl 中时,变量似乎为空。变量从会话中获取数据。会话仅在您访问该页面时起作用吗?它不适用于背景吗?

标签: phpwordpresssessionpayment-gateway

解决方案


推荐阅读