首页 > 解决方案 > 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();
  
      },

标签: javascriptangularfirebasesquare

解决方案


要回答您的问题,您似乎需要创建一个 CheckoutRequest,然后在 SquareConnect 框架上调用 CheckoutApi。

有关示例,请参见本文: https ://developer.squareup.com/blog/super-simple-serverless-ecommerce/

但是,我只会推迟对无服务器的要求。这不应该是您的客户或最终用户设定的要求,也不应该是您作为开发专家无法决定的事情。无服务器支付非常危险,并且具有巨大的安全风险、违反 PCI 的可能性,并且可能违反 OWASP 原则。

在此处输入图像描述

在这里找到:https ://medium.com/faun/how-to-create-a-serverless-payment-system-using-stripe-and-aws-lambda-3e532a5a3817

即使在这里,他们也建议您在进行无服务器支付系统时仍应添加服务器端代码以保护敏感数据。


推荐阅读