I use the following code to complete a payment that has been approved by Paypal.com:
// Get the order object $order_object = new Order($_GET["orderid"]); // Complete the payment $payment = Payment::get($order_object->paypal_payment_id, $apiContext); //Set the payer id $order_object->SetPayerId($_GET["PayerID"]); try { // PaymentExecution object includes information necessary // to execute a PayPal account payment. // The payer_id is added to the request query parameters // when the user is redirected from paypal back to your site $execution = new PaymentExecution(); $execution->setPayer_id($_GET["PayerID"]); //Execute the payment // (See bootstrap.php for more on `ApiContext`) $finished_payment = $payment->execute($execution, $apiContext); } catch(PayPal\Exception\PPConnectionException $e) { echo "<p>PPConnectionException - Already executed payment?</p>"; } echo "Payment state: " . $finished_payment->getState() . '<br/>'; echo "Payment ID:" . $finished_payment->getId() . '<br/>';
If I get an order state before it is executed, it returns created , which is ok, but then after executing with this code, it returns with an approved state.
This would be nice if approved meant that the transaction was completed, however, on the developer's toolbar, the transaction shows as completed , as I expected!
Why should the code return approved when it is truly completed ?
thanks
UPDATE: I just checked http://sandbox.paypal.com and logged in as my test seller account and client test account, I used and both also say the transaction is complete. I can prove it, because if I try to re-run the order, it will return a 500 error. This really confuses why it returns inconsistent data ...
Screenshots:
Returning from the code above ...

Type of order on the developer's website ... 
Does approved completed ?
source share