phppaypal

Approved Orders Not Showing Up in PayPal Transaction History


I am using the PayPal API to process payments on my website (it is hosted locally for now).

I create the order with CAPTURE as the intent and once the payment is successfully submitted I get back an APPROVED response. However, the balance on my PayPal account has not been updated nor have the orders been added to my PayPal transaction history (even after days). I am using my LIVE credentials and not the sandbox so that shouldn't be an issue.

I found someone on the PayPal forums with the exact same problem but no response.

Here is my backend code that checks if the order submitted on the client has been approved:

$orderId = $_POST['orderId'];
$url = "https://api.paypal.com/v2/checkout/orders/$orderId";

$headers = array(
  'Content-Type: application/json',
  'Authorization: Basic ' . base64_encode($clientId . ':' . $clientSecret),
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
curl_close($ch);

if ($response) {
  $responseData = json_decode($response, true);
  $orderStatus = $responseData['status'];
  
  if ($orderStatus === 'APPROVED') {
      // this part runs but my PayPal balance does not change
      echo 'SUCCESS';
  }
}

Solution

  • For complete steps, see the standard integration guide.

    After an order is approved it must be captured. The capture request may succeed or fail. You should display a success or failure message to the payer based on this response.

    Use the JS SDK for approval and do this from the onApprove function.