2011-11-19 3 views
0

안녕하세요 PHP하지만 난 PHP에 아주 아주 새로운 해요 무엇을하지 내가 그것을 알아 낸 있다고 생각하지만, 근처에도 아니었다 :)페이팔 IPN 변수 내가 IPN을 설정하는 중이 야

어쨌든 모든 내가 만든 지불이 그 옆에 다음 텍스트 파일에있는 사람의 이름을 작성하고 후에 그냥이

<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 
<input type="hidden" name="cmd" value="_s-xclick"> 
<input type="hidden" name="hosted_button_id" value="5ES3TSKJNLJ24"> 
<table style="text-align: right; width: 100%;"> 
<tr><td><input type="hidden" name="on0" value="Amount you'd like to donate">Amount you'd like to donate</td></tr><tr><td><select name="os0"> 
    <option value="Just the license">Just the license $2.99 USD</option> 
    <option value="A bit more">A bit more $5.99 USD</option> 
    <option value="Two bits more">Two bits more $8.99 USD</option> 
    <option value="A lot more">A lot more $15.00 USD</option> 
    <option value="We love you :)">We love you :) $50.00 USD</option> 
</select> </td></tr> 
<tr><td><input type="hidden" name="on1" value="Primary Phone Gmail">Primary Phone Gmail</td></tr><tr><td><input type="text" name="os1" maxlength="200"></td></tr> 
</table> 
<input type="hidden" name="currency_code" value="USD"> 
<input type="image" align="right" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
</form> 

처럼 보이는 내 단추에서 만든 텍스트 필드에 자신의 입력을 작성하면됩니다 찾고 있어요 내 ipn.php는 다음과 같습니다.

<?php 
// Revision Notes 
// 11/04/11 - changed post back url from https://www.paypal.com/cgi-bin/webscr to https://ipnpb.paypal.com/cgi-bin/webscr 
// For more info see below: 
// https://www.x.com/content/bulletin-ip-address-expansion-paypal-services 
// "ACTION REQUIRED: if you are using IPN (Instant Payment Notification) for Order Management and your IPN listener script is behind a firewall that uses ACL (Access Control List) rules which restrict outbound traffic to a limited number of IP addresses, then you may need to do one of the following: 
// To continue posting back to https://www.paypal.com to perform IPN validation you will need to update your firewall ACL to allow outbound access to *any* IP address for the servers that host your IPN script 
// OR Alternatively, you will need to modify your IPN script to post back IPNs to the newly created URL https://ipnpb.paypal.com using HTTPS (port 443) and update firewall ACL rules to allow outbound access to the ipnpb.paypal.com IP ranges (see end of message)." 


// read the post from PayPal system and add 'cmd' 
$req = 'cmd=_notify-validate'; 

foreach ($_POST as $key => $value) { 
$value = urlencode(stripslashes($value)); 
$req .= "&$key=$value"; 
} 

// post back to PayPal system to validate 

$header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; 

    // If testing on Sandbox use: 
    // $header .= "Host: www.sandbox.paypal.com:443\r\n"; 
$header .= "Host: ipnpb.paypal.com:443\r\n"; 
$header .= "Content-Type: application/x-www-form-urlencoded\r\n"; 
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; 

    // If testing on Sandbox use: 
    //$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); 
$fp = fsockopen ('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30); 

// assign posted variables to local variables 
$item_name = $_POST['item_name']; 
$item_number = $_POST['item_number']; 
$payment_status = $_POST['payment_status']; 
$payment_amount = $_POST['mc_gross']; 
$payment_currency = $_POST['mc_currency']; 
$txn_id = $_POST['txn_id']; 
$receiver_email = $_POST['receiver_email']; 
$payer_email = $_POST['payer_email']; 
$payer_firstName = $_POST['first_name']; 
$payer_lastName = $_POST['last_name']; 
$gmail = $_POST['on1']; 

//set email variables 
$From_email = "From: [email protected]"; 
$Subject_line = "Thanks for your purchase"; 

$email_msg = "\n\nThe details of your order are as follows:"; 
$email_msg .= "\n\n" . "Transaction ID: " . $txn_id ; 
$email_msg .= "\n" . "Payment Date: " . $payment_date; 

if (!$fp) { 
// HTTP ERROR 
} else { 
fputs ($fp, $header . $req); 
while (!feof($fp)) { 
$res = fgets ($fp, 1024); 
if (strcmp ($res, "VERIFIED") == 0) { 
// check the payment_status is Completed 
// check that txn_id has not been previously processed 
// check that receiver_email is your Primary PayPal email 
// check that payment_amount/payment_currency are correct 
// process payment 

$mail_From = $From_email; 
$mail_To = $payer_email; 
$mail_Subject = $Subject_line; 
$mail_Body = $email_msg; 

mail($mail_To, $mail_Subject, $mail_Body, $mail_From); 

$data = "$payer_firstName $payer_lastName $gmail"; 

$fh = fopen("./paypal/test.txt", "a"); 
fwrite($fh, $data); 
fclose($fh); 

} 
else if (strcmp ($res, "INVALID") == 0) { 
// log for manual investigation 

$mail_From = $From_email; 
$mail_To = $receiver_email; 
$mail_Subject = "INVALID IPN POST"; 
$mail_Body = "INVALID IPN POST. The raw POST string is below.\n\n" . $req; 

mail($mail_To, $mail_Subject, $mail_Body, $mail_From); 

} 
} 
fclose ($fp); 
} 
?> 
+0

왜 마법의 따옴표를 확인하고 있니? 이 옵션은 더 이상 사용되지 않으며 아무도이 옵션을 사용하지 않아야합니다. 이렇게하면 코드가 복잡해집니다. –

+0

나는 paypal에서 예제를 복사하여 붙여 넣었습니다. 솔직히 많은 PHP를 몰라서 문제가 생겼습니다. 내 PHP 지식의 연장은 텍스트 파일을 작성 중입니다 :) – user577732

+0

조금만 더 잘하면 내 질문을 업데이 트 내가 할 노력하고있어 그들이 지불 한 후 자신의 이름과 라인에 텍스트 필드의 입력을 작성하는 것입니다 txt 파일을 내 서버에 저장하십시오. – user577732

답변

0

이미 다 알아 냈어. 하루 종일 데리고 다녔다. (오전 3시 40 분에 작동했다.) 하루 만에 많은 PHP를 배웠다. 내가 몇 푼했는지 게시 할 것이다.

+0

이 문제를 어떻게 해결했는지 우리에게 알려주시겠습니까? 현재이 답변은 동일한 문제가있는 다른 사람을 돕지 않습니다. 그렇게하면 질문을 다시 열어 드리겠습니다. 감사. – Kev

+0

죄송합니다. 코드와 웹 사이트가 새로워졌지만, 튜토리얼 http://www.micahcarrick.com/paypal-ipn-with-php.html에 따라 기억하고 있습니다. 일하는. 요점은 paypal의 웹 사이트에서 ipn 스크립트쪽으로 버튼을 가리켜 야합니다. – user577732

관련 문제