douji6461 2017-11-01 07:11
浏览 45
已采纳

Paypal Sandbox没有返回任何变量

I have my code as follows:

    $paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; 
    $paypal_id = 'payments@business.com';

    $str .= "<form method='post' action='".$paypal_url."'>";
    $str .= "<input type='hidden' name='business' value='".$paypal_id."'>";
    $str .= "<input type='hidden' name='cmd' value='_xclick'>";
    $str .= "<input type='hidden' name='item_name' value='Room'>";
    $str .= "<input type='hidden' name='item_number' value='".getRoom($id)."'>";
    $str .= "<input type='hidden' name='currency_code' value='USD'>";
    $str .= "<input type='hidden' name='no_shipping' value='1'>";
    $str .= "<input type='hidden' name='amount' id='paypal_cost' value='".getBal($id)."'>";
    $str .= "<input name='notify_url' value='http://localhost/tropicana/guests/notify.php' type='hidden'>";
    $str .= "<input type='hidden' name='cancel_return' value='http://localhost/tropicana/guests/payments.php'>";
    $str .= "<input type='hidden' name='return' value='http://localhost/tropicana/guests/notify.php'>";
    $str .= "<button type='submit' name='submit' class='form-control btn-danger'>Pay $".getBal($id)." with <i>PayPal</i>";

    $str .= "</form>";

But after a successful payment, my return script notify.php is not receiving any variables.

When i try to print_r() the $_REQUEST, it returns an empty array.

  • 写回答

1条回答 默认 最新

  • dsf6565 2017-11-01 15:58
    关注

    TL;DR: Your notify_url cannot be localhost since PayPal will send you the IPN messages (from outside), which means your development machine must be exposed to internet.

    One way to expose your computer is using a tool like ngrok, or something like serveo, or similar. Once you do that, set your notify_url to that public URL to receive the IPN messages.

    But, be warned:

    • if you use free ngrok option, your random subdomain (ex. 13bf0ee2.ngrok.com) will change on every ngrok re/start
    • if you test subscriptions, your previously created plans with ngrok notify_url won't be valid anymore and you will not receive the recurrent IPN messages.
    • because PayPal sandbox is one big piece of junk, you may not receive IPN messages at all simply because they are totally broken service.

    Of course, you will scratch your head sometimes why things worked yesterday and not today. The best option is to boycott them and move on with your life and business with someone who's actually competent on this field.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问为什么我配置IPsec后PC1 ping不通 PC2,抓包出来数据包也并没有被加密
  • ¥200 求博主教我搞定neo4j简易问答系统,有偿
  • ¥15 nginx的使用与作用
  • ¥100 关于#VijeoCitect#的问题,如何解决?(标签-ar|关键词-数据类型)
  • ¥15 一个矿井排水监控系统的plc梯形图,求各程序段都是什么意思
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要