【问题标题】:Subscription with ngx-stripe使用 ngx-stripe 订阅
【发布时间】:2021-02-22 17:24:03
【问题描述】:

有人知道或知道如何向我解释 ngx-stripe 是如何进行订阅的。

我尝试使用 cURL 来实现,但我做不到。

我可以制作令牌卡,但下一步是什么?

我有 Angular 的前端和 laravel 的后端。

我不知道我需要制作令牌,然后是客户,最后是订阅。但我不知道怎么做,我已经阅读了文档但我仍然卡住了

【问题讨论】:

    标签: angular laravel stripe-payments


    【解决方案1】:

    在 Stripe 中创建订阅的主要步骤是:

    1. 创建条纹客户(条纹/收银员)
    2. 收集付款方式(ngx-stripe)
    3. 将付款方式保存给客户(条纹/收银员)
    4. 创建订阅(条纹/收银员)

    您只能将 ngx-stripe 用于第二步(收集付款方式),并且可能用于第四步(创建订阅)由于 SCA 需要身份验证的情况。首先,我会按照 ngx-stripe 文档来创建令牌:

    https://richnologies.gitbook.io/ngx-stripe/examples#create-token

    但是,我不会打电话给this.stripeService.createToken,而是打电话给this.stripeService.createPaymentMethod

        this.stripeService
          .createPaymentMethod({
            type: 'card',
            card: this.card.element,
            billing_details: { name },
          })
          .subscribe((result) => {
            if (result.paymentMethod) {
              // Send the payment method to your server
              console.log(result.paymentMethod.id);
            } else if (result.error) {
              // Error creating the token
              console.log(result.error.message);
            }
          });
    

    PaymentMethods 是 Stripe 用于收集付款详细信息的较新推荐途径。

    创建 PaymentMethod 后,您需要将 PaymentMethod ID 发送到您的服务器。在您的服务器中,您将创建一个 Customer 并将 PaymentMethod 保存到它:

    使用条纹

    使用 Laravel 收银员

    此时,您将拥有一个带有已保存 PaymentMethod 的 Stripe 客户。最后一步是为该客户创建订阅:

    使用条纹

    使用 Laravel 收银员

    这就是要点!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-03
      • 2017-12-27
      • 2018-06-21
      • 2014-09-03
      • 2017-08-20
      • 2021-05-22
      • 2021-01-01
      • 2015-07-26
      相关资源
      最近更新 更多