I'm trying to get the PHP Hello World example to work. I downloaded the code from the authorize.net site and I used Composer and the given composer.json
file.
When I run the command composer update, I get a warning message:
Package goetas/xsd2php is abandoned, you should avoid using it. Use goetas-webservices/xsd2php instead.
Package goetas/xsd-reader is abandoned, you should avoid using it. Use goetas-webservices/xsd-reader instead.
I tried running the charge-credit-card.php program in spite of the warning, but I get this error:
Fatal error: Class 'Goetas\Xsd\XsdToPhp\Jms\Handler\BaseTypesHandler' not found in /var/www/public/newsite/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php on line 82
I tried my hand at correcting the composer.json file to get rid of that error, but I only dug myself a deeper hole.
Here's the composer.json file for reference.
{
"require":
{ "php": ">=5.2.0",
"ext-curl": "*",
"authorizenet/authorizenet": "1.8.8",
"jms/serializer": "xsd2php-dev as 0.18.0"},
"require-dev":
{
"goetas/xsd2php": "2.*@dev",
"goetas/xsd-reader": "2.*@dev"},
"repositories":
[{
"type": "vcs",
"url": "https://github.com/goetas/serializer.git"
}]}
And here's the PHP program I am running...
<?php
require 'vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE","phplog");
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("123456789");
$merchantAuthentication->setTransactionKey("abcdefghijklmnop");
$refId = 'ref' . time();
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111" );
$creditCard->setExpirationDate( "2038-12");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
// Create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount(151.51);
$transactionRequestType->setPayment($paymentOne);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId( $refId);
$request->setTransactionRequest($transactionRequestType);
// if I comment out the line below, no error occurs
$controller = new AnetController\CreateTransactionController($request);
// $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
echo "<p>Hello there 10. The reference id is " . $refId . "</p>";
?>
Here is the console output from running composer install
Loading composer repositories with package information
Reading composer.json of jms/serializer (0.16.0)
Reading composer.json of jms/serializer (0.15.0)
Reading composer.json of jms/serializer (0.14.0)
Reading composer.json of jms/serializer (0.13.0)
Reading composer.json of jms/serializer (0.12.0)
Reading composer.json of jms/serializer (0.11.0)
Reading composer.json of jms/serializer (event-sdispatcher)
Reading composer.json of jms/serializer (graph-refactor)
Reading composer.json of jms/serializer (master)
Reading composer.json of jms/serializer (ok-for-lignano)
Reading composer.json of jms/serializer (patch-1)
Reading composer.json of jms/serializer (psr4)
Reading composer.json of jms/serializer (remove-hndl)
Reading composer.json of jms/serializer (serializer-master)
Reading composer.json of jms/serializer (xsd2php)
Updating dependencies (including require-dev)
- Installing doctrine/lexer (v1.0.1)
Loading from cache
- Installing doctrine/annotations (v1.3.0)
Loading from cache
- Installing phpoption/phpoption (1.5.0)
Loading from cache
- Installing phpcollection/phpcollection (0.5.0)
Loading from cache
- Installing jms/parser-lib (1.0.0)
Loading from cache
- Installing jms/metadata (1.5.1)
Loading from cache
- Installing jms/serializer (dev-xsd2php f339d96)
Cloning f339d96f7e359e2837ed8b752348cc84823a9966
- Installing goetas-webservices/xsd-reader (v0.1.2)
Loading from cache
- Installing zendframework/zend-eventmanager (3.0.1)
Loading from cache
- Installing zendframework/zend-code (2.6.3)
Loading from cache
- Installing doctrine/inflector (v1.1.0)
Loading from cache
- Installing symfony/yaml (v3.1.6)
Loading from cache
- Installing psr/log (1.0.2)
Loading from cache
- Installing symfony/debug (v3.1.6)
Loading from cache
- Installing symfony/polyfill-mbstring (v1.2.0)
Loading from cache
- Installing symfony/console (v3.1.6)
Loading from cache
- Installing goetas/xsd2php (dev-master 7e1ab0a)
Cloning 7e1ab0a2d007991b0c6d326e9f67ec90c020b5e5
- Installing goetas/xsd-reader (dev-master c5bcc02)
Cloning c5bcc02d1a07f26533991e7b0d6c51a98d78c02c
- Installing authorizenet/authorizenet (1.8.8)
Loading from cache
zendframework/zend-eventmanager suggests installing container-interop/container-interop (^1.1.0, to use the lazy listeners feature)
zendframework/zend-eventmanager suggests installing zendframework/zend-stdlib (^2.7.3 || ^3.0, to use the FilterChain feature)
zendframework/zend-code suggests installing zendframework/zend-stdlib (Zend\Stdlib component)
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/process ()
authorizenet/authorizenet suggests installing phpdocumentor/phpdocumentor (For generating API documentation)
Package goetas/xsd2php is abandoned, you should avoid using it. Use goetas-webservices/xsd2php instead.
Package goetas/xsd-reader is abandoned, you should avoid using it. Use goetas-webservices/xsd-reader instead.
Writing lock file
Generating autoload files
..
is, in general, a valid construction - it goes up the directory tree one level. In your case that resolves to/var/www/public/newsite/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MerchantAuthenticationType.php
. Would you check your project on the server to see at what point that path does not exist, and let us know here? – halfercomposer update
did not run correctly. In the project folder, destroy the vendor folder usingrm -rf vendor
and run the Composer command again, and paste the whole output in the question. – halfer"authorizenet/authorizenet": "1.9.0"
, entry in the "require" object. (Like there was in the description of the composer.json file on the main repository page). I tried adding that to this composer.json file, but then it didn't run at all, finding a conflict. – ChuckYour requirements could not be resolved to an installable set of packages. Problem 1 - Installation request for authorizenet/authorizenet dev-master -> satisfiable by authorizenet/authorizenet[dev-master]. - Can only install one of: authorizenet/authorizenet[1.9.0, dev-master]. - Installation request for authorizenet/authorizenet 1.9.0 -> satisfiable by authorizenet/authorizenet[1.9.0].
I'm out of ideas for what composer.json file to use. Or maybe I'm just doing it wrong... seems like this should work. – Chuck