gpt4 book ai didi

Paypal IPN : get Buyer address

转载 作者:太空宇宙 更新时间:2023-11-03 15:42:30 24 4
gpt4 key购买 nike

我已经使用沙箱获取交易后 Paypal IPN 返回的信息。我遇到的问题是 IPN 不发送买家地址信息,但我仍然可以获得买家的名字和姓氏等信息。我也可以毫无问题地获取交易 ID 或商品购买信息。我无法获得的唯一变量是所有买家地址信息,如 $_POST['address_name'] 或 $_POST['address_city']。这是我的 HTML 表单:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type='hidden' value="Montant_Achat" name="amount" />
<input name="currency_code" type="hidden" value="EUR" />
<input name="shipping" type="hidden" value="0.00" />
<input name="tax" type="hidden" value="0.00" />
<input type="hidden" name="cmd" value="_s-xclick">

<input type="hidden" name="hosted_button_id" value="XXXXXXX">
<p>
<input type="hidden" name="on0" value="Durée"><span id="texteDuree">Durée : </span><select id="duree" onchange="changeCustom()" name="os0">

<option value="1 mois" id="30">1 mois €0,01 EUR</option>
<option value="3 mois" id="90">3 mois €15,00 EUR</option>
<option value="6 mois" id="180">6 mois €30,00 EUR</option>

</select>
</p>
<input name="return" type="hidden" value="factures.php" />
<input name="cancel_return" type="hidden" value="paypal_pro.php" />
<input name="notify_url" type="hidden" value="paypal/paypal_notify.php" />

<input name="item_name" type="hidden" value="Nom de votre produit" />
<input name="no_note" type="hidden" value="1" />
<input name="lc" type="hidden" value="FR" />
<input name="bn" type="hidden" value="PP-BuyNowBF" />
<input id="custom" name="custom" type="hidden" value="<?php echo $_SESSION["numUser"]; ?>||30" />

<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="no_shipping" value="2" />
<input type='hidden' name="address_override" value="1">
<input type="image" style="height:auto;" src="https://www.paypalobjects.com/fr_FR/FR/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - la solution de paiement en ligne la plus simple et la plus sécurisée !">

<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">

</form>

这是我的 Paypal 通知文件的开头:

// lire le formulaire provenant du système PayPal et ajouter 'cmd'
$req = 'cmd=_notify-validate';

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

// renvoyer au système PayPal pour validation
$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]);
}
$_req = 'cmd=_notify-validate';
foreach ($myPost 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";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30);

// récupération des informations de paypal
$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'];
$custom = explode("||", $_POST['custom']);
$id_user = $custom[0];
$dureeContrat = $custom[1];



$first_name = $_POST["first_name"];
$last_name = $_POST["last_name"];
$address_city = $_POST["address_city"];
$address_country = $_POST["address_country"];
$address_country_code = $_POST["address_country_code"];
$address_name = $_POST["address_name"];
$address_state = $_POST["address_state"];
$address_street = $_POST["address_street"];
$address_zip = $_POST["address_zip"];

这是 IPN 返回的 $POST 变量:

Key: mc_gross

Key: protection_eligibility

Key: payer_id


Key: tax

Key: payment_date

Key: payment_status

Key: charset

Key: first_name

Key: option_selection1

Key: mc_fee

Key: notify_version

Key: custom

Key: payer_status

Key: business

Key: quantity

Key: verify_sign

Key: payer_email


Key: option_name1
Key: txn_id

Key: payment_type

Key: btn_id

Key: last_name

Key: receiver_email

Key: payment_fee

Key: shipping_discount

Key: insurance_amount

Key: receiver_id

Key: txn_type

Key: item_name


Key: discount
Key: mc_currency

Key: item_number

Key: residence_country

Key: handling_amount

Key: shipping_method

Key: transaction_subject

Key: payment_gross

Key: shipping

Key: ipn_track_id

预先感谢您的帮助。

最佳答案

如果付款信息中包含地址,PayPal 只会发送带有 IPN 通知的地址。否则,它会完全忽略它。

如果在按钮创建过程中您指定不需要运费,这将导致在 IPN 中不退回任何运费。另一种可能是您的订单不需要送货,因此买家只需在结帐时选择不包含他们的送货地址,在这种情况下,PayPal 不会将其发送给您。

关于 Paypal IPN : get Buyer address,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13573193/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com