Categorygithub.com/flc1125/go-twca
repositorypackage
1.0.8
Repository: https://github.com/flc1125/go-twca.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Go TWCA

Go Version GoDoc codecov Go Report Card lint test MIT license

TWCA is a Go library for Taiwan Certificate Authority (TWCA) services.

Installation

go get github.com/flc1125/go-twca

Usage

MID

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

}

License

MIT license