[3位数卡代码失败,错误代码为E00003。根据其数据类型,值XXXXXXX无效-模式约束失败

问题描述 投票:0回答:1

下面的代码:-

public bool AuthorizePayment(string Card_Num, string Exp_Date, string Card_Code, string amount)
{
      //Console.WriteLine("Charge Credit Card Sample");

      ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;

      // define the merchant information (authentication / transaction id)
      ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
      {
          name = ConfigurationManager.AppSettings["AuthNetID"],
          ItemElementName = ItemChoiceType.transactionKey,
          Item = ConfigurationManager.AppSettings["AuthNetKey"],
      };

      var creditCard = new creditCardType
      {
          cardNumber = Card_Num,
          expirationDate = Exp_Date,
          cardCode = Card_Code
      };

      //standard api call to retrieve response
      var paymentType = new paymentType { Item = creditCard };

      var transactionType = objInf.Get("x_type") == "AUTH_CAPTURE" ? transactionTypeEnum.authCaptureTransaction.ToString() : transactionTypeEnum.refundTransaction.ToString();

      var transactionRequest = new transactionRequestType
      {
          transactionType = transactionType,
          amount = Convert.ToDecimal(amount),
          payment = paymentType,
      };

      if (objInf.Get("x_invoice_num") != null)
      {
          transactionRequest.order = new orderType { invoiceNumber = objInf.Get("x_invoice_num") };
      }
      if (objInf.Get("x_trans_id") != null)
      {
          transactionRequest.refTransId = objInf.Get("x_trans_id");
      }

      var request = new createTransactionRequest { transactionRequest = transactionRequest };

      // instantiate the controller that will call the service
      var controller = new createTransactionController(request);
      controller.Execute();

      // get the response from the service (errors contained if any)
      var response = controller.GetApiResponse();

      // validate response
      if (response != null)
      {
          //other code
      }
      else
      {
          //other code
      }
  }

[大多数代码是从AuthNet网站复制粘贴的,如果我发送到AuthNet的卡代码是3位数字,则交易失败,Api返回空响应,即使API文档中明确提到了3位卡代码已验证。在这个问题上的任何帮助,将不胜感激。

payment-gateway authorize.net
1个回答
0
投票

错误消息中的XXXXXXX提示Authorize.Net正在获取5个字符,请检查您的cardCode是否用空格包装(例如“ cardCode”:“ 123”或“ 123”或“ 123”)。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.