【发布时间】:2016-01-08 07:36:39
【问题描述】:
我是做php的,刚集成授权支付网关
我关注了以下链接 Php Integration Guide
然后我下载了这个 Php-SDK Example
但每当我执行此操作时,它都会显示错误,我检查了日志并显示 错误:SSL 证书问题:无法获取本地颁发者证书。 请给我确定的解决方案。
-charge-credit-card.php
<?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("API-key");
$merchantAuthentication->setTransactionKey("Trans-Key");
$refId = 'ref' . time();
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("370000000000002");
$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";
}
?>
错误消息: 未捕获的异常“异常”,消息“从 api 获取有效响应时出错。检查日志文件以获取错误详细信息'
在日志文件中
错误: SSL 证书问题:无法获取本地颁发者证书
【问题讨论】:
标签: php payment-gateway authorize.net