Executing payment always times out

elijah_carrel
New Community Member

Hello,

 

I'm using the express checkout button, and trying to authorize the payment on the client side and execute it on the server side. (As I understand it, if I were to execute on the client side, users can easily look at my JS code and "spoof" paying for something without actually paying for it, just by running the code following `return actions.payment.execute().then(function() `, which is why I decided to do this.) My server side is in PHP, and the code is as follows. I am in sandbox. However, the server side execution is always timing out (returning a 504 HTTP error code), and so I cannot figure out the error. Going to look at the API calls I've made, I see several calls listed as errors, but I cannot see more information. (Side question: how can I see more information about each call?)

 

Thanks so much for any help you can provide!

 

<?php

require_once('/home/smbeadna/public_html/return_response.func.php');
require('/home/smbeadna/PayPal-PHP-SDK/autoload.php');

$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'<clientID>', // ClientID
'<clientSecret>' // ClientSecret
)
);
use PayPal\Api\Amount; use PayPal\Api\Details; use PayPal\Api\Payment; use PayPal\Api\PaymentExecution; use PayPal\Api\Transaction; $paymentId = $_GET['payment_id']; $payment = Payment::get($paymentId, $apiContext); $execution = new PaymentExecution(); $execution->setPayerId($_GET['payer_id']); $transaction = new Transaction(); $amount = new Amount(); $details = new Details(); $amount->setCurrency('USD'); $amount->setTotal($_GET['fee']); $transaction->setAmount($amount); $execution->addTransaction($transaction); $response = array(); try { $result = $payment->execute($execution, $apiContext); try { $payment = Payment::get($paymentId, $apiContext); } catch (Exception $ex) { $response['success'] = false; $response['error'] = $ex; $response['error_code'] = $ex->getCode(); $response['error_data'] = $ex->getData(); return_response($response); } } catch (PayPal\Exception\PayPalConnectionException $ex) { $response['success'] = false; $response['error'] = $ex; $response['error_code'] = $ex->getCode(); $response['error_data'] = $ex->getData(); return_response($response); } catch (Exception $ex) { $response['success'] = false; $response['error'] = $ex; $response['error_code'] = $ex->getCode(); $response['error_data'] = $ex->getData(); return_response($response); } $response['success'] = true; return_response($response); ?>

 

Login to Me Too
1 REPLY 1

MTS_Andre
Moderator
Moderator

Hi, can you post the full response where we should see the PayPal DebugID or Correltaion ID. This will help in debugging the error.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.