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);
?>
... View more