【问题标题】:Square Payment api integration angular and firebase serverlessSquare Payment api 集成 Angular 和 Firebase 无服务器
【发布时间】:2021-01-31 14:13:43
【问题描述】:

我正在使用 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();
  
      },

【问题讨论】:

  • 无服务器没有任何意义。我想在有人付款后一定会发生一些事情。无论是注册谁支付或该人支付了什么。为什么还要付款?

标签: javascript angular firebase square


【解决方案1】:

要回答您的问题,您需要创建一个 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

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

【讨论】:

    猜你喜欢
    • 2011-07-20
    • 2022-12-02
    • 1970-01-01
    • 2019-04-16
    • 1970-01-01
    • 2016-02-05
    • 2021-02-08
    • 2020-05-04
    • 1970-01-01
    相关资源
    最近更新 更多