如何使用PHP在返回页面上获取paypal买家地址

时间:2014-08-21 05:20:10

标签: php paypal street-address city returnurl

我没有得到街道地址,州和城市。 我使用以下代码来获取信息:

<?php
if($_GET['tx']) $tx= $_GET['tx']; 
$identity = '1Y7reMOTMxCY66RFk.......................'; 
$ch = curl_init();
curl_setopt_array($ch, array ( CURLOPT_URL =>
    'https://www.sandbox.paypal.com/cgi-bin/webscr', CURLOPT_POST => TRUE,
    CURLOPT_POSTFIELDS => http_build_query(array ('cmd' => '_notify-synch','tx' => $tx,
    'at' => $identity,)), CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HEADER => FALSE,
    CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false,)); 
$response = curl_exec($ch); 
$status   = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
curl_close($ch); 
if( substr($response, 0, 7) == 'SUCCESS') 
{ 
$response = substr_replace($response, '', 0, 7); 
$response = str_replace(array("\n", "\r", "\r\n"), '&', $response);  
parse_str($response, $response_array);
} 
echo "<pre>"; print_r($response_array); ?>

输出:

Array
(
    [transaction_subject] => 
    [txn_type] => web_accept
    [payment_date] => 21:41:19 Aug 20, 2014 PDT
    [last_name] => Maurya
    [residence_country] => US
    [pending_reason] => address
    [item_name] => THE BOOM
    [payment_gross] => 1495.00
    [mc_currency] => USD
    [business] => arunk-facilitator@hotmail.com
    [payment_type] => instant
    [protection_eligibility] => Ineligible
    [payer_status] => verified
    [fraud_management_pending_filters_1] => Maximum Transaction Amount
    [tax] => 0.00
    [payer_email] => pm.sz@gmail.com
    [txn_id] => 3PU02356JM49....
    [quantity] => 1
    [receiver_email] => arunk-facilitator@hotmail.com
    [first_name] => Prikshit
    [payer_id] => HFKPSNRD...
    [receiver_id] => N4DKWT577...
    [item_number] => 102
    [handling_amount] => 0.00
    [payment_status] => Pending
    [shipping] => 0.00
    [mc_gross] => 1495.00
    [custom] =>
    [charset] => windows-1252
)

1 个答案:

答案 0 :(得分:1)

由于支付按钮,您需要确保变量的值为
按钮代码中的 no_shipping 未设置为1 。如果 no_shipping = 1 通过了你 不会在PDT和IPN中收回送货地址。

您可以在以下网址获取此变量的说明:

https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables#no_shipping