2016-06-20 3 views
2

이 질문에 힙이 요청되었지만 찾을 수있는 답변이 없으며 아무도 도움을받지 못했습니다. 많은 것은 세 살이므로 문제의 일부인지 확실하지 않습니다.Paypal IPN이 샌드 박스에서 계속해서 유효하지 않음을 반환합니다.

나는 샌드 박스를 통해 IPN을 보내 페이팔 IPN 수신기를 테스트 해왔다. IPN이 전송되고 핸드 셰이크가 확인되었지만 청취자에게 반환되는 상태는 항상 유효하지 않습니다. 몇 가지 다른 예제를 시도했지만 아무 것도 작동하지 않습니다. 난 그냥 텍스트 입력, 출력 텍스트, 페이팔에서 확인 상태 및 HTTP 상태 코드 로그인, 바로 다시 내 코드를 제거했습니다

<?php 

define("LOG_FILE", "./ipn.log"); 
define("DEBUG", 0); 
define("USE_SANDBOX", 1); //for testing 

//get raw input 
$stream_input = file_get_contents('php://input'); 
error_log(date('[Y-m-d H:i e] '). $stream_input. PHP_EOL, 3, LOG_FILE); //log result for comparison to return string 

//choose correct URL 
if(USE_SANDBOX == 1) { 
    $paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; 
} else { 
    $paypal_url = "https://www.paypal.com/cgi-bin/webscr"; 
} 

// add cmd for return request 
$return_string = 'cmd=_notify-validate&' . $stream_input; 
error_log(date('[Y-m-d H:i e] '). $return_string. PHP_EOL, 3, LOG_FILE); //log result for comparison 

//cURL setup 
$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, $return_string); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); 
$verification_status = curl_exec($ch); 
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); 

//log result 
error_log(date('[Y-m-d H:i e] '). $verification_status . PHP_EOL, 3, LOG_FILE); 
error_log(date('[Y-m-d H:i e] '). $http_status . PHP_EOL, 3, LOG_FILE); 

//log cURL errors 
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: $return_array" . PHP_EOL, 3, LOG_FILE); 
      error_log(date('[Y-m-d H:i e] '). "HTTP response of validation request: $verification_status" . PHP_EOL, 3, LOG_FILE); 
     } 
     curl_close($ch); 
} 
?> 

을 그리고 이것은 내가 로그에서 얻을 출력 :

[2016-06-20 03:52 America/New_York] payment_type=instant&payment_date=Mon%20Jun%2020%202016%2017%3A50%3A12%20GMT+1000%20%28AUS%20Eastern%20Standard%20Time%29&payment_status=Canceled_Reversal&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&[email protected]&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&[email protected]&[email protected]&[email protected]&residence_country=US&item_name=something&item_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&txn_type=web_accept&txn_id=146655022&notify_version=2.1&parent_txn_id=SOMEPRIORTXNID003&reason_code=other&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AXwY9QNq9ZSeZMzEi6Nyk68hdvbc 
[2016-06-20 03:52 America/New_York] cmd=_notify-validate&payment_type=instant&payment_date=Mon%20Jun%2020%202016%2017%3A50%3A12%20GMT+1000%20%28AUS%20Eastern%20Standard%20Time%29&payment_status=Canceled_Reversal&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&[email protected]&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&[email protected]&[email protected]&[email protected]&residence_country=US&item_name=something&item_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&txn_type=web_accept&txn_id=146655022&notify_version=2.1&parent_txn_id=SOMEPRIORTXNID003&reason_code=other&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AXwY9QNq9ZSeZMzEi6Nyk68hdvbc 
[2016-06-20 03:52 America/New_York] INVALID 
[2016-06-20 03:52 America/New_York] 200 

나는 입력 문자열과 출력 문자열을 서로 테스트했으며 출력 문자열의 시작 부분에 'cmd = _notify-validate &'을 제외하고는 모두 동일합니다. 대부분의 예제처럼 urlencode를 사용하여 배열로 출력을 보내려고했지만 아무런 운이 없었습니다.

제발, 나는 무엇을 놓치고 있습니까?

+1

http://stackoverflow.com/questions/37679022/paypal-ipn-simulator-returning-invalid-butive-followed-the-rules/37755288#37755288 –

+2

그렇지 않습니다. 그것들. 코드는 괜찮습니다. –

+0

아, 멋지다. 어제 나를 미치게 만들었다. 고마워. – Elenchus

답변

1

나는 똑같은 문제를 겪었습니다. 그것은 IPN 시뮬레이터 및 모든 날짜 필드에 오류가있는 것 같습니다. 인코딩이 엉망진창 인 것처럼 보입니다. 즉, 데이터를 확인하고 다시 게시하려고 할 때 PayPal은 메시지가 동일하지 않다고 생각합니다.

모든 날짜 필드를 지우면 작동합니다.

관련 문제