feat(payment): add complete payment system with multi-provider support
Add a full payment and subscription system supporting EasyPay (Alipay/WeChat), Stripe, and direct Alipay/WeChat Pay providers with multi-instance load balancing.
This commit is contained in:
23
backend/internal/payment/provider/factory.go
Normal file
23
backend/internal/payment/provider/factory.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Wei-Shaw/sub2api/internal/payment"
|
||||
)
|
||||
|
||||
// CreateProvider creates a Provider from a provider key, instance ID and decrypted config.
|
||||
func CreateProvider(providerKey string, instanceID string, config map[string]string) (payment.Provider, error) {
|
||||
switch providerKey {
|
||||
case "easypay":
|
||||
return NewEasyPay(instanceID, config)
|
||||
case "alipay":
|
||||
return NewAlipay(instanceID, config)
|
||||
case "wxpay":
|
||||
return NewWxpay(instanceID, config)
|
||||
case "stripe":
|
||||
return NewStripe(instanceID, config)
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown provider key: %s", providerKey)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user