Reply
Highlighted
New Member
Posts: 2
Registered: ‎03-23-2020

PHP SDK issue

Hello,

 

I've got the SDK installed via Composer and here is the path:

 

/anet_php_sdk/vendor/autoload.php

 

I'm loading it like this:

 

require $_SERVER["DOCUMENT_ROOT"].'/anet_php_sdk/vendor/autoload.php';

 

There are no load errors and I checked by changing "vendor" to "vendors" and it gave an error.

 

So now I'm trying to set the API credentials as per https://github.com/AuthorizeNet/sdk-php like so:

 

use net\authorize\api\contract\v1 as AnetAPI;

 

but when I test the page I get this:

 

Parse error: syntax error, unexpected 'use' (T_USE) in /path/to/file/file.php on line 209

 

Any thoughts are greatly appreciated.

 

Chris

Highlighted
New Member
Posts: 2
Registered: ‎03-23-2020

Re: PHP SDK issue

All, I have solved this. For anyone else who may encounter this issue, the "use" code cannot be inside a function, it needs to be available globally.

Highlighted
New Member
Posts: 2
Registered: ‎03-31-2020

Re: PHP SDK issue

Thanks. I will keep that in mind.