I've been using PayPal's IPN to handle transactions. I wanted to build a invoice search tool to be able to search through older or current user payments for various reasons. I spent some time today setting up the PayPal PHP REST API SDK to facilitate this and did the following.
I generate an AccessToken via the OAuthTokenCredential object, which requires an instance of the config .
$config = PayPal\Core\PayPalConfigManager::getInstance()->getConfigHashmap();
$oauth_credential->getAccessToken($config);
I create an ApiContext using the primed OAuthTokenCredential.
$api_context = new PayPal\Rest\ApiContext($oauth_credential);
I create a search object using a broad date span that I'm 100% sure should return results.
$search = new PayPal\Api\Search(
'{
"start_invoice_date" : "2014-12-01 PST",
"end_invoice_date" : "2015-01-01 PST",
"page" : 1,
"page_size" : 20,
"total_count_required" : true
}'
);
I then do an invoice search utilizing both my search object and API context
$invoices = PayPal\Api\Invoice::search($search, $api_context);
There are no errors and everything runs fine. The issue is that I get no results back in the $invoices
object. It acts as if I just created a new account and have no invoices. I get the feeling I'm missing a setting somewhere, Used an inappropriate API call for what I want to do, or that I should be using one of their other APIs .
Usually the classic and REST architecture in PayPal works independently and cannot be always used together. For instance, you cannot use REST API
to search for a transaction ran using Classic API
and vice versa.