ソースを参照

Fix registration form errors

master
Immanuel Onyeka 4ヶ月前
コミット
9cc4464d48
2個のファイルの変更14行の追加3行の削除
  1. +11
    -3
      grav-admin/user/js/registration/registration.vue
  2. +3
    -0
      skouter.go

+ 11
- 3
grav-admin/user/js/registration/registration.vue ファイルの表示

@@ -1,8 +1,8 @@
<template> <template>
<section class="shadowbox">
<section v-if="allow" class="shadowbox">
<h2>Register</h2> <h2>Register</h2>
<account v-if="step == 1" :err="err" @submit="create" /> <account v-if="step == 1" :err="err" @submit="create" />
<billing v-if="step == 2 && !trial" :err="err" :sub="sub"/>
<billing v-if="step == 2" :err="err" :sub="sub"/>
<completed v-if="step == 3" :err="err" :status="sub.paymentStatus"/> <completed v-if="step == 3" :err="err" :status="sub.paymentStatus"/>
</section> </section>
</template> </template>
@@ -20,6 +20,7 @@ const token = ref("")
const user = ref(null) const user = ref(null)
const sub = ref(null) const sub = ref(null)
const trial = ref(false) const trial = ref(false)
const allow = ref(true)


const clientSecret = new URLSearchParams(window.location.search).get( const clientSecret = new URLSearchParams(window.location.search).get(
'payment_intent_client_secret' 'payment_intent_client_secret'
@@ -111,8 +112,15 @@ onMounted(() => {
trial.value = true trial.value = true
} }
getUser().then( u => { getUser().then( u => {
if (u) { user.value = u; intent(u) }
if (u) { user.value = u; console.log(u); intent(u) }
// If user's account was not created through a trial form but the
// current path is /free-trial, hide the form.
if (u && u.status != "Trial" && trial.value) {
allow.value == false
}
}) })
}) })
</script> </script>


+ 3
- 0
skouter.go ファイルの表示

@@ -3123,6 +3123,7 @@ func createTrialSubscription(cid string) (*stripe.Subscription, error) {
} }
subscriptionParams.AddExpand("latest_invoice.payment_intent") subscriptionParams.AddExpand("latest_invoice.payment_intent")
s, err := subscription.New(subscriptionParams) s, err := subscription.New(subscriptionParams)

return s, err return s, err
} }
@@ -3217,6 +3218,7 @@ func subscribe(w http.ResponseWriter, db *sql.DB, r *http.Request) {
// existing instance if possible. It's main purpose is to supply a // existing instance if possible. It's main purpose is to supply a
// client secret used for sending billing information to stripe. // client secret used for sending billing information to stripe.
func trialSubscribe(w http.ResponseWriter, db *sql.DB, r *http.Request) { func trialSubscribe(w http.ResponseWriter, db *sql.DB, r *http.Request) {
stripe.Key = os.Getenv("STRIPE_SECRET_KEY")
claims, err := getClaims(r) claims, err := getClaims(r)
user, err := queryUser(db, claims.Id) user, err := queryUser(db, claims.Id)


@@ -3258,6 +3260,7 @@ func trialSubscribe(w http.ResponseWriter, db *sql.DB, r *http.Request) {
user.Sub.Start = int(s.CurrentPeriodStart) user.Sub.Start = int(s.CurrentPeriodStart)
user.Sub.ClientSecret = s.LatestInvoice.PaymentIntent.ClientSecret user.Sub.ClientSecret = s.LatestInvoice.PaymentIntent.ClientSecret
user.Sub.PaymentStatus = string(s.LatestInvoice.PaymentIntent.Status) user.Sub.PaymentStatus = string(s.LatestInvoice.PaymentIntent.Status)
user.Sub.Status = string(s.Status)
// Inserting from here is unnecessary and confusing because // Inserting from here is unnecessary and confusing because
// new subs are already handled by the stripe hook. It remains for // new subs are already handled by the stripe hook. It remains for


読み込み中…
キャンセル
保存