如何在Nuxt.js中获取Stripe的结账状态

huangapple go评论66阅读模式
英文:

How to get checkout state of stripe in Nuxt.js

问题

我正在尝试订阅一个活跃的计划。
所以首先,我想在Nuxt.js中获取Stripe结账的成功状态。
我正在使用vue-stripe模块。

<script>
  export default {
    data () {
      this.pk = "pk_test_5*******************************************";
      return {
        lineItems: [
            {
            price: 'price_**************Im', // 您在Stripe仪表板中创建的一次性价格的ID
            quantity: 1,
            },
        ],
        successUrl: 'https://main.*********.com/home',
        cancelUrl: 'https://main.*********.com/pricing',
      };
    },
    methods: {
        checkout () {
            this.$refs.checkoutRef.redirectToCheckout();
        }        
    },
  };
  </script>

我想在Amplify中保存成功状态,最佳方式是什么?

我正在尝试在Nuxt.js中获取Stripe结账的成功状态。

英文:

I am trying to make subscribed to an active plan.
so first I'd like to get success state of stripe checkout in Nuxt.js.
And I am using vue-stripe module.

<script>
  export default {
    data () {
      this.pk = "pk_test_5*******************************************";
      return {
        lineItems: [
            {
            price: 'price_**************Im', // The id of the one-time price you created in your Stripe dashboard
            quantity: 1,
            },
        ],
        successUrl: 'https://main.*********.com/home',
        cancelUrl: 'https://main.*********.com/pricing',
      };
    },
    methods: {
        checkout () {
            this.$refs.checkoutRef.redirectToCheckout();
        }        
    },
  };
  </script>

And I'd like to save success state in amplify.
what is the best way?

I am trying to get success of stripe checkout in Nuxt.js

答案1

得分: 1

Stripe建议使用webhooks来进行支付/订单对账。Webhooks允许您在收到来自Stripe帐户的事件(如新的付款等活动)时执行异步操作,比如更新数据库。

在结账(Checkout)的具体情况下,当您的客户在托管支付页面上成功支付时,将触发一个checkout.session.completed 事件。有关如何为这些事件实现Webhook处理程序的文档在这里

英文:

The Stripe recommendation is to utilise webhooks for any payment/order reconciliation. Webhooks allow you to perform asynchronous actions, like updating a database, when receiving events that are fired from your Stripe account according to activity (like a new payment, for example).

In the specific case of Checkout, a checkout.session.completed event will be fired when your customers successful pay on the hosted payment page. There's documentation here on how to implement a webhook handler for those events.

huangapple
  • 本文由 发表于 2023年3月31日 17:56:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897150.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定