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 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出