问题描述
是否有人知道或知道如何向我解释NGX-Stripe如何订阅。
我试着用Curl做,但做不到。
我可以制作令牌卡,但下一步是什么?
我的前端是带角的,后端是带棱角的。
我明白我需要制作令牌,然后是客户,最后是订阅。但我不知道怎么回事,我已经看过文档了,但还是卡住了
推荐答案
在条带中创建订阅的主要步骤如下:
创建条纹客户(条纹/收银员) 领用付款方式(NGX-Stripe) 将付款方式保存给客户(条码/收银员) 创建订阅(条带/收银台) 您只能将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发送到您的服务器。在您的服务器中,您将创建一个客户并将PaymentMethod保存到其中:使用条带
https://stripe.com/docs/api/customers/create https://stripe.com/docs/api/customers/create#create_customer-invoice_settings-default_payment_method使用Laravel收银机
https://laravel.com/docs/8.x/billing#adding-payment-methods 在这一点上,您将拥有一位具有保存的PaymentMethod的STRIPE客户。最后一步是为该客户创建订阅:使用条带
https://stripe.com/docs/billing/subscriptions/fixed-price#create-subscription(第三个代码块)使用Laravel收银机
https://laravel.com/docs/8.x/billing#creating-subscriptions这就是要点!