1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 21:45:23 +02:00

Subscription tests and domain (#2209)

* Save work

* Subscriptions and trials domain

* Store family ID on customer

* Remove indirection of stripe calls

* Test simplifications

* Update brakeman

* Fix stripe tests in CI

* Update billing page to show subscription details

* Remove legacy columns

* Complete billing settings page

* Fix hardcoded plan name

* Handle subscriptions for self hosting mode

* Lint fixes
This commit is contained in:
Zach Gollwitzer 2025-05-06 14:05:21 -04:00 committed by GitHub
parent 8c10e87387
commit 5da4bb6dc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 1041 additions and 233 deletions

View file

@ -89,7 +89,7 @@
<div class="flex items-start justify-between">
<div>
<p class="text-sm font-medium text-primary">Free trial</p>
<p class="text-sm text-secondary"><%= Current.family.trial_remaining_days %> days remaining</p>
<p class="text-sm text-secondary"><%= Current.family.days_left_in_trial %> days remaining</p>
</div>
<%= render LinkComponent.new(
@ -99,8 +99,8 @@
</div>
<div class="flex items-center gap-0.5 h-1.5">
<div class="h-full bg-warning rounded-full" style="width: <%= 100 - Current.family.trial_remaining_days / 14.0 * 100 %>%"></div>
<div class="h-full bg-surface-inset rounded-full" style="width: <%= Current.family.trial_remaining_days / 14.0 * 100 %>%"></div>
<div class="h-full bg-warning rounded-full" style="width: <%= Current.family.percentage_of_trial_completed %>%"></div>
<div class="h-full bg-surface-inset rounded-full" style="width: <%= Current.family.percentage_of_trial_remaining %>%"></div>
</div>
</div>
<% end %>

View file

@ -22,10 +22,7 @@
<%= form_with model: @user do |form| %>
<%= form.hidden_field :redirect_to, value: self_hosted? ? "home" : "trial" %>
<%= form.hidden_field :set_onboarding_goals_at, value: Time.current %>
<% if self_hosted? %>
<%= form.hidden_field :onboarded_at, value: Time.current %>
<% end %>
<%= form.hidden_field :onboarded_at, value: Time.current %>
<div class="space-y-3">
<% [

View file

@ -29,12 +29,26 @@
</p>
<div class="w-full">
<%= render ButtonComponent.new(
<% if Current.family.can_start_trial? %>
<%= render ButtonComponent.new(
text: "Try Maybe for 14 days",
href: start_trial_subscription_path,
href: subscription_path,
full_width: true,
data: { turbo: false }
) %>
<% elsif Current.family.trialing? %>
<%= render LinkComponent.new(
text: "Continue trial",
href: root_path,
full_width: true,
) %>
<% else %>
<%= render LinkComponent.new(
text: "Upgrade",
href: upgrade_subscription_path,
full_width: true,
) %>
<% end %>
</div>
</div>

View file

@ -26,13 +26,13 @@
size: "sm",
as_button: true,
data: { action: "rule--actions#remove", rule__actions_destroy_param: action.persisted? }) %>
<%# Templates for different input types - these will be cloned and used by the Stimulus controller %>
<template data-rule--actions-target="selectTemplate">
<span class="font-medium uppercase text-xs">to</span>
<%= form.select :value, [], {} %>
</template>
<template data-rule--actions-target="textTemplate">
<span class="font-medium uppercase text-xs">to</span>
<%= form.text_field :value, placeholder: "Enter a value" %>

View file

@ -11,19 +11,21 @@
) %>
<div class="text-sm space-y-1">
<% if subscription_pending? %>
<% if @family.has_active_subscription? %>
<p class="text-primary">
Your subscription is pending. You can still use Maybe+ while we process your subscription.
<span>You are currently subscribed to the <span class="font-medium"><%= @family.subscription.name %></span>.</span>
<% if @family.next_billing_date %>
<span>Your plan renews on <span class="font-medium"><%= @family.next_billing_date.strftime("%B %d, %Y") %></span>.</span>
<% end %>
</p>
<% elsif @user.family.trialing? %>
<% elsif @family.trialing? %>
<p class="text-primary">
You are currently trialing <span class="font-medium">Maybe+</span>
You are currently trialing Maybe
<span class="text-secondary">
(<%= @user.family.trial_remaining_days %> days remaining)
(<%= @family.days_left_in_trial %> days remaining)
</span>
</p>
<% elsif @user.family.subscribed? %>
<p class="text-primary">You are currently subscribed to <span class="font-medium">Maybe+</span></p>
<% else %>
<p class="text-primary">You are currently <span class="font-medium">not subscribed</span></p>
<p class="text-secondary">Once you subscribe to Maybe+, you'll see your billing settings here.</p>
@ -31,7 +33,7 @@
</div>
</div>
<% if @user.family.subscribed? %>
<% if @family.has_active_subscription? %>
<%= render LinkComponent.new(
text: "Manage",
icon: "external-link",
@ -40,7 +42,7 @@
href: subscription_path,
rel: "noopener"
) %>
<% elsif @user.family.trialing? && !subscription_pending? %>
<% else %>
<%= render LinkComponent.new(
text: "Choose plan",
variant: "primary",

View file

@ -18,7 +18,7 @@
<%= image_tag "logo-color.png", class: "w-16 mb-6" %>
<% if Current.family.trialing? %>
<p class="text-xl lg:text-3xl text-primary font-display font-medium">Your trial has <%= Current.family.trial_remaining_days %> days remaining</p>
<p class="text-xl lg:text-3xl text-primary font-display font-medium">Your trial has <%= Current.family.days_left_in_trial %> days remaining</p>
<% else %>
<p class="text-xl lg:text-3xl text-primary font-display font-medium">Your trial is over</p>
<% end %>
@ -33,8 +33,8 @@
<%= form_with url: new_subscription_path, method: :get, class: "max-w-xs", data: { turbo: false } do |form| %>
<div class="space-y-4 mb-6">
<%= render "subscriptions/plan_choice", form: form, plan: "annual", checked: params[:plan] == "annual" || params[:plan].blank? %>
<%= render "subscriptions/plan_choice", form: form, plan: "monthly", checked: params[:plan] == "monthly" %>
<%= render "subscriptions/plan_choice", form: form, plan: "annual", checked: @plan == "annual" %>
<%= render "subscriptions/plan_choice", form: form, plan: "monthly", checked: @plan == "monthly" %>
</div>
<div class="text-center space-y-2">