gpt4 book ai didi

php - 使用 authorize.net 支付错误 由于身份验证值无效,用户身份验证失败

转载 作者:行者123 更新时间:2023-12-05 08:43:12 27 4
gpt4 key购买 nike

我已点击付款链接 https://github.com/AuthorizeNet/sdk-php但响应“由于身份验证值无效,用户身份验证失败”。该代码适用于开发人员,但不适用于开发人员,但不适用于真实帐户。

require 'authorizesdk/vendor/autoload.php'; 
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;

define("AUTHORIZENET_LOG_FILE","phplog");
/** Make sure that the WordPress bootstrap has run before continuing. */
require( dirname(__FILE__) . '/wp-load.php' );
global $wpdb;
if ( is_user_logged_in() ) {
$user_ID = get_current_user_id();
}

$creditcardno=$_POST['credit_card_number'];
$expdate=$_POST['year'].'-'.$_POST['month'];
$invoiceno=$_POST['x_invoice_num'];
$description=$_POST['x_description'];
$id=$_POST['x_id'];
$email=$_POST['x_email'];
//$creditcardno='';
//$expdate='16/06';
//$invoiceno=$_POST['x_invoice_num'];
//$description=$_POST['x_description'];
//$id=$_POST['x_id'];
//$email=$_POST['x_email'];


//44Wz7d8Zsr2F5zD6
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5Tb3S44sLp");
$merchantAuthentication->setTransactionKey("****");
$refId = 'ref' . time();

// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber($_POST['credit_card_number']);
$creditCard->setExpirationDate( $expdate);
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);

// Order info
$order = new AnetAPI\OrderType();
$order->setInvoiceNumber($invoiceno);
$order->setDescription($description);

// Customer info
$customer = new AnetAPI\CustomerDataType();
$customer->setId($id);
$customer->setEmail($mail);

// Bill To
$billto = new AnetAPI\CustomerAddressType();
$billto->setFirstName($_POST['credit_card_fname']);
$billto->setLastName($_POST['credit_card_lname']);
$billto->setCompany($_POST['x_company']);
$billto->setAddress($_POST['x_address']);
$billto->setCity($_POST['x_city']);
$billto->setState($_POST['x_state']);
$billto->setZip($_POST['x_zip']);
$billto->setCountry($_POST['x_country']);

// Create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
// $transactionRequestType->setAmount($_POST['x_amount']);
$transactionRequestType->setAmount($_POST['x_amount']);
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setOrder($order);
$transactionRequestType->setCustomer($customer);
$transactionRequestType->setBillTo($billto);

$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);
echo '<pre>';
var_dump($response);exit;

我们必须为真实账户正确设置什么吗?

最佳答案

我明白了,这里的问题是您已经设置了实时 API 凭据,但 API 环境仍然设置为沙箱,

为此,您需要更改最后的第 3 行

$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);

$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);

这将解决问题。

关于php - 使用 authorize.net 支付错误 由于身份验证值无效,用户身份验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33752427/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com