问题描述
我是Stripe API的新手,我想每月创建一个Subscription
,并允许他们输入折扣代码。
为此,我使用Subscription Schedule,它允许我在内部创建2个阶段。例如,第一个星期是1欧元,然后是常规订阅。 一切正常,我可以创建订阅时间表:
{
canceled_at: null
completed_at: null
created: 1602415626
current_phase: {end_date: 1602502026,start_date: 1602415626}
customer: "cus_IAzNj2kr9i1nw8"
default_settings: {billing_cycle_anchor: "automatic",billing_thresholds: null,collection_method: "charge_automatically",default_payment_method: null,default_source: null,…}
end_behavior: "release"
id: "sub_sched_1Hb2hiLShhG4xDx2Fw5Xn3mg"
livemode: false
Metadata: {user_id: "263175",promo_code: "",sub_id_id: "11"}
object: "subscription_schedule"
phases: (2) [{…},{…}]
released_at: null
released_subscription: null
renewal_interval: null
status: "active",subscription: "sub_IBPWnRqS6gVVlm"
}
我面临的唯一问题是如何使用Subscription Schedule
验证用户的卡?创建常规Subscription
时,您可以访问pending_setup_intent
或last_invoice.payment_intent
,从中可以询问3DS或发送错误消息。
你们能告诉我我如何实现吗? 谢谢
解决方法
您需要retrieve the Subscription by its ID才能获得这些,但随后您应该可以使用它们。