【问题标题】:Payment Method Error Square Api支付方式错误 Square API
【发布时间】:2017-08-22 17:33:47
【问题描述】:

我正在尝试将 Square API 与我的 asp.net C# 应用程序集成并收取一张卡,它给出了一个例外

Error calling Charge: {"errors":[{"category":"PAYMENT_METHOD_ERROR","code":"CARD_DECLINED","detail":"Card declined."}]}

但是当我使用沙盒凭据时,它可以正常工作。

这是整个代码的 git 链接。 https://github.com/square/connect-api-examples/blob/master/connect-examples/v2/csharp_payment/PaymentExample/Default.aspx.cs

以下是我的代码。

private static TransactionsApi _transactionsApi = new TransactionsApi();
        private static string _locationId = "G5CXF7RRQ5**";

[System.Web.Services.WebMethod]
        public static string Charge(string nonce)
        {
            string msg = "";
            try
            {
                Configuration.Default.AccessToken = "sq0atp-QXNE1q59un5dzDeDC****";


                string uuid = NewIdempotencyKey();
                Money amount = new Money(100, Money.CurrencyEnum.USD);
                string a = "";

                ChargeRequest body = new ChargeRequest(AmountMoney: amount, IdempotencyKey: uuid, CardNonce: nonce);


                var response = _transactionsApi.Charge(_locationId, body);
                return msg = response.ToJson();
            }
            catch (ApiException e)
            {
                return msg = e.Message;
            }
        }

        public static string NewIdempotencyKey()
        {
            return Guid.NewGuid().ToString();
        }

【问题讨论】:

标签: c# payment-gateway square square-connect


【解决方案1】:

Square 的开发者沙盒在接受卡片方面更为宽松。尝试另一张卡,如果您的卡被拒绝,您会收到预期的错误。

【讨论】:

  • 先生,我使用超过 10 张卡并获得相同的异常错误调用费用:{“errors”:[{“category”:“PAYMENT_METHOD_ERROR”,“code”:“CARD_DECLINED”,“detail”: “卡被拒绝。”}]}
  • 您的代码运行正常,可能是您的帐户有问题。您可以尝试创建一个不同的帐户进行测试吗?
  • 先生,您能告诉我我的帐户设置有什么问题,然后我会修复它。我也认为这不是编程错误,因为它适用于沙盒凭据。但我无法追踪我的帐户有什么问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-22
  • 2020-05-04
  • 1970-01-01
相关资源
最近更新 更多