2016-02-11 85 views
1

我正在处理付款处理页面。我们正在使用Authorize.net来处理交易。我导入了Authorize的php库及其所有依赖项。

当我尝试处理交易测试,我得到以下错误:

Fatal error: Using $this when not in object context in /home/ticketstroyfair/public_html/include/authorize/vendor/jms/serializer/src/JMS/Serializer/Serializer.php on line 99 

起初我还以为这东西在我的代码,所以我试图运行授权的PHP样本交易,并得到同样的错误。

该串行器昨天刚刚从GitHub下载。 https://github.com/schmittjoh/serializer

这里是授权示例代码:

<?php 
require 'include/authorize/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("YOU_API_LOGIN_ID"); 
    $merchantAuthentication->setTransactionKey("YOUR_TRANSACTION_KEY"); 
    $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); 
    $controller = new AnetController\CreateTransactionController($request); 
    $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); 

if ($response != null) 
{ 
    $tresponse = $response->getTransactionResponse(); 
    if (($tresponse != null) && ($tresponse->getResponseCode()=="1")) 
    { 
    echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n"; 
    echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n"; 
    } 
    else 
    { 
    echo "Charge Credit Card ERROR : Invalid response\n"; 
    } 
} 
else 
{ 
    echo "Charge Credit Card Null response returned"; 
} 
?> 

是什么原因造成的错误任何想法?

+0

那么,你在哪个代码中为串行器调用? –

+0

我刚刚添加了我试图运行的授权示例代码。 Authorize库中的一种方法是调用Serializer。 –

回答

相关问题