From 2eedb8114af027a875bbc2551e7f3182e5b27549 Mon Sep 17 00:00:00 2001 From: Manager Bot Date: Tue, 6 Dec 2022 02:30:31 +0000 Subject: [PATCH] Now with subscription table. --- Web/lib/MJB/Web/Controller/Auth.pm | 5 ++++- Web/lib/MJB/Web/Controller/UserSettings.pm | 7 +++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Web/lib/MJB/Web/Controller/Auth.pm b/Web/lib/MJB/Web/Controller/Auth.pm index 4e775eb..dade5f2 100644 --- a/Web/lib/MJB/Web/Controller/Auth.pm +++ b/Web/lib/MJB/Web/Controller/Auth.pm @@ -254,9 +254,12 @@ sub do_register_stripe ( $c ) { }); $person->new_related('auth_password', {})->set_password($c->param('password')); + # Create the subscription. + $person->subscription->insert; + # Notify the system about the new account. $c->db->system_notes->create({ - source => 'User Registration (Open)', + source => 'User Registration (Stripe)', content => 'An account was created for ' . $person->email, }); diff --git a/Web/lib/MJB/Web/Controller/UserSettings.pm b/Web/lib/MJB/Web/Controller/UserSettings.pm index f48d54d..e94b1fa 100644 --- a/Web/lib/MJB/Web/Controller/UserSettings.pm +++ b/Web/lib/MJB/Web/Controller/UserSettings.pm @@ -132,10 +132,9 @@ sub subscription ($c) { # Store the customer id along side the user in the DB. if ( $customer_id ) { $c->db->storage->schema->txn_do( sub { - $c->stash->{person}->stripe_customer_id( $customer_id ); - $c->stash->{person}->is_subscribed( 1 ); - $c->stash->{person}->is_enabled( 1 ); - $c->stash->{person}->update; + $c->stash->{person}->subscription->stripe_customer_id( $customer_id ); + $c->stash->{person}->subscription->is_valid( 1 ); + $c->stash->{person}->subscription->update; }); }