2013-12-08 6 views
0

나는 샌드 박스 모드로 페이팔 결제를 통합 한 웹 사이트를 만들고 있습니다. 나는 내 모든 거래를 내 샌드 박스 상인 계정에 PHP 파일을 통해 나열하고 싶습니다. 나는 paypal API의 초보자이지만 sand-boxed 상인 계정의 사용자 이름, 암호 및 서명이 있습니다. 나는 List of PayPal transactions모든 Paypal 거래 ID 목록보기

<?php 
$info = 'USER=[API_USERNAME]' 
     .'&PWD=[API_PASSWORD]' 
     .'&SIGNATURE=[API_SIGNATURE]' 
     .'&METHOD=TransactionSearch' 
     .'&TRANSACTIONCLASS=RECEIVED' 
     .'&STARTDATE=2013-01-08T05:38:48Z' 
     .'&ENDDATE=2013-07-14T05:38:48Z' 
     .'&VERSION=94'; 

$curl = curl_init('https://api-3t.paypal.com/nvp'); 
curl_setopt($curl, CURLOPT_FAILONERROR, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 

curl_setopt($curl, CURLOPT_POSTFIELDS, $info); 
curl_setopt($curl, CURLOPT_HEADER, 0); 
curl_setopt($curl, CURLOPT_POST, 1); 

$result = curl_exec($curl); 

# Bust the string up into an array by the ampersand (&) 
# You could also use parse_str(), but it would most likely limit out 
$result = explode("&", $result); 

# Loop through the new array and further bust up each element by the equal sign (=) 
# and then create a new array with the left side of the equal sign as the key and the right side of the equal sign as the value 
foreach($result as $value){ 
    $value = explode("=", $value); 
    $temp[$value[0]] = $value[1]; 
} 

# At the time of writing this code, there were 11 different types of responses that were returned for each record 
# There may only be 10 records returned, but there will be 110 keys in our array which contain all the different pieces of information for each record 
# Now create a 2 dimensional array with all the information for each record together 
for($i=0; $i<count($temp)/11; $i++){ 
    $returned_array[$i] = array(
     "timestamp"   = urldecode($result["L_TIMESTAMP".$i]), 
     "timezone"   = urldecode($result["L_TIMEZONE".$i]), 
     "type"    = urldecode($result["L_TYPE".$i]), 
     "email"    = urldecode($result["L_EMAIL".$i]), 
     "name"    = urldecode($result["L_NAME".$i]), 
     "transaction_id" = urldecode($result["L_TRANSACTIONID".$i]), 
     "status"   = urldecode($result["L_STATUS".$i]), 
     "amt"    = urldecode($result["L_AMT".$i]), 
     "currency_code"  = urldecode($result["L_CURRENCYCODE".$i]), 
     "fee_amount"  = urldecode($result["L_FEEAMT".$i]), 
     "net_amount"  = urldecode($result["L_NETAMT".$i])); 
} 
?> 

에서 발견 된이 코드를 시도했지만이 난 단지 트랜잭션 ID를 필요 Parse error: syntax error, unexpected '=', expecting ')' in C:\wamp\www\all_transactions.php on line 40 위의 코드는 모든 세부 사항을 제공합니다 생각 말하고있다.

+1

나는 조금 혼란 스럽다. 내 편집자에게 코드를 붙여 넣었고 구문 오류가보고되지 않는 총 33 개의 행만 표시했습니다. PHP로 작업하고 있으므로 [PayPal 용 클래스 라이브러리] (http://www.angelleye.com/download-angell-eye-php-class-library-for-paypal/)를 확인하는 것이 좋습니다. PayPal API 호출은 매우 간단합니다. –

+0

@AndrewAngell 아니, 그 52 줄의 코드. 나는 너의 것을 시도 할 것이다. :) –

+0

@AndrewAngell 나는 당신의 반과 함께 노력했다. 그러나 그 반환 오류 '보안 헤더가 유효하지 않습니다'하지만 내 신임장에 대해 확신합니다. –

답변

0

array에 대해 잘못된 구문을 사용하고 있습니다. 그것은이어야한다 $key => $value

$returned_array[$i] = array(
    "timestamp"   => urldecode($result["L_TIMESTAMP".$i]), 
    "timezone"   => urldecode($result["L_TIMEZONE".$i]), 
    "type"    => urldecode($result["L_TYPE".$i]), 
    "email"    => urldecode($result["L_EMAIL".$i]), 
    "name"    => urldecode($result["L_NAME".$i]), 
    "transaction_id" => urldecode($result["L_TRANSACTIONID".$i]), 
    "status"   => urldecode($result["L_STATUS".$i]), 
    "amt"    => urldecode($result["L_AMT".$i]), 
    "currency_code"  => urldecode($result["L_CURRENCYCODE".$i]), 
    "fee_amount"  => urldecode($result["L_FEEAMT".$i]), 
    "net_amount"  => urldecode($result["L_NETAMT".$i]) 
);