php - Authorize.net 连接有问题
问题描述
使用composer下载php sdk并创建必要的东西后,在尝试运行脚本以连接服务器时,我遇到了这个问题
致命错误:声明 JMS\Serializer\JsonDeserializationVisitor::startVisitingObject(JMS\Serializer\Metadata\ClassMetadata $metadata, JMS\Serializer\object $object, array $type): void 必须与 JMS\Serializer\Visitor\DeserializationVisitorInterface 兼容: :startVisitingObject(JMS\Serializer\Metadata\ClassMetadata $metadata, JMS\Serializer\Visitor\object $data, array $type): void in /home/vagrant/Code/Project/vendor/jms/serializer/src/JsonDeserializationVisitor.php在第 14 行
这是我创建的脚本(使用那里的例子)
/* Create a merchantAuthenticationType object with authentication details
retrieved from the constants file */
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
$merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
// Set the transaction's refId
$refId = 'ref' . time();
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111");
$creditCard->setExpirationDate("2038-12");
$creditCard->setCardCode("123");
// Add the payment data to a paymentType object
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
// Create order information
$order = new AnetAPI\OrderType();
$order->setInvoiceNumber("10101");
$order->setDescription("Golf Shirts");
// Set the customer's Bill To address
$customerAddress = new AnetAPI\CustomerAddressType();
$customerAddress->setFirstName("Ellen");
$customerAddress->setLastName("Johnson");
$customerAddress->setCompany("Souveniropolis");
$customerAddress->setAddress("14 Main Street");
$customerAddress->setCity("Pecan Springs");
$customerAddress->setState("TX");
$customerAddress->setZip("44628");
$customerAddress->setCountry("USA");
// Set the customer's identifying information
$customerData = new AnetAPI\CustomerDataType();
$customerData->setType("individual");
$customerData->setId("99999456654");
$customerData->setEmail("EllenJohnson@example.com");
// Add values for transaction settings
$duplicateWindowSetting = new AnetAPI\SettingType();
$duplicateWindowSetting->setSettingName("duplicateWindow");
$duplicateWindowSetting->setSettingValue("60");
// Add some merchant defined fields. These fields won't be stored with the transaction,
// but will be echoed back in the response.
$merchantDefinedField1 = new AnetAPI\UserFieldType();
$merchantDefinedField1->setName("customerLoyaltyNum");
$merchantDefinedField1->setValue("1128836273");
$merchantDefinedField2 = new AnetAPI\UserFieldType();
$merchantDefinedField2->setName("favoriteColor");
$merchantDefinedField2->setValue("blue");
// Create a TransactionRequestType object and add the previous objects to it
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authOnlyTransaction");
$transactionRequestType->setAmount($amount);
$transactionRequestType->setOrder($order);
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setBillTo($customerAddress);
$transactionRequestType->setCustomer($customerData);
$transactionRequestType->addToTransactionSettings($duplicateWindowSetting);
$transactionRequestType->addToUserFields($merchantDefinedField1);
$transactionRequestType->addToUserFields($merchantDefinedField2);
// Assemble the complete transaction request
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequestType);
// Create the controller and get the response
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
我该如何解决这个问题
解决方案
推荐阅读
- pine-script - 解决OCHL上执行代码的问题
- javascript - 如何在 Nuxt 中处理 setInterval
- visual-studio - 从 Visual Studio 部署到 Hololens 2 模拟器工作正常,但我无法通过 USB 部署到设备本身
- crystal-reports - 水晶报表显示线
- node.js - 错误:14 不可用:未建立连接 - Cloud Firestore
- python-3.x - 如何使用 pandas Python 合并两个数据框
- python - 如何在 python 中对包含数十亿条记录的非常大的 .csv 文件进行排序?
- python - Dask-SSH 集群添加私钥
- typescript - 如何在 Typescript 中的另一个类的构造函数中调用一个类?
- tomcat9 - ISAPI 重定向器与 Tomcat9