Sometimes when we get an online donation, the record remains in the "pending" state in CiviCRM even though the payment went through successfully in Paypal. This happens for maybe 1/3 - 1/2 of donations. Is there a solution for this, a way to make sure they are always marked "Completed"?
The way it works with paypal standard is that paypal informs civicrm that the payment has been done in the background via IPN (instant payment notification)
It means that paypal is sending information to a specific page on civicrm with the proper data (eg this payment has been successful) then your server sends these information back to a specific page on paypal to check it's a genuine confirmation and paypal returns a page that confirms it's one
Something in the chain isn't working sometimes. It might be a firewall, your site too loaded, connection issue...
Did you check the log? are you using drupal?