ces*_*dav 1 laravel stripe-payments angular
有人知道或知道如何向我解释 ngx-stripe 是如何进行订阅的吗?
我尝试用 cURL 做到这一点,但我做不到。
我可以制作令牌卡,但下一步是什么?
我的前端是 Angular,后端是 Laravel。
我知道我需要制作令牌,然后是客户,最后是订阅。但我不知道怎么办,我已经阅读了文档,但我仍然陷入困境
小智 7
在 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);
}
});
Run Code Online (Sandbox Code Playgroud)
PaymentMethods 是 Stripe 收集付款详细信息的较新推荐路径。
创建 PaymentMethod 后,您需要将 PaymentMethod ID 发送到您的服务器。在您的服务器中,您将创建一个 Customer 并将 PaymentMethod 保存到其中:
使用条纹
使用 Laravel 收银台
此时,您将拥有一个已保存 PaymentMethod 的 Stripe 客户。最后一步是为该客户创建订阅:
使用条纹
使用 Laravel 收银台
这就是要点!
| 归档时间: |
|
| 查看次数: |
1861 次 |
| 最近记录: |