Paypal Payflow失败:无效的帐号[23]

时间:2018-08-29 16:00:10

标签: php curl paypal payflowpro

我想在Web应用程序上实现Paypal Payflow,我使用PHP语言作为后端。由于Paypal Payflow SDK仅支持.NET和Java,因此我需要使用curl调用手动实现自己。

我向Paypal Payflow发出请求的代码如下:

   $user = 'user1'; // API User Username
    $password = '123456'; // API User Password
    $vendor = 'mainvendor'; // Merchant Login ID
    $cardno=str_replace(' ', '', $_POST["cardNumber"]);
    $expdate=str_replace(' ', '', $_POST["cardExpiry"]);
    $cvv2=$_POST["cardCVC"];
    // Reseller who registered you for Payflow or 'PayPal' if you registered
    // directly with PayPal
    $partner = 'PayPalCA'; 




    $amount = $_POST["amountcurrency"];
    $currency = $currencies["currency"];

    $url ='https://payflowpro.paypal.com';


        $request  = 'USER=' . urlencode($user);
        $request .= '&VENDOR=' . urlencode($vendor);
        $request .= '&PWD=' . $password;
        $request .= '&PARTNER=' . urlencode($partner);
        $request .= '&TRXTYPE=S';
        $request .= '&TENDER=C';
        $request .= '&ACCT=' . str_replace(' ', '', $cardno);
        $request .= '&EXPDATE=' . $expdate;
        $request .= '&CVV2=' . $cvv2;
        $request .= '&AMT=' . $amount;
        $request .= '&CURRENCY=' . $currency;
        $request .= '&COMMENT1=Bet Deposit';
        $request .= '&BILLTOFIRSTNAME=' . $userinfo["user_name"];
        $request .= '&BILLTOLASTNAME=' . $userinfo["user_surname"];
        $request .= '&BILLTOSTREET=' . $userinfo["street_number"];
        $request .= '&BILLTOCITY    =' . $userlocation->cityname;
        $request .= '&BILLTOSTATE   =' . $userlocation->subcountryname;
        $request .= '&BILLTOZIP=' . str_replace(' ', '', 
         $userinfo["postal_code"]);
        $request .= '&BILLTOCOUNTRY=' . $userinfo["country"];
        $request .= '&CUSTIP=' . $iusers->get_ip_address();
        $request .= '&EMAIL=' . $userinfo["user_email"];




    $headers = array();
    $headers[] = 'Content-Type: application/x-www-form-urlencoded';
    $headers[] = 'Content-Length: ' . strlen($request);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
    curl_setopt($ch, CURLOPT_HEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $result = curl_exec($ch);
    curl_close($ch);

    // Parse results
    $response = array();
    $result = strstr($result, 'RESULT');    
    $valArray = explode('&', $result);
    foreach ($valArray as $val) {
      $valArray2 = explode('=', $val);
      $response[$valArray2[0]] = $valArray2[1];
    }



    if ($response['RESULT'] == 0) {
      echo '<span style="color: white;">SUCCESS!</span>';
    } else {
      echo '<span style="color: white;">FAILURE: ' . $response['RESPMSG'] . ' ['. $response['RESULT'] . ']</span>';
    }

当我发出请求时,我得到以下响应:

失败:无效的帐号[23]

有人可以帮助我解决这个问题吗?

谢谢。

0 个答案:

没有答案