allowPromotionCodes(); } $couponId = config('cashier.first_month_coupon_id'); if (! is_string($couponId) || $couponId === '') { throw new RuntimeException( 'STRIPE_FIRST_MONTH_COUPON_ID must be set when REQUIRE_CARD_FOR_TRIAL is enabled, ' .'otherwise checkout would charge the full price instead of the $1 first month.' ); } return $subscription->withCoupon($couponId); } /** * The fixed-amount first-month coupon only applies to a genuinely new * customer checking out a single workspace: the fixed `amount_off` is only * correct for a quantity of one, and the $1 offer is for first-time signups * — not a returning account re-subscribing with workspaces it kept from a * lapsed subscription. */ private static function qualifiesForPaidFirstMonth(Account $account): bool { if (! (bool) config('trypost.billing.require_card_for_trial', true)) { return false; } return $account->workspaces()->count() === 1 && ! $account->subscriptions()->exists(); } }