Square nonce 代表什么?

What does a Square nonce represent?

我正在尝试向 Square 提交付款,但不确定 card_nonce 代表什么。

在此处找到的完整 API 文档:https://docs.connect.squareup.com/api/connect/v2/#endpoint-createcustomercard

它指出,"A card nonce representing the credit card to link to the customer."

但是,在此处找到的 REST 付款处理文档中:https://docs.connect.squareup.com/articles/processing-payment-rest

它指出,"Card nonces expire after 24 hours. The Charge endpoint returns an error if you attempt to charge an expired nonce."

  1. 如果我想存储一个 card_nonce 用于循环计费,我可以使用一次 card_nonce 并重复使用它进行计费吗?

  2. 客户每次结账时都必须输入他们的银行卡信息吗?

  3. card_nonce是代表卡的状态,还是代表特定卡交易的密钥?

卡随机数是信用卡的标记化形式。您只能使用一次,并且它们会过期。它 "represents" 一张信用卡,以及最终用户在您的付款表格中输入的所有详细信息。

如果您想将其用于定期付款,请阅读 Square 文档中的 Processing reoccurring payments

您将卡附加到客户,然后使用客户的卡 ID 针对收费端点进行支付,最终用户无需再次输入他们的信用卡详细信息。

也不是 Square 开发人员,但使用术语 "nonce" 似乎暗示了您问题的答案。基本上,随机数通常是一次性身份验证令牌或一次性密钥。所以...

  1. 根据定义,随机数对任何重复出现的事物都没有用。

  2. 是的,客户每次都需要重新输入信息。

  3. card_nonce 可能代表该卡的单一身份验证。

当然,如果他们有不同的定义,我的答案可能全错了:-)

根据 Square 文档(下面的 link),您可以使用以下任一值作为随机数。确保您使用沙箱凭据进行测试。

fake-card-nonce-ok — returns a successful test transaction.
fake-card-nonce-declined — returns a "Card Declined" error.

例如- 将下面的随机数替换为 "fake-card-nonce-ok" 或 "fake-card-nonce-declined".

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

https://docs.connect.squareup.com/articles/using-sandbox

这将 return 一个包含交易结果信息的 JSON 对象。