通过 JavaScript 接受信用卡付款
Accept Credit Card Payments via JavaScript
我有一个 Square 帐户。我也有一个网页。在此网页上,我正在收集信用卡详细信息(姓名、号码、到期日期、cvv)。我想根据用户提供的信用卡详细信息向用户收费。我认为 Square 有一个允许这样做的 API。但是,我没有看到它。看起来一切都必须在服务器上完成。
有没有一种方法可以完全从 JavaScript 在客户端安全地执行此操作?通过互联网将详细信息发送到服务器似乎风险更大,只是为了将该信息传递到 Square。
此时我有以下几点:
var creditCardNumber = '....';
var credidCardHolderName = 'Joe Smith';
var creditCardExpiration = '10/2020';
var creditCardCvv = '...';
var purchaseAmount = 50.50;
有没有办法通过 Square 在客户端使用 JavaScript 从用户的信用卡中收取 purchaseAmount
的费用?如果是,怎么做?
谢谢
要处理付款,您可能需要发送一些 API 凭据,这些凭据在您的前端显示是不安全的。这就是为什么您可能需要一些后端。
当然你会允许客户更改付款金额,这通常是不行的。
Square 文档几乎没有很好的图表和图像来展示他们的 API 如何工作以及如何理解集成它,例如
查看他们网站上的 "Get started" 指南,尤其是 how it works。
您不能将自己的服务器完全排除在外。那将意味着您永远不会知道订单。钱只会出现在您的帐户中。
不过您不应该收集信用卡信息。看看the Square Documentation for online transactions.
作为该过程的一部分,用户被重定向到收集信用卡信息的 Square 网站。您永远不需要将信用卡详细信息发送到您的服务器。
- Merchant - Create a POST request: . Package the order information as a JSON message. NOTE: Currently, Square Checkout cannot calculate
shipping costs or taxes dynamically, those totals must be provided in
the POST request as line items in the order.
- Add an authorization token to the header.
- Merchant - Send the generated POST request to Square Checkout and process the response:
- Save the returned checkout ID.
- Automatically redirect the customer to the returned Checkout page URL.
- Customer - Provide payment details using the Square Checkout UI.
- Square Checkout - Process the transaction and sends email confirmation to merchant and customer.
- Merchant - Verify the transaction results.
很遗憾,我无法找到执行此操作所需的具体文档。您似乎需要使用您的帐户凭据登录 developer portal。如果您找不到所需的文档,则应联系 Square 支持。话虽如此,我可以给你一些基本的指导。
请勿在您的网站中存储任何信用卡信息。不要存储在 javascript 变量中,发送到您的服务器,或将它们存储在任何数据库中。您可以使用 Square 的特定代码来确保数据安全并确保它只与 Square 共享。
尝试深入研究您尝试使用的产品的文档。您要完成的工作应该可以在某种 "Setup" 或 "Get Started" 类型的文档中找到,这些文档将显着显示。
我有一个 Square 帐户。我也有一个网页。在此网页上,我正在收集信用卡详细信息(姓名、号码、到期日期、cvv)。我想根据用户提供的信用卡详细信息向用户收费。我认为 Square 有一个允许这样做的 API。但是,我没有看到它。看起来一切都必须在服务器上完成。
有没有一种方法可以完全从 JavaScript 在客户端安全地执行此操作?通过互联网将详细信息发送到服务器似乎风险更大,只是为了将该信息传递到 Square。
此时我有以下几点:
var creditCardNumber = '....';
var credidCardHolderName = 'Joe Smith';
var creditCardExpiration = '10/2020';
var creditCardCvv = '...';
var purchaseAmount = 50.50;
有没有办法通过 Square 在客户端使用 JavaScript 从用户的信用卡中收取 purchaseAmount
的费用?如果是,怎么做?
谢谢
要处理付款,您可能需要发送一些 API 凭据,这些凭据在您的前端显示是不安全的。这就是为什么您可能需要一些后端。
当然你会允许客户更改付款金额,这通常是不行的。
Square 文档几乎没有很好的图表和图像来展示他们的 API 如何工作以及如何理解集成它,例如
查看他们网站上的 "Get started" 指南,尤其是 how it works。
您不能将自己的服务器完全排除在外。那将意味着您永远不会知道订单。钱只会出现在您的帐户中。
不过您不应该收集信用卡信息。看看the Square Documentation for online transactions.
作为该过程的一部分,用户被重定向到收集信用卡信息的 Square 网站。您永远不需要将信用卡详细信息发送到您的服务器。
- Merchant - Create a POST request: . Package the order information as a JSON message. NOTE: Currently, Square Checkout cannot calculate shipping costs or taxes dynamically, those totals must be provided in the POST request as line items in the order.
- Add an authorization token to the header.
- Merchant - Send the generated POST request to Square Checkout and process the response:
- Save the returned checkout ID.
- Automatically redirect the customer to the returned Checkout page URL.
- Customer - Provide payment details using the Square Checkout UI.
- Square Checkout - Process the transaction and sends email confirmation to merchant and customer.
- Merchant - Verify the transaction results.
很遗憾,我无法找到执行此操作所需的具体文档。您似乎需要使用您的帐户凭据登录 developer portal。如果您找不到所需的文档,则应联系 Square 支持。话虽如此,我可以给你一些基本的指导。
请勿在您的网站中存储任何信用卡信息。不要存储在 javascript 变量中,发送到您的服务器,或将它们存储在任何数据库中。您可以使用 Square 的特定代码来确保数据安全并确保它只与 Square 共享。
尝试深入研究您尝试使用的产品的文档。您要完成的工作应该可以在某种 "Setup" 或 "Get Started" 类型的文档中找到,这些文档将显着显示。