Lawrence Cooke
Lawrence Cooke

Reputation: 1597

Getting Order details from Paypal API

I am new to Paypal Smart Buttons.

I have been able to successfully make a purchase and when returning to my site , I am able to get ID for the order.

I am wanting to verify the transactionID is a legitimate ID for the next step.

To do this, I am trying to use the PHP SDK

I have created the following code

require  'vendor/autoload.php';

$apiContext = new \PayPal\Rest\ApiContext(
        new \PayPal\Auth\OAuthTokenCredential(
            'sandboxclient',     
            'sandboxsecret'
        )
);

$payment = new \PayPal\Api\Order();

try {
    $payment->get("8T0564921E866114V",$apiContext);
    echo $payment;
}
catch (\PayPal\Exception\PayPalConnectionException $ex) {
    echo $ex->getData();
}

However I receive an error:

{"name":"INVALID_RESOURCE_ID","message":"The requested resource ID was not found","information_link":"https://developer.paypal.com/docs/api/payments/#errors","debug_id":"cae19ebc8e1b1"}```

I tried both the Order API calls and also the Payment API calls, both ended up with the same error. How do I get this to work. Does it matter that I am using the Paypal Sandbox at the moment for this?


Upvotes: 1

Views: 933

Answers (1)

Preston PHX
Preston PHX

Reputation: 30442

It appears you may be using the deprecated v1 PayPal-PHP-SDK.

Do not use that. The v2 Checkout-PHP-SDK should be used.

Upvotes: 1

Related Questions