erimeri
erimeri

Reputation: 181

Paypal Payflow FAILURE: Invalid account number [23]

I want to implement Paypal Payflow on my Web Application, i am using PHP language as backend. Since Paypal Payflow SDK has support only for .NET and Java i need to implement myself manually with curl calls.

My code for making a request to Paypal Payflow is following:

   $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>';
    }

When i make the request i get the following response:

FAILURE: Invalid account number [23]

Can someone help me with this issue?

Thanks in advance.

Upvotes: 1

Views: 1066

Answers (0)

Related Questions