TWCA is a Go library for Taiwan Certificate Authority (TWCA) services.
go get github.com/flc1125/go-twca
package main
import (
"context"
"time"
"github.com/flc1125/go-twca/mid"
)
var ctx = context.Background()
func init() {
time.Local = time.UTC
}
func main() {
client := mid.New(&mid.Config{
Addr: "https://midonlinetest.twca.com.tw",
BusinessNo: ".....",
HashKeyNo: ".....",
HashKey: ".....",
})
// MIDClause
resp, err := client.Clause(ctx)
if err != nil {
panic(err)
}
_ = resp
// ServerSideTransaction
resp2, err := client.ServerSideTransaction(ctx, mid.ServerSideTransactionRequest{
VerifyNo: mid.DefaultGenerator.Generate(),
MemberNo: ".....",
Action: mid.ValidateMSISDNAdvanceAction,
MIDInputParams: &mid.MIDInputParams{
Msisdn: ".....",
Birthday: nil,
ClauseVer: ".....",
ClauseTime: ".....",
},
})
if err != nil {
panic(err)
}
_ = resp2
// ServerSideVerifyResult
resp3, err := client.ServerSideVerifyResult(ctx, mid.ServerSideVerifyResultRequest{
VerifyNo: resp2.VerifyNo,
MemberNo: resp2.OutputParams.MemberNo,
Token: resp2.OutputParams.Token,
})
if err != nil {
panic(err)
}
_ = resp3
}