Repository navigation
feat: promotions, the after-checkout section, and component stories #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b82b4c2
fix: show the interval toggle only when a plan has more than one inte…
roble 1fc8497
feat: promotions shown on the pricing page, applied at checkout (sc-1…
roble 4ff89b3
feat: push promotions drafted locally, and a launch promotion in the …
roble 3abdfdf
Merge branch 'renanroble-sc-1240-billing-promotions' into dev
roble b5b0c6a
fix: a provider code with other terms is never adopted, shown or sent
roble ca14da3
Merge branch 'renanroble-sc-1240-billing-promotions' into dev
roble f8d4366
feat: the merchant chooses the settings section a buyer lands on afte…
roble fed87e9
feat: stories for PlanFeatures, ProductCard, ProductSection and Check…
roble 68b3aad
Merge nightly/2026-11-26-module-stories: stories (Vue, React)
roble d2acf43
fix: forms pass their own validation errors to InputField
roble fc28338
fix: a restricted promotion code is typed on Stripe's page, never pre…
roble 84cf5da
Merge renanroble-release-review-billing
roble 520fb2c
test: ProductFactory draws one unique name for slug and SKU
roble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?php | ||
|
|
||
| namespace Modules\Billing\Database\Factories; | ||
|
|
||
| use Illuminate\Database\Eloquent\Factories\Factory; | ||
| use Modules\Billing\Models\Promotion; | ||
|
|
||
| /** | ||
| * @extends Factory<Promotion> | ||
| */ | ||
| class PromotionFactory extends Factory | ||
| { | ||
| protected $model = Promotion::class; | ||
|
|
||
| /** @return array<string, mixed> */ | ||
| public function definition(): array | ||
| { | ||
| return [ | ||
| 'provider' => 'stripe', | ||
| 'provider_promotion_code_id' => 'promo_'.fake()->regexify('[A-Za-z0-9]{24}'), | ||
| 'code' => strtoupper(fake()->unique()->bothify('LAUNCH-####')), | ||
| 'percent_off' => null, | ||
| 'amount_off' => 1000, | ||
| 'currency' => 'USD', | ||
| 'duration' => 'once', | ||
| 'duration_in_months' => null, | ||
| 'max_redemptions' => null, | ||
| 'times_redeemed' => 0, | ||
| 'expires_at' => null, | ||
| 'is_active' => true, | ||
| ]; | ||
| } | ||
| } |
64 changes: 64 additions & 0 deletions
64
database/migrations/1000_00_02_000001_create_promotions_table.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
| use Modules\Billing\Models\Promotion; | ||
|
|
||
| /** | ||
| * A promotion is a provider's promotion code the pricing page shows. The | ||
| * provider enforces it; these columns are what the page reads, so rendering | ||
| * never calls the provider. Its own migration, so existing installs get it. | ||
| */ | ||
| return new class extends Migration | ||
| { | ||
| public function up(): void | ||
| { | ||
| Schema::create('promotions', function (Blueprint $table) { | ||
| $table->id(); | ||
|
|
||
| $table->string('provider'); | ||
| // Null until pushed: a promotion drafted here (the demo's), like a price. | ||
| $table->string('provider_promotion_code_id')->nullable(); | ||
| $table->string('code'); | ||
|
|
||
| // One of the two, as the provider's coupon has it. | ||
| $table->decimal('percent_off', 5, 2)->nullable(); | ||
| $table->unsignedBigInteger('amount_off')->nullable(); | ||
| $table->string('currency', 3)->nullable(); | ||
|
|
||
| // once, repeating (for duration_in_months) or forever. | ||
| $table->string('duration')->default('once'); | ||
| $table->unsignedInteger('duration_in_months')->nullable(); | ||
|
|
||
| $table->unsignedInteger('max_redemptions')->nullable(); | ||
| $table->unsignedInteger('times_redeemed')->default(0); | ||
| $table->timestamp('expires_at')->nullable(); | ||
| $table->boolean('is_active')->default(true); | ||
|
|
||
| $table->timestamps(); | ||
|
|
||
| $table->unique(['provider', 'provider_promotion_code_id']); | ||
| }); | ||
|
|
||
| // One promotion per price, by construction. | ||
| Schema::table('prices', function (Blueprint $table) { | ||
| $table->foreignIdFor(Promotion::class)->nullable()->after('product_id')->constrained()->nullOnDelete(); | ||
| $table->index('promotion_id'); | ||
| }); | ||
|
|
||
| // What the buyer saved, and with which code: kept on the payment, so it | ||
| // outlives the promotion. | ||
| Schema::table('payments', function (Blueprint $table) { | ||
| $table->unsignedBigInteger('discount_amount')->default(0)->after('amount_refunded'); | ||
| $table->string('promotion_code')->nullable()->after('discount_amount'); | ||
| }); | ||
| } | ||
|
|
||
| public function down(): void | ||
| { | ||
| Schema::table('payments', fn (Blueprint $table) => $table->dropColumn(['discount_amount', 'promotion_code'])); | ||
| Schema::table('prices', fn (Blueprint $table) => $table->dropConstrainedForeignIdFor(Promotion::class)); | ||
| Schema::dropIfExists('promotions'); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
database/settings/0001_01_01_000020_add_after_checkout_section_to_billing_settings.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?php | ||
|
|
||
| use Spatie\LaravelSettings\Migrations\SettingsMigration; | ||
|
|
||
| return new class extends SettingsMigration | ||
| { | ||
| public function up(): void | ||
| { | ||
| // Where buyers already landed, so an installed app changes nothing. | ||
| if (! $this->migrator->exists('billing.after_checkout_section')) { | ||
| $this->migrator->add('billing.after_checkout_section', 'billing'); | ||
| } | ||
| } | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not attach an existing
LAUNCHwith different terms.If the database already contains
LAUNCHwithamount_off=1000,firstOrCreatereturns that promotion unchanged. Line 107 then attaches it to Lifetime. The 29900 price becomes 28900, not the intended 19900. An existing percentage promotion also remains unchanged.Before reusing the promotion, check its provider and offer terms. If they differ, warn and skip the association, or use a distinct showcase code. Preserve the provider ID and redemption count when the existing offer matches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid. Filed as sc-1260, https://app.shortcut.com/saucebase/story/1260; not blocking this release.