Paypal Payflow FAILURE: неверный номер счета [23] - PullRequest
0 голосов
/ 29 августа 2018

Я хочу реализовать 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]

Может кто-нибудь помочь мне с этим вопросом?

Заранее спасибо.

...