2026-04-10 21:08:51 +08:00
|
|
|
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 {
|
2026-04-11 00:25:41 +08:00
|
|
|
case payment.TypeEasyPay:
|
2026-04-10 21:08:51 +08:00
|
|
|
return NewEasyPay(instanceID, config)
|
2026-04-11 00:25:41 +08:00
|
|
|
case payment.TypeAlipay:
|
2026-04-10 21:08:51 +08:00
|
|
|
return NewAlipay(instanceID, config)
|
2026-04-11 00:25:41 +08:00
|
|
|
case payment.TypeWxpay:
|
2026-04-10 21:08:51 +08:00
|
|
|
return NewWxpay(instanceID, config)
|
2026-04-11 00:25:41 +08:00
|
|
|
case payment.TypeStripe:
|
2026-04-10 21:08:51 +08:00
|
|
|
return NewStripe(instanceID, config)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("unknown provider key: %s", providerKey)
|
|
|
|
|
}
|
|
|
|
|
}
|