Adyen支付网关集成错误401.(远程服务器返回错误:(401)未经授权。)

时间:2018-06-12 13:44:03

标签: .net c#-4.0 payment-gateway payment adyen

我正在尝试将adyen api(C#.net)实现到我的项目中,我遇到了以下问题:

AdyenPaymentGatewaySample.dll中出现“System.Net.WebException”类型的异常,但未在用户代码中处理 附加信息:远程服务器返回错误:(401)未经授权。

var config = new Config();
config.MerchantAccount = "MyMerchantAccountName";
config.Password = "mypassword";
config.Username = "test";
config.Endpoint = "https://pal- test.adyen.com/pal/servlet/Payment/v30";
config.ApplicationName = "MyServername";
config.Environment = Test;
config.SkinCode = "7A26B737";//test
config.HmacKey = "7A26B737AN79CSpV87A7A26B737AN79CSpV87A7A26B737AN79CSpV87A";//test

var client = new Client(config);
var payment = new Payment(client);
var paymentRequest = new PaymentRequest
{
 MerchantAccount = "MyMerchantAccountName",
 Amount = new Amount("CAD", 5),
   Card = new Card(Number: "4111111111111111", ExpiryMonth: "08", ExpiryYear: "2018", Cvc: "737", HolderName: "John Smith"),
Reference = "Merchant reference",
AdditionalData = new Dictionary<string, string>()
};

var paymentResult = payment.Authorise(paymentRequest);
return paymentResult;

有关为何发生这种情况的任何想法?

1 个答案:

答案 0 :(得分:1)

HTTP错误401表示您的用户密码错误,系统中不存在,或者无权发送卡数据。