NotFound 字段 "card_nonce" 错误

NotFound at field "card_nonce" error

我在测试/sandbox 中遇到此错误,但在生产中没有

InvalidRequestError - NotFound at field "card_nonce": 未找到资源。

我路过,看:

请让我知道我需要做什么。

您能否检查一下用于创建沙盒卡随机数的 App ID 是否与您用于沙盒收费请求的应用 ID 匹配?沙盒 App ID 应具有 sandbox- 前缀。

测试 Square 时

  • 使用 sandbox/test 应用程序 ID
  • 您不能使用生产访问密钥 - 也不能生成访问密钥(用于测试)
  • 您必须在沙盒访问密钥中进行硬编码 - 这样您所有的测试站点都使用相同的密钥

这将解决上述问题。

我认为这里的问题是 card_nonce 属性。此属性必须从 SqPaymentForm 生成,因为 documentation 表示:

A nonce generated from the SqPaymentForm that represents the card to charge. The application that provides a nonce to this endpoint must be the same application that generated the nonce with the SqPaymentForm. Otherwise, the nonce is invalid.

所以我推荐使用Square推荐的test cases,然后添加到你的平台。