我尝试使用他们的API从Authorize.net生成自定义报告,但无法正确加载SDK。
我在开发板HERE上创建了一个帖子,并向其支持团队发送了一封电子邮件请求。该问题应该已通过临时补丁HERE修复。但错误仍然存在。
有没有人对如何解决这个问题有任何想法?
我的代码:
<?php
error_reporting(-1); ini_set('display_errors', 'On');
date_default_timezone_set('UTC');
/* autoload through composer */
//require 'vendor/autoload.php';
/* autoload through git clone */
//require 'git/sdk-php/autoload.php';
/* autoload through .zip download */
require 'download/sdk-php-master/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
function getSettledBatchList($startDate, $endDate) {
$api_id = "MY_API_ID";
$account_key = "MY_ACCOUNT_KEY";
$start_dt = new DateTime($startDate);
$end_dt = new DateTime($endDate);
$merchAuth = new AnetAPI\MerchantAuthenticationType();
$merchAuth->setName($api_id);
$merchAuth->setTransactionKey($account_key);
$request = new AnetAPI\GetSettledBatchListRequest();
$request->setMerchantAuthentication($merchAuth);
$request->setIncludeStatistics(true);
$request->setFirstSettlementDate($start_dt);
$request->setLastSettlementDate($end_dt);
$controller = new AnetController\GetSettledBatchListController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
if(($response != null) && ($response->getMessages()->getResultCode() == "Ok")){
/* Do Nothing For Now */
}else{
$errorMessages = $response->getMessages()->getMessage();
echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n";
}
return $response;
}
$api_response = getSettledBatchList('2016-05-01T00:00:00Z', '2016-05-10T00:00:00Z');
var_dump($api_response);
?>
错误:
/* Loaded with git clone https://github.com/AuthorizeNet/sdk-php.git */
Warning: include(sdk-php/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php): failed to open stream: No such file or directory in sdk-php/autoload.php on line 16
Warning: include(): Failed opening '/sdk-php/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php' for inclusion (include_path='.:') in sdk-php/autoload.php on line 16
Fatal error: Class 'JMS\Serializer\Annotation\Type' not found in /sdk-php/lib/net/authorize/util/SensitiveDataConfigType.php on line 6
/* Loaded by downloading .zip from github page */
Warning: include(/sdk-php-master/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php): failed to open stream: No such file or directory in /sdk-php-master/autoload.php on line 16
Warning: include(): Failed opening '/sdk-php-master/vendor/jms/serializer/src/JMS/Serializer/Annotation/Type.php' for inclusion (include_path='.:') in /sdk-php-master/autoload.php on line 16
Fatal error: Class 'JMS\Serializer\Annotation\Type' not found in /sdk-php-master/lib/net/authorize/util/SensitiveDataConfigType.php on line 6
/* Loaded with Composer using recommended composer.json */
Fatal error: Class 'Goetas\Xsd\XsdToPhp\Jms\Handler\BaseTypesHandler' not found in /vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php on line 82
我现在对所有想法持开放态度。谢谢!
答案 0 :(得分:0)
简单的错误。该补丁发布在composer.json文件中,该文件更新了Goetas所需的开发版本。没有意识到我需要在运行composer update之前更新我的composer.json。
答案 1 :(得分:0)
我遇到了同样的问题,我意识到问题是我在错误的require
上使用autoload.php
,我认为你也是这样做的。
你可能已经想到了它,但万一其他人有这个问题,解决方法是这样的:
您必须加载/要求autoload.php
文件夹中的vendor
,而不是sdk(root)文件夹中的byte[] data;
using (var ms = new MemoryStream()) {
using (var bw = new BinaryWriter(ms)) {
bw.Write(points.Length);
foreach (var p in points) {
bw.Write(p.X);
bw.Write(p.Y);
}
}
data = ms.ToArray();
}
。