Jump to content

PHP PayPal SDK Help

HUD
Go to solution Solved by HUD,

Link me that docs, but check for sure if your error reporting is working. Without that it can be irritating. You can also post me your code where you using Sale::get.

 

 

I've actually fixed it now, I decided to re-code the whole page not sure what I did wrong.

Hey, so I've been working on a PayPal checkout system, I finished my return success URL.. and the page doesn't show anything, no matter what. Also doesn't give me any errors (I checked the error log), and as-well checked with phpcodechecker.com and nothing.

 

Here's my coding:

 

<?phpuse PayPal\Api\Payment;use PayPal\Api\PaymentExecution;   require '../src/start.php';         // Sanitize just in case?      $approved = htmlspecialchars($_GET['approved']);      $package = htmlspecialchars($_GET['package']);      $userID = htmlspecialchars($_GET['userID']);      $secretHash = htmlspecialchars($_GET['secretHash']);       if (isset($approved) && isset($package) && isset($userID) && isset($secretHash)) {           // Encrypt these        $userID_enc = openssl_digest(''.$user->ID.'', 'sha512');        $secretHash_enc = openssl_digest(''.$user->privHash.'', 'sha512');           // Verify the $_GETs        $approved_check = $approved === 'true';        $package_check = $package === $package;        $userID_check = $userID === $userID_enc;        $secretHash_check = $secretHash === $secretHash_enc;           if ($approved_check && $package_check && $userID_check && $secretHash_check) {               $payerId = $_GET['PayerID'];               // Get payment_id from database               $paymentId = $db->prepare("                  SELECT payment_id                  FROM transactions_paypal                  WHERE hash = :hash              ");               $paymentId->execute([                    'hash' => $_SESSION['paypal_hash']                ]);                   // Update Transaction              $updateTransaction = $db->prepare("                    UPDATE transactions_paypal                    SET status = 'paid'                    WHERE payment_id = :payment_id              ");               $updateTransaction->execute([                    'payment_id' => $payment_id                ]);                 $payment = $paymentId->fetchObject()->payment_id;                   // Accept payment                $payment = Payment::get($paymentId, $api);                   // Charge User                $execution = new PaymentExecution();                $execution->setPayerId($payerId);                 $payment->execute($execution, $api);           } else {              echo "Something went wrong.";          }      } else {          echo "Seomething went wrong.";      }
Link to comment
Share on other sites

Link to post
Share on other sites

Looking for this ASAP, gladly appreciate any help. <3

 

I've also updated the code so it finalizes the PayPal checkout.. but still no results are even showing. My payment.php processing page works fine, but not this page.

Link to comment
Share on other sites

Link to post
Share on other sites

What result do you expect, if there are no errors then you will se nothing cause nothing is printed out, and you are saying that it processes paypal notification successfully - than it works, what else to worry about?

Link to comment
Share on other sites

Link to post
Share on other sites

What result do you expect, if there are no errors then you will se nothing cause nothing is printed out, and you are saying that it processes paypal notification successfully - than it works, what else to worry about?

 

Ah, I removed it on the thread because I edited it. I had:

 

var_dump($payerId);
Link to comment
Share on other sites

Link to post
Share on other sites

do you do that after this line?: 

$payerId = $_GET['PayerID'];

try to echo something just after <?PHP, if it prints anything than try that every next line ans see at what point there is noting printed out.

 

And in the meantime you can think about this line:

$package_check = $package === $package;

probably a typo but it will be always true.

Link to comment
Share on other sites

Link to post
Share on other sites

do you do that after this line?: 

$payerId = $_GET['PayerID'];

try to echo something just after <?PHP, if it prints anything than try that every next line ans see at what point there is noting printed out.

 

And in the meantime you can think about this line:

$package_check = $package === $package;

probably a typo but it will be always true.

 

 

Thanks, just looked into it but wasn't the problem. Still can't find it. Nothing prints if I echo something after starting tags @ line 1.

 

$package_check = $package;

 

That's what the code should be... still doesn't do anything.

Link to comment
Share on other sites

Link to post
Share on other sites

do you do that after this line?: 

$payerId = $_GET['PayerID'];

try to echo something just after <?PHP, if it prints anything than try that every next line ans see at what point there is noting printed out.

 

And in the meantime you can think about this line:

$package_check = $package === $package;

probably a typo but it will be always true.

 

Figured it out to be: 

 

$payment = Payment::get($paymentId, $api);

 

Going to check the documentation real fast.

Link to comment
Share on other sites

Link to post
Share on other sites

--snip--

 

If there is nothing printing out then you probably have an error when parsing php script, and you don't get it because of configuration. You can test by creating simple php file with intentional error in it, and see if php will display errors.

Link to comment
Share on other sites

Link to post
Share on other sites

If there is nothing printing out then you probably have an error when parsing php script, and you don't get it because of configuration. You can test by creating simple php file with intentional error in it, and see if php will display errors.

 

 

According to the documentations & examples it needs to be : 

(Which it didn't work).

use PayPal\Api\Sale;$payment = Sale::get($paymentId, $api);
Link to comment
Share on other sites

Link to post
Share on other sites

Link me that docs, but check for sure if your error reporting is working. Without that it can be irritating. You can also post me your code where you using Sale::get.

Link to comment
Share on other sites

Link to post
Share on other sites

Link me that docs, but check for sure if your error reporting is working. Without that it can be irritating. You can also post me your code where you using Sale::get.

 

 

I've actually fixed it now, I decided to re-code the whole page not sure what I did wrong.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×