stripe 面试真题 (五)Sending Subscription Notifications 订阅通知系统

10次阅读
没有评论

Sending Subscription Notifications — Part 1

At Stripe, we frequently send notifications to users related to their subscriptions.
Each user has an account creation date and a subscription plan with a specific duration.
You’ll need to generate email subject lines corresponding to each user for different stages of their subscription, sorted by time.

Your notification system will need to allow the configuration of a send schedule.
For example, a send schedule configuration might be:

  • send one email on the account creation date,
  • another email 15 days before the subscription end date,
  • and a final email on the subscription end date.

The send schedule could look like this:

t=start         [Welcome] New subscription for ${user}
t=15 days before end   [Upcoming expiry] Subscription expiry upcoming for ${user}
t=end           [Expired] Subscription end for ${user}

Given a send schedule configuration, your input will be an unsorted list of user accounts with:

  • account creation date
  • subscription duration in days
  • user name
  • subscription plan

Your objective is to print out all email subject lines we will send out, sorted by time.
The output should include the time, type of email, the user, and the plan.

Example configuration:

send_schedule = {
  "start": "Welcome",
  "-15": "Upcoming expiry",
  "end": "Expired"
}

user_accounts = [
  {"account_date": 0, "duration": 30, "name": "John", "plan": "Silver"},
  {"account_date": 1, "duration": 15, "name": "Alice", "plan": "Gold"},
]

Expected output:

0: [Welcome] Subscription for John (Silver)
1: [Welcome] Subscription for Alice (Gold)
1: [Upcoming expiry] Subscription for Alice (Gold)
15: [Upcoming expiry] Subscription for John (Silver)
16: [Expired] Subscription for Alice (Gold)
30: [Expired] Subscription for John (Silver)

Sending Subscription Notifications — Part 2

Sometimes users may change their subscription plan during the subscription period.
You are now given a list of subscription changes, each specifying the time of change, user name, and new plan.
Each subject line should reflect the user’s current plan at the time of sending.
Additionally, when a plan is updated, send an“[Updated]”notification email immediately.

Example:

subscription_changes = [
  {"change_date": 5, "name": "Alice", "new_plan": "Platinum"}
]

Expected output:

0: [Welcome] Subscription for John (Silver)
1: [Welcome] Subscription for Alice (Gold)
1: [Upcoming expiry] Subscription for Alice (Gold)
5: [Updated] Subscription for Alice (Platinum)
15: [Upcoming expiry] Subscription for John (Silver)
16: [Expired] Subscription for Alice (Platinum)
30: [Expired] Subscription for John (Silver)

题目模拟了 Stripe 的订阅系统中邮件发送逻辑,要求实现一个可以根据不同时间节点(注册日、到期前 N 天、到期日)发送通知邮件的系统。
每个用户有:账户创建时间、订阅持续天数、用户名、订阅计划。系统需根据配置生成对应的邮件主题行并按时间排序输出。

在第二部分中,加入了用户在订阅期间更改套餐的场景,需要即时发送“更新通知”,并让后续邮件反映新的订阅计划。

考察点:

  • 对时间线事件排序(event scheduling);
  • 多数据源合并(用户信息 + 更改记录);
  • 动态状态更新(plan change propagation);
  • 模块化系统设计与可扩展性。

VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 Stripe、Google、Amazon、Citadel、SIG 等,提供实时语音助攻、远程陪练与面试节奏提醒,帮助大家在关键时刻不卡壳。
如果你也在准备 Stripe 或类似工程向公司,可以了解一下我们的定制助攻方案——从编程面到系统设计,全程护航上岸。

正文完
 0