我正在尝试使用PHP SDK将authorize.net集成到我的laravel购物车中。我目前只在沙盒环境中。我有它处理事务(我可以在管理员中看到它并获取电子邮件)但返回的响应都是空值。
代码仍然有点脏
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
class PaymentController extends Controller
{
//
public function authnet_chargeCard()
{
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName(env('AUTHNET_ID'));
$merchantAuthentication->setTransactionKey(env('AUTHNET_KEY'));
$refId = 'ref' . time();
define("AUTHORIZENET_LOG_FILE", "phplog");
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111");
$creditCard->setExpirationDate("1226");
$creditCard->setCardCode("123");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
$order = new AnetAPI\OrderType();
$order->setInvoiceNumber("COW-100");
$order->setDescription("New Item");
//create a transaction
$amount=100;
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType( "authCaptureTransaction");
$transactionRequestType->setAmount($amount);
$transactionRequestType->setOrder($order);
$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);
//dd($response);
if ($response != null)
{
$tresponse = $response->getTransactionResponse();
if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) )
{
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";
}
}
}
每次我的回答都是这样的:
CreateTransactionResponse {#352 ▼
-transactionResponse: null
-profileResponse: null
-refId: null
-messages: null
-sessionToken: null
}
我甚至尝试暂时将$ VERIFY_PEER设置为false
答案 0 :(得分:0)
不知道我哪里出错了...清理了作曲家文件......更新了它并且热情好转。很抱歉浪费虚拟空间和时间。
答案 1 :(得分:0)
yum -y update
yum install -y centos-release-scl
yum install -y devtoolset-6
yum install -y devtoolset-6-gcc-gfortran
scl enable devtoolset-6 bash
scl enable devtoolset-6-gcc-gfortran bash
mkdir packages
cd packages
wget -qO-
https://downloads.sourceforge.net/project/libpng/zlib/1.2.8/zlib-
1.2.8.tar.gz | tar zvx
cd zlib-1.2.8
./configure
make
make install
cd ..
wget -qO- http://downloads.sourceforge.net/pcre/pcre-8.35.tar.gz |
tar xzv
cd pcre-8.35
./configure
make
make install
cd ..
wget -qO- http://tukaani.org/xz/xz-5.2.2.tar.gz | tar xzv
cd xz-5.2.2
./configure
make
make install
cd ..
wget -qO- https://curl.haxx.se/download/curl-7.47.1.tar.gz | tar xzv
cd curl-7.47.1
./configure
make
make install
cd ..
wget -qO- https://cran.r-project.org/src/base/R-3/R-3.4.4.tar.gz |
tar xzv
cd R-3.4.4
./configure --with-readline=no --with-x=no --prefix=/packages/R-3.4.4
F77=gfortran
make
make install
尝试上面的代码,它对我有用。