@@ -2,11 +2,13 @@ package site
22
33import (
44 "encoding/json"
5+ "errors"
56 "fmt"
67 "net/http"
78
89 "github.com/MakeNowJust/heredoc"
910 "github.com/loginradius/lr-cli/api"
11+ "github.com/loginradius/lr-cli/cmdutil"
1012 "github.com/loginradius/lr-cli/config"
1113 "github.com/loginradius/lr-cli/request"
1214 "github.com/spf13/cobra"
@@ -16,6 +18,7 @@ var AppName string
1618var Domain string
1719var PlanName string
1820var planOption string
21+ var option string
1922var AppsInfo * api.CoreAppData
2023
2124type AddAppResponse struct {
@@ -49,6 +52,15 @@ func addSite() error {
4952 fmt .Println ("Please upgrade your plan to add more sites. " )
5053 return nil
5154 }
55+
56+ checkCard , err := cardDetails ()
57+ if err != nil {
58+ return err
59+ }
60+ if ! checkCard {
61+ return nil
62+ }
63+
5264 checkInput := input ()
5365 if ! checkInput {
5466 fmt .Println ("Please enter the input paramaters properly." )
@@ -112,6 +124,29 @@ func plans() (bool, error) {
112124 return false , nil
113125}
114126
127+ func cardDetails () (bool , error ) {
128+ conf := config .GetInstance ()
129+ paymentInfo , err := api .PaymentInfo ()
130+ if err != nil {
131+ return false , err
132+ }
133+ paymentMethodId := paymentInfo .Data .Order [0 ].Paymentdetail .Stripepaymentmethodid
134+ if paymentMethodId == "" {
135+ fmt .Println ("Adding more than one app requires valid payment information. Please update card details in dashboard via browser." )
136+ fmt .Println ("(Note: User must re-login after updating details in the browser)" )
137+ fmt .Printf ("Press Y to open Browser window:" )
138+ fmt .Scanf ("%s" , & option )
139+ if option != "Y" {
140+ return false , errors .New ("Action not possible without updating card details." )
141+ }
142+ cmdutil .Openbrowser (conf .DashboardDomain + "/apps" )
143+ fmt .Println ("Please Re-Login via CLI." )
144+ return false , nil
145+ }
146+ return true , nil
147+
148+ }
149+
115150func add () error {
116151 conf := config .GetInstance ()
117152 paymentInfo , err := api .PaymentInfo ()
0 commit comments