123456789101112131415161718192021222324252627282930 |
- package stripe
- import (
- "fmt"
- "os"
- "github.com/stripe/stripe-go/v81"
- "github.com/stripe/stripe-go/v81/account"
- )
- // Initialize sets up the Stripe client with the provided API key
- func Initialize() error {
- apiKey := os.Getenv("STRIPE_SECRET_KEY")
- if apiKey == "" {
- return fmt.Errorf("STRIPE_SECRET_KEY environment variable is not set")
- }
- // Set the API key for the Stripe client
- stripe.Key = apiKey
- // Test the connection
- acc, err := account.Get()
- if err != nil {
- return fmt.Errorf("failed to connect to Stripe: %v", err)
- }
- fmt.Printf("Stripe account: %+v\n", acc)
- return nil
- }
|