sdk-php icon indicating copy to clipboard operation
sdk-php copied to clipboard

SDK not working, a lot of errors.

Open rajasajidmanzoor opened this issue 10 years ago • 14 comments

Hello, I have following code in my php

` require_once 'sdk/autoload.php'; // Make sure this path is correct. $transaction = new AuthorizeNetAIM ('APILOGIN', 'APIkey'); $transaction->amount = '9.99'; $transaction->card_num = '4007000000027'; $transaction->exp_date = '10/16';

$response = $transaction->authorizeAndCapture ();

if ($response->approved) { echo "

Success! The test credit card has been charged!

"; echo "Transaction ID: " . $response->transaction_id; } else { echo $response->error_message; } `

and it is showing following warning..

Warning: include(C:\wamp\www\invoice\sdk/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php): failed to open stream: No such file or directory in C:\wamp\www\invoice\sdk\autoload.php on line 16

Warning: include(): Failed opening 'C:\wamp\www\invoice\sdk/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\invoice\sdk\autoload.php on line 16

Fatal error: Class 'JMS\Serializer\Annotation\Type' not found in C:\wamp\www\invoice\sdk\lib\net\authorize\util\SensitiveDataConfigType.php on line 6

Please tell me how can i fix this.

rajasajidmanzoor avatar Sep 24 '16 22:09 rajasajidmanzoor

The fiest line in code should be require_once 'sdk/vendor/autoload.php'

ashtru avatar Sep 25 '16 12:09 ashtru

still it is having same errors because there is no vendor folder

rajasajidmanzoor avatar Sep 25 '16 16:09 rajasajidmanzoor

Hi

For using sdk/vendor/autoload.php you will need to install composer.

Also, as it seems you are running wamp stack you will need to install composer separately

Hope this helps.

kikmak42 avatar Sep 25 '16 17:09 kikmak42

I know but there is no wiki or documentation available to clone this repository using composer or any other alternative tool..

rajasajidmanzoor avatar Sep 25 '16 17:09 rajasajidmanzoor

If you're familiar with Composer, it's simple:

$ cd path/to/my/project
$ composer require authorizenet/authorizenet

texdc avatar Sep 26 '16 13:09 texdc

Has there been a fix for this? I've been trying all the way back to where the package was named xsd2php from another vendor and it's seriously broken through and through.. What's the secret here? Stability on file is dev.

Problem 1
    - Installation request for authorizenet/authorizenet ^1.9 -> satisfiable by authorizenet/authorizenet[1.9.0].
    - authorizenet/authorizenet 1.9.0 requires jms/serializer serializer-master-dev as 1.0 -> no matching package found.

RyanThompson avatar Oct 31 '16 17:10 RyanThompson

Relevant bits from my composer.json:

    ...
    "require": {
        ...
        "jms/serializer": "serializer-master-dev as 1.0",
        "authorizenet/authorizenet": "^1.8.9",
        ...
    },
    ...
    "repositories": [{
        "type": "vcs",
        "url": "https://github.com/goetas/serializer.git"
    }]
    ...

pdbreen avatar Oct 31 '16 17:10 pdbreen

Holy smokes you saved me - thank you @pdbreen !

RyanThompson avatar Oct 31 '16 17:10 RyanThompson

It seems we do need Composer, even though the php sample code section has:

What if I'm not using Composer? We provide a custom SPL autoloader, just download the SDK.:

require 'path/to/anet_php_sdk/autoload.php';

Time to "get familiar" with Composer...

ghost avatar Nov 13 '16 12:11 ghost

1st try crashed and burned. Any help would be appreciated as I'm still not too familiar with Composer.

I went to the directory where I want to include the authorize files, and ran php /path/composer.phar require authorizenet/authorizenet

OUTPUT

Using version ^1.9 for authorizenet/authorizenet ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.

Problem 1 - Installation request for authorizenet/authorizenet ^1.9 -> satisfiable by authorizenet/authorizenet[1.9.0]. - authorizenet/authorizenet 1.9.0 requires jms/serializer serializer-master-dev as 1.0 -> no matching package found.

Potential causes:

  • A typo in the package name
  • The package is not available in a stable-enough version according to your minimum-stability setting see https://getcomposer.org/doc/04-schema.md#minimum-stability for more details.

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, deleting ./composer.json.

ghost avatar Nov 13 '16 14:11 ghost

Looks like I got it by basically following the SDK instructions- clone repo, change composer.json to

{ "require": { "php": ">=5.5", "ext-curl": "*", "authorizenet/authorizenet": "1.8.9", "jms/serializer": "serializer-master-dev as 1.0", "symfony/yaml": "^3.1" }, "repositories": [{ "type": "vcs", "url": "https://github.com/goetas/serializer.git" }] }

and run composer update.

BUT - I had to add back the "symfony/yaml": "^3.1" line as that's not in the instructions.

ghost avatar Nov 13 '16 14:11 ghost

I've done the above, I'm brand new to composer... Finally got authorizenet SDK installed through composer. How do I reference it in my code? require vendor/autoload.php spits out

Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\phplod\bids\payment.php on line 9

Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\phplod\bids\payment.php on line 9

Do I have to have the composer.json in the same directory or something?

BenGeocth avatar Nov 28 '16 03:11 BenGeocth

here's what works for me, but it depends on where the calling script and vendor folder are located. my calling script is in myproject/dir1 so i had to pop the last element off the array to properly define my APP_ROOT.

$rpp = explode('/', DIR); // the magic constant directory (http://php.net/manual/en/language.constants.predefined.php) - github is bolding and removing underscores array_pop($rpp); define('APP_ROOT', implode('/', $rpp).'/' );

require APP_ROOT . 'vendor/autoload.php';

ghost avatar Nov 28 '16 13:11 ghost

We've reduced the dependency list in latest release, composer.json plus removed the need for a github reference, all dependencies are in packagist.

brianmc avatar Dec 05 '16 07:12 brianmc