Skip to content
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

Updated Cashier to v15 #858

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Services/PayPalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@
$this->user->save();

$sub = new Subscription();
$sub->user_id = $this->user->id; // @phpstan-ignore-line

Check failure on line 91 in app/Services/PayPalService.php

View workflow job for this annotation

GitHub Actions / PHP 8.3

No error to ignore is reported on line 91.
$sub->name = 'kanka'; // @phpstan-ignore-line
$sub->type = 'kanka'; // @phpstan-ignore-line

Check failure on line 92 in app/Services/PayPalService.php

View workflow job for this annotation

GitHub Actions / PHP 8.3

No error to ignore is reported on line 92.
$sub->stripe_id = 'manual_sub_' . uniqid(); // @phpstan-ignore-line

Check failure on line 93 in app/Services/PayPalService.php

View workflow job for this annotation

GitHub Actions / PHP 8.3

No error to ignore is reported on line 93.
spitfire305 marked this conversation as resolved.
Show resolved Hide resolved
$sub->stripe_status = 'canceled'; // @phpstan-ignore-line

Check failure on line 94 in app/Services/PayPalService.php

View workflow job for this annotation

GitHub Actions / PHP 8.3

No error to ignore is reported on line 94.
$sub->stripe_price = 'paypal_' . $this->user->pledge; // @phpstan-ignore-line

Check failure on line 95 in app/Services/PayPalService.php

View workflow job for this annotation

GitHub Actions / PHP 8.3

No error to ignore is reported on line 95.
$sub->quantity = 1; // @phpstan-ignore-line

Check failure on line 96 in app/Services/PayPalService.php

View workflow job for this annotation

GitHub Actions / PHP 8.3

No error to ignore is reported on line 96.
$sub->ends_at = Carbon::now()->addYear(); // @phpstan-ignore-line

Check failure on line 97 in app/Services/PayPalService.php

View workflow job for this annotation

GitHub Actions / PHP 8.3

No error to ignore is reported on line 97.
$sub->save();
} else {
// Add the subscription to the user level
Expand Down
2 changes: 1 addition & 1 deletion app/Services/SubscriptionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public function sourceCharge(array $payload)

\Laravel\Cashier\Subscription::create([
'user_id' => $this->user->id,
'name' => 'kanka',
'type' => 'kanka',
'stripe_id' => $source->method . '_' . $source->id,
'stripe_status' => 'active',
'stripe_price' => $source->plan(),
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"http-interop/http-factory-guzzle": "^1.2",
"ilestis/kanka-dnd5e-monster": "^5.0",
"intervention/image": "^2.4",
"laravel/cashier": "^14.0",
"laravel/cashier": "^15.0",
"laravel/framework": "^10.0",
"laravel/passport": "^11.0",
"laravel/scout": "^10.5",
Expand Down
276 changes: 141 additions & 135 deletions composer.lock

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions database/migrations/2019_05_03_000001_create_customer_columns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('stripe_id')->nullable()->index();
$table->string('pm_type')->nullable();
$table->string('pm_last_four', 4)->nullable();
$table->timestamp('trial_ends_at')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn([
'stripe_id',
'pm_type',
'pm_last_four',
'trial_ends_at',
]);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id');
$table->string('name');
$table->string('stripe_id')->unique();
$table->string('stripe_status');
$table->string('stripe_price')->nullable();
$table->integer('quantity')->nullable();
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();

$table->index(['user_id', 'stripe_status']);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('subscriptions');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('subscription_items', function (Blueprint $table) {
$table->id();
$table->foreignId('subscription_id');
$table->string('stripe_id')->unique();
$table->string('stripe_product');
$table->string('stripe_price');
$table->integer('quantity')->nullable();
$table->timestamps();

$table->index(['subscription_id', 'stripe_price']);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('subscription_items');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('subscriptions', function (Blueprint $table) {
$table->renameColumn('name', 'type');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('subscriptions', function (Blueprint $table) {
$table->renameColumn('type', 'name');
});
}
};
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function asUser(bool $subscribed = false): self

$sub = new Subscription();
$sub->user_id = $user->id; // @phpstan-ignore-line
$sub->name = 'kanka'; // @phpstan-ignore-line
$sub->type = 'kanka'; // @phpstan-ignore-line
$sub->stripe_id = 'manual_sub_' . uniqid(); // @phpstan-ignore-line
$sub->stripe_status = 'canceled'; // @phpstan-ignore-line
$sub->stripe_price = 'paypal_' . $user->pledge; // @phpstan-ignore-line
Expand Down
Loading