javascript - Square Payment api 集成 Angular 和 Firebase 无服务器
问题描述
我正在使用 Angular 创建一个项目。在我的项目中,我正在集成 square payment api 并使用 firebase 创建费用。我知道我们可以很容易地用这个服务器端实现,但我的要求是做无服务器。我已经集成了 angular side square api,但我不知道如何在没有服务器的情况下创建费用
cardNonceResponseReceived: function (errors, nonce, cardData) {
if (errors) {
// Log errors from nonce generation to the Javascript console
console.log("Encountered errors:");
errors.forEach(function(error) {
console.log(' ' + error.message);
});
return;
}
alert('Nonce received: ' + nonce); /* FOR TESTING ONLY */
// Assign the nonce value to the hidden form field
// document.getElementById('card-nonce').value = nonce;
//needs to be extracted from the
(<HTMLInputElement>document.getElementById('card-nonce')).value = nonce; //casting so .value will work
//get this value from the database when the user is logged in
(<HTMLInputElement>document.getElementById('sq-id')).value = "CBASEC8F-Phq5_pV7UNi64_kX_4gAQ";
// POST the nonce form to the payment processing page
(<HTMLFormElement>document.getElementById('nonce-form')).submit();
},
解决方案
要回答您的问题,您似乎需要创建一个 CheckoutRequest,然后在 SquareConnect 框架上调用 CheckoutApi。
有关示例,请参见本文: https ://developer.squareup.com/blog/super-simple-serverless-ecommerce/
但是,我只会推迟对无服务器的要求。这不应该是您的客户或最终用户设定的要求,也不应该是您作为开发专家无法决定的事情。无服务器支付非常危险,并且具有巨大的安全风险、违反 PCI 的可能性,并且可能违反 OWASP 原则。
即使在这里,他们也建议您在进行无服务器支付系统时仍应添加服务器端代码以保护敏感数据。
推荐阅读
- javascript - vuejs 将多个输入值分配给 json 对象值
- c# - 在 C# 中尝试读取文本文件并将其显示到控制台时遇到问题
- mysql - 具有不同值的 SQL 查询
- c++ - 使用指针访问数组的值
- django - 以编程方式在 Wagtail 中创建重定向
- macos - 如何在 Mac 上安装 clangd?
- javascript - ReactNative 异步生成器
- javascript - 创建一个将字符串作为参数并返回字符串的编码 (h4ck3r 5p34k) 版本的函数
- php - .htaccess 在 Wordpress 中导致 403 Access Denied
- jquery - 如何在 Backbone 的 Jasmine 测试运行器中测试点击事件?