Php 如何在paypal ipn中获取我添加的隐藏字段?
我被这件事难住了。我没有得到我的这两个隐藏字段,其余的我得到所有数据。谁能帮我一下我做错了什么。这是我的paypal表单:-Php 如何在paypal ipn中获取我添加的隐藏字段?,php,laravel,paypal,paypal-ipn,Php,Laravel,Paypal,Paypal Ipn,我被这件事难住了。我没有得到我的这两个隐藏字段,其余的我得到所有数据。谁能帮我一下我做错了什么。这是我的paypal表单:- <form id="paypalForm" action="<?php echo $paypalURL; ?>" target="_blank" name="paypalform" method="post" style="display: none;" > <!-- Identify your business so that you c
<form id="paypalForm" action="<?php echo $paypalURL; ?>" target="_blank" name="paypalform" method="post" style="display: none;" >
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="<?php echo $paypalID; ?>">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="{{ $serviceName }}">
<input type="hidden" name="item_number" value="<?php echo $cartId; ?>">
<input type="hidden" name="amount">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="auto_renew" value="no">
<input type="hidden" name="email_pref" value="no">
<input type='hidden' name='notify_url' value="{{ url('/ipn-paypal-success') }}">
<input type='hidden' name='cancel_return' value="{{ url('/paypal-cancel') }}">
<input type='hidden' name='return' value="{{ url('/paypal-sucess') }}">
<div class="form-group">
<label class="col-xs-3 col-form-label"></label>
<div class="col-xs-9">
<input id="paypalsubmit" type="button" value="Proceed to Payment" class="btn btn-payment-btn" />
</div>
</div>
</form>
请求的内容和顺序受php.ini中的变量\u顺序
指令的影响
为什么不使用Laravel请求
确保有use\Http\Request代码>控制器顶部
public function ipnPaypalSucess(Request $request){
$data = $request->all();
mail('my-test-email@gmail.com', 'array data', '<pre>'.print_r($data, true).'</pre>');
}
如果显示所有输入字段,则将代码替换为:
<input type="hidden" name="custom" value="custom value(s) go here" />
公共功能IPNPayPalsuces(请求$Request){
$data=$request->all();
邮件测试-email@gmail.com“,”数组数据“,”.print_r($data,true)。”;
public function ipnPaypalSucess(Request $request){
return $request->all();
}
}
您不能只将自己的字段添加到PayPal按钮,然后期望这些字段以IPN的形式返回。有一个单独的字段用于此,它的字面意思是“自定义”。这就是你需要做的:
您在该字段中放置的任何内容都将在IPN侦听器中的$\u REQUEST['custom']
中返回
当您有多个字段时,您可以在自定义参数中放置一个NVP字符串,然后在IPN脚本中重新解析它。或者,您可以将所有自定义数据存储在数据库中,然后在自定义参数中传递一个记录ID,这样您就可以根据IPN脚本中的记录ID将该数据拉回来
<input type="hidden" name="custom" value="custom value(s) go here" />