Files
sealos/controllers/pkg/pay/stripe_payment_test.go
Jiahui ea8e5cf0a9 feat(account): Add workspace subscription plan (#6103)
* initialize the data structure

* Initialize the lifecycle management of workspace subscriptions

* fix index

* add workspace subscription debt

* optimize parse period & init workspace subscription & fix subscription create bug

* remove quota controller

* add user notify framework:
content_generator:content generation
service:event notification service
providers:vms/sms/email ... provider implementation
types: core structure type definition

* optimize struct & adjust the database to obtain data

* Implement the initialization of subscriptions and the implementation of subscription traffic packages

* service implement the database layer

* auto add column payment.stripe

* add stripe pay interface

* add workspace subscription service

* add the usercr tag for subscription based spaces, Add delete workspace subscription operator & Add api interfaces related to obtaining workspace costs

* optimize interface

* overall adjustment and repair

* optimize traffic early warning notifications

* optimize traffic early warning notifications

* optimize

* optimize & add deletion account api

* optimize log

* add get payment status api && support workspace subscription AI quota package

* optimize

* Fixed the issue where traffic was not distributed after renewing the subscription package

* fix

* fix workspace subscription transaction process add ai quota package

* fix ci lint

* fix controller/account ci lint

* fix controller/pkg ci lint

* fix controller/account ci lint

* fix controller/pkg ci lint

* add admin add workspace subscription

* fix upgrade workspace subscription

* add get workspace subscription plans api

* add get workspace subscription plans api

* fix ci lint

* fix ci lint

* fix ci lint
2025-10-26 16:15:52 +08:00

80 lines
2.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright © 2024 sealos.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package pay
import (
"testing"
)
func TestCreateCheckoutSession(t *testing.T) {
stripe, err := CreateCheckoutSession(
2000,
"cny",
"http://localhost:8080",
"http://localhost:8080",
)
if err != nil {
t.Error(err)
}
t.Log(stripe.ID)
}
// func setupEnv_stripe() {
// const (
// APIKEY = ""
// )
// // check that the environment variables are set
// if os.Getenv(StripeAPIKEY) == "" {
// err := os.Setenv(StripeAPIKEY, APIKEY)
// if err != nil {
// log.Fatalf("failed to set environment variables: %v", err)
// }
// }
//
// // sandboxEnvironment
// err := os.Setenv(StripeAPIKEY, "true")
// if err != nil {
// return
// }
//}
// func TestStripsPayment_PaymentAndRefund(t *testing.T) {
// setupEnv_stripe()
// stripe.Key = os.Getenv(StripeAPIKEY)
//
// // 1. create a payment intent
// piParams := &stripe.PaymentIntentParams{
// Amount: stripe.Int64(2000), // 2000 分 = ¥20.00
// Currency: stripe.String(string(stripe.CurrencyCNY)),
// PaymentMethodTypes: stripe.StringSlice([]string{"card"}), // pay with a card
// }
// pi, err := paymentintent.New(piParams)
// if err != nil {
// t.Fatalf("failed to create a payment intent: %v", err)
// }
// t.Logf("PaymentIntent the creation is successfulID=%s", pi.ID)
//
// // 2. perform a partial refund for that payment intent
// refundParams := &stripe.RefundParams{
// PaymentIntent: stripe.String(pi.ID),
// Amount: stripe.Int64(1000), // refund 1000 cent = ¥10.00
// }
// r, err := refund.New(refundParams)
// if err != nil {
// t.Fatalf("refund failed: %v", err)
// }
// t.Logf("the refund was successfulRefund ID=%srefund amount=%d", r.ID, r.Amount)
//}