0

I have successfully utilized PayPal-PHP-SKD to request a payment sending the user to the PayPal payment gateway sandbox with credentials and sandbox buyer account etc. Everything works and I get a request to the returnURL with $_GET variables success=true, paymentID, token and PayerID. My problem is in the next step which captures the paymentID and PayerID, creates objects for Payment PaymentExecution which seems to work OK but crashes when I execute the line "result = $payment->execute($exClaimPayment, $mPPcredentials);". If I comment out that line, the code works without error but when I include it the code crashes.

"result = $payment->execute($exClaimPayment, $mPPcredentials);"

if (isset($_GET['success'], $_GET['paymentId'], $_GET['PayerID'])) {
    if ($_GET['success'] == 'true') {
        $mSuccess = TRUE;
        $mPaymentID = $_GET['paymentId'];
        $mPayerID = $_GET['PayerID'];
        $payment = Payment::get($mPaymentID, $mPPcredentials);
        $exClaimPayment = New PaymentExecution();
        $exClaimPayment->setPayerId($mPayerID);
        $mProgress = 'in success after $exClaimPayment->setPayerId($mPayerID)';
        try {
            $mProgress = 'in try';
            //result = $payment->execute($exClaimPayment, $mPPcredentials);
        } catch(Exception $ex){
            $errorMsg = json_decode($ex->getData());
        }
    }
} else { 
    $mSuccess = FALSE; 
    $mProgress = 'in NOT success';
}

In my envoronment, Win 10, Notepad++, FileZilla, Hostmonnster hosting and Chrome, I cannot see the error. It just crashes (with HTTP 500 ??)

  • Check your error logs on your server. – Jonnix Aug 30 '19 at 17:01
  • Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – aynber Aug 30 '19 at 17:24
  • Thanks for the suggestions on finding PHP errors. My previous method was to add only the slightest changes, ideally only one line, upload to server and run it. I try to minimize the number of technologies I use so the server error_log looks like a good option. – John A Brown Sep 01 '19 at 16:39

1 Answers1

0

I found my error! It was MY error. The line: result = $payment->execute($exClaimPayment, $mPPcredentials); Should have been: $result = $payment->execute($exClaimPayment, $mPPcredentials); I have worked on this code for half a day and did not see my error until 5 minutes after I posted the question on StackOverflow. My conspicuous errors in PHP often cost me a lot of time. I would benefit from an environment that would point out my syntax errors. StackOverflow is a very good resource. Thanks!

  • Get yourself a good IDE/Editor with syntax highlighting and error checking. It will save you a lot of headaches in the long run. – aynber Aug 30 '19 at 17:24