Paypal会话数据无法检索

时间:2012-05-29 06:57:51

标签: php paypal paypal-adaptive-payments

我在我的网站上使用Paypal自适应支付方式。

当我点击存款按钮时,我会调用deposit()函数 paypal为我提供了类似于https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=PAY_KEY

的重定向网址

但是当我在完成交易后返回我的网站时,我无法从paypal获得会话中的Pay键。

这是我的代码段

function deposit() {
    try {
        $PayPalConfig = array('Sandbox' => true,
            'DeveloperAccountEmail' => xxx@yyy.com,
            'ApplicationID' => APP_ID,
            'DeviceID' => DEVICE_ID,
            'IPAddress' => IP_ADDRESS,
            'APIUsername' => API_USERNAME,
            'APIPassword' => API_PASSWORD,
            'APISignature' => API_SIGNATURE,
            'APISubject' => API_SUBJECT);
        $PayPal = new PayPal_Adaptive($PayPalConfig);
        // Prepare request arrays
        $PayRequestFields = array(
            'ActionType' => 'PAY', 
            'CancelURL' => CANCEL_URL, 
            'CurrencyCode' => 'USD',
            'FeesPayer' => 'SENDER',
            'IPNNotificationURL' => '',
            'Memo' => '',
            'Pin' => '', 
            'PreapprovalKey' => '',
            'ReturnURL' => RETURN_URL,
            'ReverseAllParallelPaymentsOnError' => '', 
            'SenderEmail' => '', 
            'TrackingID' => ''
        );
        $Receivers = array();

        $Receiver = array(
            'Amount' => 10,
            'Email' => MY_PAYPAL_ACCOUNT,
            'InvoiceID' => '',
            'PaymentType' => '',
            'PaymentSubType' => '',
            'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => ''), 
            'Primary' => 'false'
        );
        array_push($Receivers, $Receiver);


        $PayPalRequestData = array(
            'PayRequestFields' => $PayRequestFields,
            'Receivers' => $Receivers,
        );

        $PayPalResult = $PayPal->Pay($PayPalRequestData);

        if ($PayPalResult['Ack'] != 'Success')
            return FALSE;
        else if ($PayPalResult['PaymentExecStatus'] == CREATED)
            header('Location: '.$PayPalResult['RedirectURL']);
    } catch (Exception $ex) {
        die('Exception in API Call');
    }
}

0 个答案:

没有答案