Skip to content

Commit

Permalink
Add GPay support ✅
Browse files Browse the repository at this point in the history
  • Loading branch information
LuD1161 committed May 12, 2022
1 parent 0a2574b commit 501509a
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions cmd/checkGpay.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"os"
"strings"

"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// checkGpayCmd represents the checkGpay command
var checkGpayCmd = &cobra.Command{
Use: "checkGpay EMAIL_ID",
Short: "Check gmail id corresponding to GPay suffixes.",
Run: func(cmd *cobra.Command, args []string) {
api_key := viper.Get("RAZORPAY_LIVE_API_KEY").(string)
if len(args) > 0 {
gpaySuffixes, err := readLines("data/gpay_suffixes.txt")
if err != nil {
log.Error().Msg("Error reading 'data/gpay_suffixes.txt'")
os.Exit(1)
}
vpa_suffix, email_id := args[0], args[0]
if strings.HasSuffix(email_id, "@gmail.com") {
vpa_suffix = email_id[:len(email_id)-10]
}
checkUpi(vpa_suffix, gpaySuffixes, api_key)
} else {
log.Error().Msgf("❌ Please enter vehicle registration number")
cmd.Help()
}
},
}

func init() {
rootCmd.AddCommand(checkGpayCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// checkGpayCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// checkGpayCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

0 comments on commit 501509a

Please sign in to comment.