From 2c485ef89b5cfe37b88b1d50fd6d5c219370bbc6 Mon Sep 17 00:00:00 2001 From: Manager Bot Date: Wed, 30 Nov 2022 13:55:17 +0000 Subject: [PATCH] Better register? --- Web/lib/MJB/Web.pm | 1 + Web/lib/MJB/Web/Controller/Auth.pm | 15 +++++++++++++++ Web/lib/MJB/Web/Controller/UserSettings.pm | 9 ++++----- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Web/lib/MJB/Web.pm b/Web/lib/MJB/Web.pm index 2daa1ab..6c56c6e 100644 --- a/Web/lib/MJB/Web.pm +++ b/Web/lib/MJB/Web.pm @@ -178,6 +178,7 @@ sub startup ($self) { $r->post ( '/register/invite' )->to( 'Auth#do_register_invite' )->name('do_register_invite' ); $r->get ( '/register/stripe' )->to( 'Auth#register_stripe' )->name('show_register_stripe' ); $r->post ( '/register/stripe' )->to( 'Auth#do_register_stripe' )->name('do_register_stripe' ); + $r->get ( '/register/stripe/pay' )->to( 'Auth#register_stripe_pay' )->name('show_register_stripe_pay' ); $r->get ( '/login' )->to( 'Auth#login' )->name('show_login' ); $r->post ( '/login' )->to( 'Auth#do_login' )->name('do_login' ); $auth->get( '/logout' )->to( 'Auth#do_logout' )->name('do_logout' ); diff --git a/Web/lib/MJB/Web/Controller/Auth.pm b/Web/lib/MJB/Web/Controller/Auth.pm index ec0b1d8..14990ff 100644 --- a/Web/lib/MJB/Web/Controller/Auth.pm +++ b/Web/lib/MJB/Web/Controller/Auth.pm @@ -272,6 +272,21 @@ sub do_register_stripe ( $c ) { # Log the user in and send them to the dashboard. $c->session->{uid} = $person->id; + $c->redirect_to( $c->url_for( 'show_register_stripe_pay' ) ); +} + +#== +# GET /register/stripe/pay | show_register_stripe_pay | N/A +# +# Once a user has registered in the strip work flow, they will need to pay +# for their account before it is enabled. This route will bring them to the +# stripe subscription payment page. +#== +sub register_stripe_pay ( $c ) { + # Don't allow this user registration method unless register.enable_open is true. + return $c->redirect_to( $c->url_for( 'show_register' ) ) + unless $c->config->{register}{enable_stripe}; + $c->redirect_to( $c->ua->get( $c->config->{stripe}->{backend} . '/stripe/get-checkout-link?lookup_key=' . $c->config->{stripe}->{lookup_key} )->result->json->{url} ); diff --git a/Web/lib/MJB/Web/Controller/UserSettings.pm b/Web/lib/MJB/Web/Controller/UserSettings.pm index 471e655..f48d54d 100644 --- a/Web/lib/MJB/Web/Controller/UserSettings.pm +++ b/Web/lib/MJB/Web/Controller/UserSettings.pm @@ -134,14 +134,13 @@ sub subscription ($c) { $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( - success => 1, - success_message => 'Thank you for signing up!', - ); + + $c->flash( confirmation => "Thank you for signing up!" ); + $c->redirect_to( $c->url_for( 'show_dashboard' ) ); } # Send to stripe to signup for the subscription