Documentation ¶
Index ¶
Constants ¶
View Source
const ( Staging EnvironmentType Production API APIType SNAP Error LogType Info Debug Err002 = "required parameter is missing, " Err004 = "parameter has illegal value, " Err007 = "signature is invalid, " Err008 = "payement method is not available, " Err019 = "payment method error, " Err020 = "duplicate order id, " ErrUnknown = "unknown error, " )
Variables ¶
View Source
var ( Environment = Staging DefaultAPIType = SNAP DefaultHttpTimeout = time.Second * time.Duration(10) DefaultLogLevel = Info DefaultLogFormat = "{\"timestamp\":\"%s\",\"log_type\":\"%s\",\"event\":\"%s\",\"detail\":\"%s\"}" DefaultHttpClient = &http.Client{Timeout: DefaultHttpTimeout} Logger = func(logtype LogType, event string, detail interface{}) { timestamp := time.Now().UTC().Format("2006-01-02 15:04:05") var jsonFormat []byte switch v := detail.(type) { case error: jsonFormat = []byte(v.Error()) case string: jsonFormat = []byte(v) case map[string]interface{}: jsonFormat, _ = json.Marshal(detail) default: jsonFormat = []byte("Someting error.") } if logtype.CheckLevel() { newLog.Printf(DefaultLogFormat, timestamp, logtype.ToString(), event, jsonFormat) } } )
Functions ¶
This section is empty.
Types ¶
type EnvironmentType ¶
type EnvironmentType uint8
func (EnvironmentType) BaseUrl ¶
func (e EnvironmentType) BaseUrl() string
BaseUrl To get Midtrans Base URL
type HTTPClient ¶
type HTTPClient interface {
RequestDo(method string, url string, bodyJson []byte, token string, signature string) ([]byte, error)
}
func GetHTTPClient ¶
func GetHTTPClient() HTTPClient
type HttpClientImp ¶
Click to show internal directories.
Click to hide internal directories.