2014-08-27 2 views
1

제목으로 PayPal에 문제가 있으며 IPN이 지불 결제 방법으로 확인되었습니다. 지금까지 한 모든 가입 IPN에 대해 데이터와 함께 INVALID가 반환되었습니다. 문제는 동일한 정확한 코드에 대해 버튼을 _xclick-subscription에서 _donations로 변경하면 예를 들어 VERIFIED 결과를 얻습니다.Paypal Subscription 유효하지 않은 반환 IPN

나는 내 문제에 대한 해결책을 찾기 위해 약간의 시간을 보냈지 만 찾을 수 없었습니다. 여기에 무슨 일이 일어나고 있는지 - 나는 사용자가 paypal (이 경우에는 샌드 박스)로 이어지는 가입 ​​버튼을 만들어 지불 한 후 지불 한 후 웹 사이트로 돌아갈 수있는 옵션을 갖습니다. 다음은 버튼 코드입니다. 이 이후

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> 
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but20.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> 
<input type="hidden" name="cmd" value="_xclick-subscriptions"> 
<input type="hidden" name="business" value="[email protected]"> 
<input type="hidden" name="item_name" value="Monthly Sub"> 
<input type="hidden" name="no_note" value="1"> 
<input type="hidden" name="currency_code" value="USD"> 
<input type="hidden" name="a3" value="10.00"> 
<input type="hidden" name="p3" value="1"> 
<input type="hidden" name="t3" value="M"> 
<input type="hidden" name="src" value="1"> 
<input type="hidden" name="sra" value="1"> 
<input type="hidden" name="rm" value="2"> 
<input type="hidden" name="return" value="http://url.com/thanks.php"> 
</form> 

내가 실제로 대신 무효의 확인으로 돌아 가기 얻을 수 있어요 때까지 거의 베어 필요한 값을 갖는 아래로 버튼을 부러 나를 위해 상당한 문제가되고있다. 다음은 IPN 수신기로 가지고있는 코드입니다.

define("DEBUG", 1); 
define("USE_SANDBOX", 1); 
define("LOG_FILE", "./ipn.log"); 
// Read POST data 
// reading posted data directly from $_POST causes serialization 
// issues with array data in POST. Reading raw POST data from input stream instead. 
$raw_post_data = file_get_contents('php://input'); 
$raw_post_array = explode('&', $raw_post_data); 
$myPost = array(); 
foreach ($raw_post_array as $keyval) { 
    $keyval = explode ('=', $keyval); 
    if (count($keyval) == 2) 
     $myPost[$keyval[0]] = urldecode($keyval[1]); 
} 
// read the post from PayPal system and add 'cmd' 
$req = 'cmd=_notify-validate'; 
if(function_exists('get_magic_quotes_gpc')) { 
    $get_magic_quotes_exists = true; 
} 
foreach ($myPost as $key => $value) { 
    if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { 
     $value = urlencode(stripslashes($value)); 
    } else { 
     $value = urlencode($value); 
    } 
    $req .= "&$key=$value"; 
} 
// Post IPN data back to PayPal to validate the IPN data is genuine 
// Without this step anyone can fake IPN data 
if(USE_SANDBOX == true) { 
    $paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; 
} else { 
    $paypal_url = "https://www.paypal.com/cgi-bin/webscr"; 
} 
$ch = curl_init($paypal_url); 
if ($ch == FALSE) { 
    return FALSE; 
} 
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $req); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); 
if(DEBUG == true) { 
    curl_setopt($ch, CURLOPT_HEADER, 1); 
    curl_setopt($ch, CURLINFO_HEADER_OUT, 1); 
} 
// Set TCP timeout to 30 seconds 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); 
$res = curl_exec($ch); 
if (curl_errno($ch) != 0) // cURL error 
    { 
    if(DEBUG == true) { 
     error_log(date('[Y-m-d H:i e] '). "Can't connect to PayPal to validate IPN message: " . curl_error($ch) . PHP_EOL, 3, LOG_FILE); 
    } 
    curl_close($ch); 
    exit; 
} else { 
     // Log the entire HTTP response if debug is switched on. 
     if(DEBUG == true) { 
      error_log(date('[Y-m-d H:i e] '). "HTTP request of validation request:". curl_getinfo($ch, CURLINFO_HEADER_OUT) ." for IPN payload: $req" . PHP_EOL, 3, LOG_FILE); 
      error_log(date('[Y-m-d H:i e] '). "HTTP response of validation request: $res" . PHP_EOL, 3, LOG_FILE); 
      // Split response headers and payload 
      list($headers, $res) = explode("\r\n\r\n", $res, 2); 
     } 
     curl_close($ch); 
} 
// Inspect IPN validation result and act accordingly 
if (strcmp ($res, "VERIFIED") == 0) { 
    if(DEBUG == true) { 
     error_log(date('[Y-m-d H:i e] '). "Verified IPN: $req ". PHP_EOL, 3, LOG_FILE); 
    } 
} else if (strcmp ($res, "INVALID") == 0) { 
    if(DEBUG == true) { 
     error_log(date('[Y-m-d H:i e] '). "Invalid IPN: $req" . PHP_EOL, 3, LOG_FILE); 
    } 
} 

내가 전에 말했듯이, VERIFIED _donations 반환하지만 _xclick - 구독의 cmd를 값이 데이터 INVALID 반환합니다. 여기에 반환되는 데이터의 예가 있습니다.

cmd=_notify-validate&txn_type=subscr_signup&subscr_id=I-SFYTVAKSSYGK&last_name=lastname&residence_country=US&mc_currency=USD&item_name=Monthly+Sub&business=mail%40url.com&amount3=10.00&recurring=1&address_street=1+Main+St&payer_status=verified&payer_email=name%40email.com&address_status=confirmed&first_name=firstname&receiver_email=mail%40url.com&address_country_code=US&payer_id=SYPW3V3BVWTJW&address_city=San+Jose&reattempt=1&address_state=CA&subscr_date=07%3A33%3A13+Aug+27%2C+2014+PDT&address_zip=95131&charset=windows-1252&period3=1+M&address_country=United+States&mc_amount3=10.00&address_name=firstname+lastname&auth=AwIHoldf-BK2GZqtPhPo0O2g3go74cV9ZOLRYhHTJdKDM5EP0YHuqHLo23RYPfQs-3YDnvhjVf.J3AtydGfvDfA&form_charset=UTF-8 

는 솔직히 여기에 밖으로 그래서 일체의 도움을 크게 감사에서 어디로 가야에 관한 단서가 없다!

+0

같은 문제가 있습니다. 누구나 해결책이 있습니까? –

+0

@MangirdasSkripka 나는 내 문제가 무엇인지 알아 냈다. 나는 새 사이트에서 개발하고 있기 때문에 웹 사이트를 볼 수 없도록 내 IP를 차단하는 htaccess를 가졌다. paypal이 데이터를 게시하는 데 사용하는 IP를 가져 오기 위해 IPN 시뮬레이션 테스트를 한 후에 나는 그들 모두를 가지고 있다고 생각했습니다. 나는 샌드 뱅크스가 서브 스크립 션 기반 지불에 사용하는 것을 놓쳤다. 이유는 모르겠다. 한번 지불하는 것과는 다르다. 일단 내가 그것을 발견, 그것을 통해 바로 갔다. 따라서 htaccess를 사용하여 들어오는 ips를 차단하는 경우 오류 로그뿐만 아니라이를 다시 확인하십시오. –

답변

0

테스트의 또 다른 하루가 끝나고 특정 문제의 원인을 파악했습니다. Paypal은 샌드 박스에서 서버로 정보를 게시하는 데 여러 IP를 사용하는 것을 좋아합니다. htaccess를 사용하여 웹 사이트를 보는 것에서 내 IP 주소를 제외한 모든 것을 차단합니다. (서버가 있지만 실제로 살기에 가까워서 웹 사이트를 열지 못하게하는 것이 마지막입니다.) 내가 Paypal 샌드 박스 IP라고 생각한 것을 잡은 후에 htaccess에서 IP를 열었습니다. Paypal은 일회성 지불 방법에 비해 구독 방법에서 데이터를 게시하는 데 다른 IP를 사용합니다. 일단 그것을 발견하고 IP에 htaccess를 추가하면 문제가 사라졌습니다.