com.paypal.core.rest.PayPalRESTException:读取超时



我在项目中使用贝宝付款。它适用于签证卡万事达卡

private def doFinalPayment(payment: Payment, payer: Payer, accessToken: String): Payment = {    
val apiContext = new  APIContext(accessToken)  
var objPay=payment   
apiContext.setConfigurationMap(sdkConfig)   
try {
      objPay = objPay.create(apiContext)//Exception Occur here
      // some code here...........
       } catch {
     case e: PayPalRESTException => {
       println("EXCEPTION IN DO FINAL PAYMENT METHOD")
       val msg = e.getMessage
       println(e)
       println(msg)
     }   
   }    
objPay 
}

但使用美国运通&发现卡,它给了我以下例外:

EXCEPTION IN DO FINAL PAYMENT METHOD  
com.paypal.core.rest.PayPalRESTException:Read timed out
Read timed out

我正在使用这些库依赖项。。。。。。

"com.paypal.sdk" % "paypal-core" % "1.5.2",
  "com.paypal.sdk" % "rest-api-sdk" % "0.7.1",
  "com.paypal.sdk" % "invoicesdk" % "2.4.106",
  "com.paypal.sdk" % "adaptivepaymentssdk" % "2.5.106",
  "com.paypal.sdk" % "adaptiveaccountssdk" % "2.4.106",
  "com.paypal.sdk" % "permissionssdk" % "2.3.106",
  "com.stripe" % "stripe-java" % "1.7.1",
  "com.sparkjava" % "spark-core" % "1.1.1",
   "com.paypal.sdk" % "merchantsdk" % "2.1.96"

美国运通和Discover有时处理时间更长。如果使用REST SDK作为基础,http.connectiontimeout变量将设置为30秒。你应该将其增加到至少60(如果你仍然超时,可能会更高)。

在Scala中,可以设置http.setRequestTimeoutInMs(6000)将超时时间增加到60秒。

SDK示例包括一个bootstrap.php文件,用于设置APIContext。

    // Use an ApiContext object to authenticate 
// API calls. The clientId and clientSecret for the 
// OAuthTokenCredential class can be retrieved from 
// developer.paypal.com
$apiContext = new ApiContext(
    new OAuthTokenCredential(
        '...',
        '...'
    )
);

// #### SDK configuration
// Comment this line out and uncomment the PP_CONFIG_PATH
// 'define' block if you want to use static file 
// based configuration
$apiContext->setConfig(
    array(
        'mode' => 'sandbox',
        'http.ConnectionTimeOut' => 30,
        'log.LogEnabled' => true,
        'log.FileName' => '../PayPal.log',
        'log.LogLevel' => 'FINE'
    )
);

http。ConnectionTimeOut字段是您要查找的位置。将其设置为60或更高。

相关内容

  • 没有找到相关文章

最新更新