[英]Paypal subscription “custom” variable issue ( Sandbox )
So I've created a paypal button from their button template creator, I need to send them a custom variable which contains the users ID. 因此,我已经从他们的按钮模板创建者创建了一个贝宝按钮,我需要向他们发送一个包含用户ID的自定义变量。
So I can then use it to further identify the user and update their specific records 因此,我可以使用它进一步识别用户并更新其特定记录
However the template for the button as given by paypal was : 但是,贝宝给出的按钮模板是 :
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="CVWJZN5AALBVJ">
<input type="image" src="https://www.sandbox.paypal.com/en_US/GB/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
And I altered it to: 我将其更改为:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="custom" value="<?php echo $id; ?>">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="CVWJZN5AALBVJ">
<input type="image" src="https://www.sandbox.paypal.com/en_US/GB/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
Essentially just adding this line 本质上只是添加这一行
<input type="hidden" name="custom" value="<?php echo $id; ?>">
But when my IPN is called, I did a var dump and the custom variable is NOT being sent with the other post variables 但是当我的IPN被调用时,我做了一个var dump并且自定义变量没有和其他post变量一起发送
This is the data I'm receiving when I go through the subscription payment ( From the var dump) 这是我通过订阅付款时收到的数据(来自var dump)
Array
(
[txn_type] => subscr_signup
[subscr_id] => I-TUUWHD0V6T4Y
[last_name] => buyer
[residence_country] => GB
[mc_currency] => GBP
[item_name] => premium membership
[business] => dddd-facilitator@hotmail.com
[recurring] => 1
[address_street] => 1 Main Terrace
[verify_sign] => AStwKS3.L4rNUPfkl7TOO9eahVmAABKWlAKqXwDrHAOGmGfwPvaWdtSg
[payer_status] => verified
[test_ipn] => 1
[payer_email] =>dddd-buyer@hotmail.com
[address_status] => confirmed
[first_name] => test
[receiver_email] => dddd-facilitator@hotmail.com
[address_country_code] => GB
[payer_id] => 7RUAE8WJDD4V2
[address_city] => Wolverhampton
[reattempt] => 1
[address_state] => West Midlands
[subscr_date] => 12:42:12 Oct 26, 2015 PDT
[btn_id] => 3228524
[address_zip] => W12 4LQ
[charset] => windows-1252
[notify_version] => 3.8
[period3] => 1 M
[address_country] => United Kingdom
[mc_amount3] => 10.00
[address_name] => test buyer
[ipn_track_id] => 21e04b9a73c5
)
I want to see [custom] => "usersid"
Any pointers? 我想看
[custom] => "usersid"
指针吗?
The problem was that the ID column in the database was in capitals: 问题是数据库中的ID列用大写字母表示:
I had 我有
$id = $row['id'];
when it should have been 什么时候应该
$id = $row['ID'];
The problem is that you use a generated by paypal button ( with id CVWJZN5AALBVJ )! 问题是您使用的是由Paypal生成的按钮(ID为CVWJZN5AALBVJ)! This button submit what you add as parameters inside the paypal administration, not what parameter you add inside button form .
此按钮提交您在贝宝管理中添加为参数的内容,而不是您在按钮form中添加的参数 。 You must use a custom form to submit following this example:
您必须使用自定义表单来提交以下示例:
<form method="post" name="checkout-form" action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="your@paypal_email.com">
<input type="hidden" name="item_name" value="Product Name>
<input type="hidden" name="amount" value="22" >
<input type="hidden" name="item_number" value="65">
<input type="hidden" name="custom" value="YOUR PRODUCT ID OR SOME CUSTOM CODE">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://zoomthe.me/paypalipn/paypal_ipn.php">
<input type="hidden" name="cancel_return" value="http://zoomthe.me/paypal_cancel">
<input type="hidden" name="cbt" value="Product Description">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="notify_url" value="http://zoomthe.me/your_listener_ipn_file.php">
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.