I am using paypal for payment in my project. It works for visa card and mastercard and payment was successfully done.
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
}
But with American Express & Discover card it gives me the following exception:
EXCEPTION IN DO FINAL PAYMENT METHOD
com.paypal.core.rest.PayPalRESTException:Read timed out
Read timed out
I am using these library dependencies......
"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"
American Express and Discover sometimes have longer processing times. If you are using the REST SDK as your base, the http.connectiontimeout variable is set to 30 seconds. You should increase that to at least 60 (and possibly higher if you still get timeouts).
In Scala, you can set http.setRequestTimeoutInMs(6000) to increase the timeout to 60 seconds.
The SDK samples include a bootstrap.php file that sets an 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'
)
);
The http.ConnectionTimeOut field is where you want to look. Set that to 60 or higher.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With