Ошибка:
system.typeinitializationexception: «Тип инициализатор для 'Authorizenet.Util.httputility' бросил исключение». Br /> public static anetapiresponse run (строка апилогинид, строка apitransactionkey, десятичное количество)
{
system.net.servicepointmanager.securityprotocol = system.net.securityprotocoltype.tls12; < /p>
var apiLoginId = "";
var transactionKey = "";
Console.WriteLine("Authorize Credit Card Sample");
ApiOperationBase.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};
ApiOperationBase.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};
var creditCard = new creditCardType
{
cardNumber = "4111111111111111",
expirationDate = "1035",
cardCode = "123"
};
var billingAddress = new customerAddressType
{
firstName = "John",
lastName = "Doe",
address = "123 My St",
city = "OurTown",
zip = "98004"
};
var merchantAuth = new merchantAuthenticationType
{
name = apiLoginId,
ItemElementName = ItemChoiceType.transactionKey,
Item = transactionKey
};
var paymentType = new paymentType { Item = creditCard };
var lineItems = new lineItemType[2];
lineItems[0] = new lineItemType { itemId = "1", name = "t-shirt", quantity = 2, unitPrice = new Decimal(15.00) };
lineItems[1] = new lineItemType { itemId = "2", name = "snowboard", quantity = 1, unitPrice = new Decimal(450.00) };
var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
amount = 50.00m
};
var request = new getHostedPaymentPageRequest
{
merchantAuthentication = merchantAuth,
transactionRequest = transactionRequest,
hostedPaymentSettings = new settingType[]
{
new settingType { settingName = "hostedPaymentReturnUrl", settingValue = "https://yourwebsite.com/payment-success" },
new settingType { settingName = "hostedPaymentReturnOptions", settingValue = "{ \"showReceipt\": false }" }
}
};
var controller = new getHostedPaymentPageController(request);
controller.Execute(); // Error happens here
< /code>
попробовал это, но не работал < /p>
- обеспечить включен TLS 1.2 < /li>
< li> Понизил Authorize.net SDK до 2.0.2 - Очищенный и перестроенный раствор
Подробнее здесь: https://stackoverflow.com/questions/794 ... er-execute
Мобильная версия