简体   繁体   English

STRIPE - 使用试用创建订阅,试用结束后对 3D 安全卡实施一次性身份验证失败

[英]STRIPE - Creating Subscription with trial, implementing one-time authentication fails for 3D secure cards after trial ends

  • Stack: Nodejs/Vue/Stripe堆栈:Nodejs/Vue/Stripe
  • NOTE: Logic works for the standard card (4242424242424242), when trial does not exist even 3D cards work.注意:逻辑适用于标准卡 (4242424242424242),即使 3D 卡也不存在试用版。
  • This card is used for this test: 4000002500003155此卡用于本次测试:4000002500003155

https://stripe.com/docs/testing#regulatory-cards https://stripe.com/docs/testing#regulatory-cards

Hi everyone, so the title pretty much says everything, I have an issue with 3d secure cards when trial ends.大家好,标题几乎说明了一切,试用期结束时我遇到了 3d 安全卡的问题。

Steps to reproduce: Node(SERVER):重现步骤:节点(服务器):

  1. create customer创建客户
const customer = await this.getInstance().customers.create({ email: userData.email, name: userData.fullname, });
  1. create subscription创建订阅
const subscription = await this.getInstance().subscriptions.create({ customer, items: [ { price: priceId, }, ], off_session: true, promotion_code, payment_behavior: 'default_incomplete', expand: ['latest_invoice.payment_intent', 'pending_setup_intent'], metadata, trial_from_plan: true, });
  1. return data to CLIENT side将数据返回给客户端
 const invoice = subscription.latest_invoice as Stripe.Invoice; const intentType = subscription.pending_setup_intent ? 'setup' : 'payment'; const intent = intentType === 'payment' ? (invoice.payment_intent as Stripe.PaymentIntent) : (subscription.pending_setup_intent as Stripe.SetupIntent); const formattedSubscription = pick(subscription,['cancel_at_period_end','cancel_at','canceled_at']); return { intentType, ...pick(intent, ['id', 'client_secret', 'status']), ...formattedSubscription, };

From the CLINET side:从 CLINET 方面:

  1. Fetching response:获取响应:
 const response = await this.$pricesService.buyPlan(this.selectedPlan.id, { fullname: this.nameOnTheCard, email: this.email, hash: this.couponApplied?.hash, }); if (response.error) { throw new Error(response.error); }
 const { intentSecret, intentID, intentType, ...restOfBuyResponse } = response;
  1. Depending on the type of the intent:根据意图的类型:
 if (intentType === 'payment') { stripeResponse = await StripeInstance.confirmCardPayment(intentSecret, { payment_method: { card: this.$refs.cardElement.$refs.element._element }, }); } else { stripeResponse = await StripeInstance.confirmCardSetup(intentSecret, { payment_method: { card: this.$refs.cardElement.$refs.element._element }, }); }
  1. Confirmation triggers 3d Secure modal and after confirming it, invoice on 0$ is paid.确认触发 3d Secure 模式,确认后,支付 0$ 的发票。

Everything works as it should until this next point.一切正常,直到下一点。

To test trail mode as fast as it can be done, I've made API to remove trial from the subscription为了尽可能快地测试跟踪模式,我制作了 API 以从订阅中删除试用版

 const subscription = await this.getInstance().subscriptions.update(subscriptionId, { trial_end: 'now', });

After that, Invoice is OverDue, subscription is failed (with switching to pending).之后,发票过期,订阅失败(切换到挂起)。 I've noticed that default_payment_method is absent, so I've even returned setup intent payment method from the fronted, and attached to the customer, even invoice settings.我注意到 default_payment_method 不存在,所以我什至从前端返回了设置意图付款方式,并附加到客户,甚至发票设置。 But no matter what I've modified, new invoice and payment intent never used that information.但无论我修改了什么,新的发票和付款意向都从未使用过这些信息。

Is this expected behavior due to some regulations or am I missing something?这是由于某些规定导致的预期行为还是我遗漏了什么?

发票

/////////// /////////// 订阅 //////////// //////////// 活动

By default, both creating & updating a subscription is considered to be an on-session request and hence the card requires authentication.默认情况下,创建和更新订阅都被视为会话请求,因此卡需要身份验证。

If this is purely for testing purposes, you can include off_session=true .如果这纯粹是为了测试目的,您可以包含off_session=true

 const subscription = await this.getInstance().subscriptions.update(subscriptionId, {
    trial_end: 'now',
    off_session : true
 });

If you let the trial for a subscription end and progress naturally (without making an API call to update the subscription), you'd see that 3DS will not be requested (using card ending with 3155).如果您让订阅试用结束并自然进行(无需调用 API 来更新订阅),您会看到不会请求 3DS(使用以 3155 结尾的卡)。

You try this out by creating a subscription with trial_end set to the nearest possible time.您可以通过创建一个将trial_end设置为最近的可能时间的订阅来尝试这一点。 You can make an API call to finalize and pay the invoice if you don't want to wait for 1 hour for it to be done automatically.如果您不想等待 1 小时自动完成,您可以调用 API 来完成支付发票。

const subscription = await stripe.subscriptions.create({
  customer: 'cus_FfkjLYmWcepurw',
  items: [
    {price: 'price_1JXgRCJQtHgRImA7fDIHY4B2'},
  ],
  trial_end : 1634536700
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 试用结束后显示高级条带订阅 - showing premium stripe subscription after trial ends 如何将 Stripe 3D 安全一次性付款 + 定期订阅放在一个弹出窗口中? - How can put Stripe 3D secure one time payment + recurring subscription in a single pop up? 特定订阅项目的免费试用,而订阅未在条带中试用 - Free trail for a specific subscription item while subscription is not on trial in stripe Stripe 将 paymentMethod 添加到试用订阅并稍后验证信用卡 - Stripe adding paymentMethod to trial subscription and later validate credit card stripe:在保存的卡上创建 30 天的试用订阅费用,但允许用户升级并立即开始收费? - stripe: Create a 30-day trial subscription charge on a saved card but allow user to upgrade and start charging immediately? 订阅模式下的 Stripe 结账会话,免费试用且无需请求付款方式 - Stripe checkout session in subscription mode, with free trial and without requesting payment method 在nodejs中在stripe中添加3D安全验证 - Add 3D secure verification in stripe in nodejs 如何在 Stripe 的 Checkout session 中添加试用期 - how to add trial period in Checkout session in Stripe 在 nodeJS 中使用 STRIPE webhooks 处理一次性付款的最佳方式 - Best way to handle one-time payments with STRIPE webhooks in nodeJS Stripe 不会让费用与具有一次性来源的客户相关联 - Stripe does not let a charge be associated with a customer with one-time source
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM