发送一个值给PayPal并让它返回



我已经尝试了一个多星期得到一个值,我发送到贝宝返回。我在网上找到的所有方法都试过了,但都无济于事,而且我几乎没有头发可以拔了……

<form action="https://www.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="XXXXXXXXXXXX">
<input type="hidden" name="custom" value="<?=$pno;?>">
<input type="image" 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>

<form action="https://www.paypal.com/cgi-bin/webscr?custom=<?$pno;?>>" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXXXXXXXXXXX">
<input type="image" 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>

和许多关于这些主题的变化。这些都不起作用。当我尝试分配$_POST['custom']时,它每次都是空的。

客户的PayPal账户是一个商业账户,并且开启了自动返回。

我做错了什么?

对于不使用API的集成,您永远无法依赖任何返回发生,因此这是您的第一个错误。

最好的解决方案是使用以下基于api的集成:https://developer.paypal.com/docs/business/checkout/server-side-api-calls/#server-side-api-calls

你需要两个路由,一个用于'Create Order',一个用于'Capture Order',它们返回JSON。

将路由与以下审批流程配对:https://developer.paypal.com/demo/checkout/#/pattern/server

purchase_unit对象可以包含custom_id https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit_request

最新更新