且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Paypal Rest API解决400错误的请求错误

更新时间:2021-08-05 07:28:06

如果给定数据中出现任何错误,paypal api将返回400-错误的请求错误.

If anything goes wrong in the data given, paypal api will return a 400 - Bad request error.

当我收到错误(PHP SDK)时,我捕获了异常,并且$ex->getData()返回了一个json,其中包含有关错误请求的详细信息,在我的情况下,我给出的货币代码是错误的.

When I got the error(PHP SDK), I caught the exception and $ex->getData() returned a json which contains the details about the bad request, in my case the currency code I given was wrong.

    try {
        $payment->create($apiContext);
    } catch (PayPal\Exception\PPConnectionException $ex) {
        var_dump(json_decode($ex->getData()));
        exit(1);
    }