Skip to content

Commit

Permalink
Removes unecessary stripe flags
Browse files Browse the repository at this point in the history
  • Loading branch information
emmdim committed Dec 3, 2024
1 parent c094c7e commit e74d533
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
12 changes: 0 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ func main() {
flag.StringP("dbType", "t", db.TypePebble, fmt.Sprintf("key-value db type [%s,%s,%s]", db.TypePebble, db.TypeLevelDB, db.TypeMongo))
flag.String("stripeKey", "", "stripe secret key")
flag.String("stripeProductID", "", "stripe price id")
flag.Int64("stripeMinQuantity", 100, "stripe min number of tokens")
flag.Int64("stripeMaxQuantity", 100000, "stripe max number of tokens")
flag.String("stripeWebhookSecret", "", "stripe webhook secret key")
flag.Parse()

Expand Down Expand Up @@ -101,12 +99,6 @@ func main() {
if err := viper.BindPFlag("stripeProductID", flag.Lookup("stripeProductID")); err != nil {
panic(err)
}
if err := viper.BindPFlag("stripeMinQuantity", flag.Lookup("stripeMinQuantity")); err != nil {
panic(err)
}
if err := viper.BindPFlag("stripeMaxQuantity", flag.Lookup("stripeMaxQuantity")); err != nil {
panic(err)
}
if err := viper.BindPFlag("stripeWebhookSecret", flag.Lookup("stripeWebhookSecret")); err != nil {
panic(err)
}
Expand Down Expand Up @@ -150,8 +142,6 @@ func main() {
dbType := viper.GetString("dbType")
stripeKey := viper.GetString("stripeKey")
stripeProductID := viper.GetString("stripeProductID")
stripeMinQuantity := viper.GetInt64("stripeMinQuantity")
stripeMaxQuantity := viper.GetInt64("stripeMaxQuantity")
stripeWebhookSecret := viper.GetString("stripeWebhookSecret")

// parse auth types and amounts
Expand Down Expand Up @@ -217,8 +207,6 @@ func main() {
stripeKey,
stripeProductID,
stripeWebhookSecret,
stripeMinQuantity,
stripeMaxQuantity,
int64(amount),
&f,
storage,
Expand Down
6 changes: 1 addition & 5 deletions stripehandler/stripe.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
type StripeHandler struct {
Key string // The API key for the Stripe account.
ProductID string // The ID of the price associated with the product.
MinQuantity int64 // The minimum quantity allowed for the product.
MaxQuantity int64 // The maximum quantity allowed for the product.
DefaultAmount int64 // The default amount for the product.
WebhookSecret string // The secret used to verify Stripe webhook events.
Storage *storage.Storage // The storage instance for the faucet.
Expand All @@ -42,15 +40,13 @@ type ReturnStatus struct {
// NewStripeClient creates a new instance of the StripeHandler struct with the provided parameters.
// It sets the Stripe API key, price ID, webhook secret, minimum quantity, maximum quantity, and default amount.
// Returns a pointer to the created StripeHandler.
func NewStripeClient(key, productID, webhookSecret string, minQuantity, maxQuantity, defaultAmount int64, faucet *faucet.Faucet, storage *storage.Storage) (*StripeHandler, error) {
func NewStripeClient(key, productID, webhookSecret string, defaultAmount int64, faucet *faucet.Faucet, storage *storage.Storage) (*StripeHandler, error) {
if key == "" || productID == "" || webhookSecret == "" || storage == nil {
return nil, errors.New("missing required parameters")
}
stripe.Key = key
return &StripeHandler{
ProductID: productID,
MinQuantity: minQuantity,
MaxQuantity: maxQuantity,
DefaultAmount: defaultAmount,
WebhookSecret: webhookSecret,
Storage: storage,
Expand Down

0 comments on commit e74d533

Please sign in to comment.