代码娱乐者 2017-06-21 10:23 采纳率: 50%
浏览 2404
已采纳

沙盒paypal在线支付成功后返回非法参数invalid

测试的时候,PayPal一直返回invalid,求大神解答
public void ipn() throws IOException, DaoException {
String res ="";
Enumeration en = context.getRequest().getParameterNames();
String str = "cmd=_notify-validate";
while (en.hasMoreElements()) {
String paramName = (String) en.nextElement();
String paramValue = context.getRequest().getParameter(paramName);
str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue);
}
System.out.println(str);

    URL u = new URL("https://www.sandbox.paypal.com/cgi-bin/webscr");
    URLConnection uc = u.openConnection();
    uc.setDoOutput(true);
    uc.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    PrintWriter pw = new PrintWriter(uc.getOutputStream());
    pw.println(str);
    pw.close();

    BufferedReader in = new BufferedReader(
    new InputStreamReader(uc.getInputStream()));
    res = in.readLine();
    in.close();
    System.out.println(res);
    // assign posted variables to local variables
    String videoId = context.getRequest().getParameter("item_number");
    String paymentAmount = context.getRequest().getParameter("mc_gross");
    String paymentCurrency = context.getRequest().getParameter("mc_currency");
    // check notification validation
    if (res.equals("VERIFIED")) {
        // check that paymentStatus=Completed
        // check that txnId has not been previously processed
        // check that receiverEmail is your Primary PayPal email
        // check that paymentAmount/paymentCurrency are correct
        // process payment


        System.out.println("Success");
    } else if (res.equals("INVALID")) {
        // log for investigation
        System.out.println("invalid Fail");
    } else {
        // error
        System.out.println("Nothing");
    }

}
  • 写回答

2条回答 默认 最新

  • 代码娱乐者 2017-11-27 09:09
    关注

    后来发现是PayPal的账户设置不正确

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记