Skip to content

Commit

Permalink
Feat: Add Annual Plan (#116)
Browse files Browse the repository at this point in the history
* Update plans.yml

* Update new plans in test creds

* Add annual plan

* Update tests

* Free plan cannot be checked out
  • Loading branch information
chtzvt authored Apr 1, 2024
1 parent 18485c0 commit d1206c5
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/models/business_subscription_checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ def initialize(user:, plan: nil, success_path: nil)
end

def url
return "/" if @plan == "free"

checkout.url
end

private

def checkout
return nil if @plan == "free"

user.set_payment_processor(:stripe)
user.payment_processor.checkout(
mode: "subscription",
Expand Down
8 changes: 6 additions & 2 deletions app/models/businesses/permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def legacy_subscription?
end

def pays_hiring_fee?
full_time_subscription?
full_time_subscription? || part_time_subscription? || annual_subscription? || free_subscription?
end

def can_message_developer?(role_type:)
if legacy_subscription? || full_time_subscription? || free_subscription?
if legacy_subscription? || full_time_subscription? || annual_subscription? || free_subscription?
true
elsif part_time_subscription? && !role_type.only_full_time_employment?
true
Expand All @@ -45,6 +45,10 @@ def part_time_subscription?
active_subscriptions(:part_time).any?
end

def annual_subscription?
active_subscriptions(:annual).any?
end

def free_subscription?
active_subscriptions(:free).any?
end
Expand Down
14 changes: 13 additions & 1 deletion app/views/pricing/_plan.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,19 @@
</p>
<div class="mt-6">
<div class="rounded-md shadow">
<%= render "pricing/purchase_button", plan: :full_time, classes: "block w-full flex items-center justify-center rounded-md border border-transparent bg-blue-800 px-5 py-3 text-base font-medium text-white hover:bg-blue-900" %>
<%= render "pricing/purchase_button", title: t(".cta_monthly"), plan: :full_time, classes: "block w-full flex items-center justify-center rounded-md border border-transparent bg-blue-800 px-5 py-3 text-base font-medium text-white hover:bg-blue-900" %>
</div>
</div>
<div class="mt-10 flex items-center justify-center text-5xl font-bold tracking-tight text-blue-900">
<span>$1,010</span>
<span class="ml-2 text-xl font-medium tracking-normal text-blue-950"><%= t(".per_year") %></span>
</div>
<p class="mt-4 text-sm">
<a href="#hiring-fee" class="font-medium text-blue-950 underline"><%= t(".hiring_fee") %></a>
</p>
<div class="mt-6">
<div class="rounded-md shadow">
<%= render "pricing/purchase_button", title: t(".cta_annual"), plan: :annual, classes: "block w-full flex items-center justify-center rounded-md border border-transparent bg-blue-800 px-5 py-3 text-base font-medium text-white hover:bg-blue-900" %>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/pricing/_purchase_button.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= button_to t(".title"),
<%= button_to title || t(".title"),
stripe_checkout_path(plan: plan),
method: :post,
data: {
Expand Down
5 changes: 4 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ en:
title: Ready to get started?
faq:
annual:
a_html: Yes! Email the Tampa Devs Talent team to set up discounted annual billing at <a href='mailto:jobs@tampadevs.com' class='underline'>jobs@tampadevs.com</a>.
a_html: Yes! We offer a monthly plan at $99/mo and an annual plan at $1,010/year (a 15% savings)
q: Can I pay annually or yearly?
cancellation:
a_html: Yes! You can cancel your subscription from the Billing link in the user drop-down. You will lose access to all paid features at the end of your billing period.
Expand All @@ -790,6 +790,8 @@ en:
description: Directly connect with hundreds of local developers in Tampa Bay looking for their next job.
title: Hire developers in Tampa Bay
plan:
cta_annual: Go Annual and Save 15%
cta_monthly: Go Monthly. Cancel Anytime
description: Hire directly from a pool of local developers in Tampa Bay, at all levels of experience.
features:
climate_html: We donate 1% of revenue to fight climate change. <a style="text-decoration:underline" href="https://climate.stripe.com/nxdibE">Learn more</a>
Expand All @@ -801,6 +803,7 @@ en:
warranty: 90 day placement warranty
hiring_fee: "+ 5% first year salary"
per_month: "/month"
per_year: "/year"
title_html: For your 1<sup>st</sup> hire and beyond
purchase_button:
title: Get started today
Expand Down
9 changes: 7 additions & 2 deletions test/components/businesses/hiring_fee_component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ class HiringFeeComponentTest < ViewComponent::TestCase
assert_text "Have you hired"
end

test "doesn't render if not on a full-time subscription" do
test "renders for all subscription types" do
@conversation.update!(created_at: 2.weeks.ago - 1.day)
update_subscription(:part_time)

render_inline HiringFeeComponent.new(@user, @conversation)
assert_no_text "Have you hired"
assert_text "Have you hired"

update_subscription(:annual)

render_inline HiringFeeComponent.new(@user, @conversation)
assert_text "Have you hired"
end

test "doesn't render if the conversation is not eligible for the fee" do
Expand Down
12 changes: 10 additions & 2 deletions test/models/businesses/permission_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ class Businesses::PermissionTest < ActiveSupport::TestCase
assert permission.legacy_subscription?
end

test "required to pay hiring fee for full-time subscriptions" do
test "required to pay hiring fee for all subscription types" do
customer = pay_customers(:one)
permission = Businesses::Permission.new(customer.subscriptions)
assert permission.pays_hiring_fee?

update_subscription(:part_time)
permission = Businesses::Permission.new(customer.subscriptions)
refute permission.pays_hiring_fee?
assert permission.pays_hiring_fee?

update_subscription(:annual)
permission = Businesses::Permission.new(customer.subscriptions)
assert permission.pays_hiring_fee?

update_subscription(:free)
permission = Businesses::Permission.new(customer.subscriptions)
assert permission.pays_hiring_fee?
end

test "part-time subscriptions can't message developers only looking for full-time roles" do
Expand Down

0 comments on commit d1206c5

Please sign in to comment.