@@ -0,0 +1,10 @@ | |||||
package adapayCore | |||||
import ( | |||||
"fmt" | |||||
"log" | |||||
) | |||||
func Println(v ...interface{}) { | |||||
log.Println("<AdapayLog> " + fmt.Sprint(v...)) | |||||
} |
@@ -0,0 +1,62 @@ | |||||
package adapayCore | |||||
import ( | |||||
"encoding/json" | |||||
"errors" | |||||
"fmt" | |||||
"io/ioutil" | |||||
) | |||||
func ToString(v interface{}) string { | |||||
switch v.(type) { | |||||
case string: | |||||
return v.(string) | |||||
default: | |||||
r, _ := json.Marshal(v) | |||||
return string(r) | |||||
} | |||||
} | |||||
func DeepCopy(value interface{}) interface{} { | |||||
if valueMap, ok := value.(map[string]interface{}); ok { | |||||
newMap := make(map[string]interface{}) | |||||
for k, v := range valueMap { | |||||
newMap[k] = DeepCopy(v) | |||||
} | |||||
return newMap | |||||
} else if valueSlice, ok := value.([]interface{}); ok { | |||||
newSlice := make([]interface{}, len(valueSlice)) | |||||
for k, v := range valueSlice { | |||||
newSlice[k] = DeepCopy(v) | |||||
} | |||||
return newSlice | |||||
} | |||||
return value | |||||
} | |||||
func ReadMerchConfig(configPath string) (*MerchSysConfig, error) { | |||||
data, err := ioutil.ReadFile(configPath) | |||||
if err != nil { | |||||
return nil, errors.New( | |||||
fmt.Sprintf("ReadMerchConfig Read Config File Failed ---> path: %s", configPath)) | |||||
} | |||||
tmpMsc := MerchSysConfig{} | |||||
jsonError := json.Unmarshal(data, &tmpMsc) | |||||
if jsonError != nil { | |||||
return nil, errors.New( | |||||
fmt.Sprintf("ReadMerchConfig Read Config File Failed ---> path: %s", configPath)) | |||||
} | |||||
if tmpMsc.ApiKeyLive == "" || tmpMsc.ApiKeyTest == "" || | |||||
tmpMsc.RspPubKey == "" || tmpMsc.RspPriKey == "" { | |||||
return nil, errors.New( | |||||
fmt.Sprintf("ReadMerchConfig Read Config File Failed ---> path: %s", configPath)) | |||||
} | |||||
return &tmpMsc, nil | |||||
} |
@@ -0,0 +1,31 @@ | |||||
package adapayCore | |||||
type ApiError struct { | |||||
ErrorCode string `json:"error_code"` | |||||
ErrorMsg string `json:"error_msg"` | |||||
ErrorType string `json:"error_type"` | |||||
Status string `json:"status"` | |||||
InvalidParam string `json:"invalid_param"` | |||||
} | |||||
type MerchSysConfig struct { | |||||
ApiKeyLive string `json:"api_key_live"` | |||||
ApiKeyTest string `json:"api_key_test"` | |||||
RspPubKey string `json:"rsa_public_key"` | |||||
RspPriKey string `json:"rsa_private_key"` | |||||
} | |||||
func (msc *MerchSysConfig) IsEmpty() bool { | |||||
return msc.ApiKeyLive == "" || msc.ApiKeyTest == "" || msc.RspPubKey == "" || msc.RspPriKey == "" | |||||
} | |||||
var GDefaultMerchSysConfig = MerchSysConfig{} | |||||
var GMultiMerchSysConfigs = map[string]MerchSysConfig{} |
@@ -0,0 +1,262 @@ | |||||
package adapayCore | |||||
import ( | |||||
"bytes" | |||||
"encoding/json" | |||||
"errors" | |||||
"fmt" | |||||
"io" | |||||
"io/ioutil" | |||||
"mime/multipart" | |||||
"net/http" | |||||
"os" | |||||
"sort" | |||||
"strings" | |||||
) | |||||
func DeleteEmptyValue(src map[string]interface{}) map[string]interface{} { | |||||
resultMap := make(map[string]interface{}) | |||||
for key, value := range src { | |||||
if key != "" && value != nil && value != "" { | |||||
resultMap[key] = value | |||||
} | |||||
} | |||||
return resultMap | |||||
} | |||||
func FormatSignSrcText(method string, paramMap map[string]interface{}) (string, error) { | |||||
validParamMap := DeleteEmptyValue(paramMap) | |||||
if strings.EqualFold(method, "GET") { | |||||
keys := make([]string, 0) | |||||
for k := range validParamMap { | |||||
keys = append(keys, k) | |||||
} | |||||
sort.Strings(keys) | |||||
tmpList := make([]string, 0) | |||||
for i := range keys { | |||||
switch tmpValue := validParamMap[keys[i]]; tmpValue.(type) { | |||||
case string: | |||||
tmpList = append(tmpList, fmt.Sprintf("%s=%s", keys[i], tmpValue)) | |||||
continue | |||||
case interface{}: | |||||
rs, err := json.Marshal(tmpValue) | |||||
if err != nil || rs == nil || string(rs) == "" { | |||||
continue | |||||
} | |||||
tmpList = append(tmpList, fmt.Sprintf("%s=%s", keys[i], string(rs))) | |||||
continue | |||||
} | |||||
} | |||||
return strings.Join(tmpList, "&"), nil | |||||
} else if strings.EqualFold(method, "POST") { | |||||
postResult, postErr := json.Marshal(validParamMap) | |||||
return string(postResult), postErr | |||||
} else { | |||||
Println("FormatSignSrcText error ... msg: Incorrect method") | |||||
return "", errors.New("Unknow Method: \"" + method + "\"") | |||||
} | |||||
} | |||||
func FilterApiError(respBodyString string) (*ApiError, error) { | |||||
apiErrorResult := ApiError{} | |||||
jsonError := json.Unmarshal([]byte(respBodyString), &apiErrorResult) | |||||
if jsonError != nil { | |||||
return nil, errors.New(fmt.Sprintf("异常数据 ==> %s", respBodyString)) | |||||
} | |||||
if apiErrorResult.ErrorCode != "" { | |||||
return &apiErrorResult, nil | |||||
} | |||||
return nil, nil | |||||
} | |||||
func HandleResponse(resp *http.Response, msc *MerchSysConfig) (map[string]interface{}, *ApiError, error) { | |||||
resultData := make(map[string]interface{}) | |||||
if resp == nil { | |||||
return resultData, nil, errors.New(fmt.Sprintf("网络异常")) | |||||
} | |||||
defer func() { | |||||
_ = resp.Body.Close() | |||||
}() | |||||
body, err := ioutil.ReadAll(resp.Body) | |||||
if err != nil && (body == nil || string(body) == "") { | |||||
return resultData, nil, errors.New(fmt.Sprintf("Adapay 异常应答 ==> status_code<%d>, error_message<%s>", | |||||
resp.StatusCode, err.Error())) | |||||
} | |||||
respDataMap := make(map[string]string) | |||||
tmpJsonErr1 := json.Unmarshal(body, &respDataMap) | |||||
if tmpJsonErr1 != nil { | |||||
return resultData, nil, errors.New(fmt.Sprintf("解析 Adapay 应答数据异常 ==> %s", string(body))) | |||||
} | |||||
err = RsaSignVerify(respDataMap["signature"], respDataMap["data"], msc) | |||||
if err != nil { | |||||
return resultData, nil, errors.New("check signature error !") | |||||
} | |||||
apiErr, err := FilterApiError(respDataMap["data"]) | |||||
if err != nil { | |||||
return resultData, nil, errors.New(fmt.Sprintf("解析 Adapay 应答数据异常 ==> %s", err.Error())) | |||||
} | |||||
if apiErr != nil { | |||||
return resultData, apiErr, nil | |||||
} | |||||
jsonErr := json.Unmarshal([]byte(respDataMap["data"]), &resultData) | |||||
if jsonErr != nil { | |||||
return nil, nil, errors.New(fmt.Sprintf("解析返回数据异常 ==> %s", resultData)) | |||||
} | |||||
return resultData, nil, nil | |||||
} | |||||
func DoGetReq(url string, params map[string]interface{}, msc *MerchSysConfig) (*http.Response, error) { | |||||
params = DeleteEmptyValue(params) | |||||
paramText, _ := FormatSignSrcText("GET", params) | |||||
request, _ := http.NewRequest("GET", url+"?"+paramText, nil) | |||||
request.Header.Add("authorization", msc.ApiKeyLive) | |||||
request.Header.Add("sdk_version", "go_v"+Version) | |||||
sign, _ := RsaSign(url+paramText, msc) | |||||
request.Header.Add("signature", sign) | |||||
return http.DefaultClient.Do(request) | |||||
} | |||||
func DoPostReq(url string, params map[string]interface{}, msc *MerchSysConfig) (*http.Response, error) { | |||||
params = DeleteEmptyValue(params) | |||||
paramText, _ := FormatSignSrcText("POST", params) | |||||
request, _ := http.NewRequest("POST", url, strings.NewReader(paramText)) | |||||
request.Header.Set("Content-Type", "application/json") | |||||
request.Header.Add("authorization", msc.ApiKeyLive) | |||||
request.Header.Add("sdk_version", "go_v"+Version) | |||||
sign, _ := RsaSign(url+paramText, msc) | |||||
request.Header.Add("signature", sign) | |||||
return http.DefaultClient.Do(request) | |||||
} | |||||
func DoUploadFile(url string, params map[string]interface{}, fileParamName string, msc *MerchSysConfig) (*http.Response, error) { | |||||
params = DeleteEmptyValue(params) | |||||
var filepath string | |||||
if str, ok := params[fileParamName].(string); ok { | |||||
filepath = str | |||||
} | |||||
file, err := os.Open(filepath) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
defer file.Close() | |||||
body := &bytes.Buffer{} | |||||
writer := multipart.NewWriter(body) | |||||
part, err := writer.CreateFormFile(fileParamName, filepath) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
_, err = io.Copy(part, file) | |||||
delete(params, fileParamName) | |||||
for key, val := range params { | |||||
if str, ok := val.(string); ok { | |||||
_ = writer.WriteField(key, str) | |||||
} | |||||
} | |||||
err = writer.Close() | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
request, err := http.NewRequest("POST", url, body) | |||||
paramText, _ := FormatSignSrcText("GET", params) | |||||
request.Header.Set("content-Type", writer.FormDataContentType()) | |||||
request.Header.Add("authorization", msc.ApiKeyLive) | |||||
request.Header.Add("sdk_version", "go_v"+Version) | |||||
sign, _ := RsaSign(url+paramText, msc) | |||||
request.Header.Add("signature", sign) | |||||
return http.DefaultClient.Do(request) | |||||
} | |||||
func GetMerchSysConfig(mscId string) MerchSysConfig { | |||||
if value, exist := GMultiMerchSysConfigs[mscId]; exist { | |||||
return value | |||||
} else { | |||||
return GDefaultMerchSysConfig | |||||
} | |||||
} | |||||
type RequestMethod string | |||||
const ( | |||||
POST RequestMethod = "POST" | |||||
GET RequestMethod = "GET" | |||||
UPLOAD RequestMethod = "UPLOAD" | |||||
) | |||||
func RequestAdaPay(reqUrl string, requestMethod RequestMethod, reqParam map[string]interface{}, msc *MerchSysConfig) (map[string]interface{}, *ApiError, error) { | |||||
data := make(map[string]interface{}) | |||||
var resp *http.Response | |||||
var err error | |||||
switch requestMethod { | |||||
case POST: | |||||
resp, err = DoPostReq(reqUrl, reqParam, msc) | |||||
break | |||||
case GET: | |||||
resp, err = DoGetReq(reqUrl, reqParam, msc) | |||||
break | |||||
} | |||||
if err != nil { | |||||
return data, nil, errors.New(fmt.Sprintf("网络异常 ==> %s", err.Error())) | |||||
} | |||||
data, apiErr, err := HandleResponse(resp, msc) | |||||
if apiErr != nil || err != nil { | |||||
return data, apiErr, err | |||||
} | |||||
return data, nil, nil | |||||
} | |||||
func UploadAdaPay(reqUrl string, reqParam map[string]interface{}, fileParamName string, msc *MerchSysConfig) (map[string]interface{}, *ApiError, error) { | |||||
data := make(map[string]interface{}) | |||||
var resp *http.Response | |||||
var err error | |||||
resp, err = DoUploadFile(reqUrl, reqParam, fileParamName, msc) | |||||
if err != nil { | |||||
return data, nil, errors.New(fmt.Sprintf("网络异常 ==> %s", err.Error())) | |||||
} | |||||
data, apiErr, err := HandleResponse(resp, msc) | |||||
if apiErr != nil || err != nil { | |||||
return data, apiErr, err | |||||
} | |||||
return data, nil, nil | |||||
} |
@@ -0,0 +1,120 @@ | |||||
package adapayCore | |||||
import ( | |||||
"crypto" | |||||
"crypto/rand" | |||||
"crypto/rsa" | |||||
"crypto/sha1" | |||||
"crypto/x509" | |||||
"encoding/base64" | |||||
"encoding/pem" | |||||
"errors" | |||||
"strings" | |||||
) | |||||
func RsaLongEncrypt(content string, msc *MerchSysConfig) (result string) { | |||||
return "" | |||||
} | |||||
func RsaLongDecrypt(content string, msc *MerchSysConfig) (result string) { | |||||
return "" | |||||
} | |||||
func RsaSign(content string, msc *MerchSysConfig) (result string, err error) { | |||||
privateKey, err := getPrivateKey(msc) | |||||
if err != nil { | |||||
return "", err | |||||
} else if privateKey == nil { | |||||
return "", errors.New("Error in get private key") | |||||
} | |||||
h := sha1.New() | |||||
h.Write([]byte([]byte(content))) | |||||
hash := h.Sum(nil) | |||||
signature, err := rsa.SignPKCS1v15(rand.Reader, privateKey.(*rsa.PrivateKey), crypto.SHA1, hash[:]) | |||||
if err != nil { | |||||
Println("Sign Error: ", err) | |||||
return "", err | |||||
} | |||||
out := base64.StdEncoding.EncodeToString(signature) | |||||
return out, nil | |||||
} | |||||
func RsaSignVerify(signData string, originalData string, msc *MerchSysConfig) (err error) { | |||||
publicKey, pubk_err := getPublicKey(msc) | |||||
if pubk_err != nil { | |||||
return pubk_err | |||||
} | |||||
sign, err := base64.StdEncoding.DecodeString(signData) | |||||
if err != nil { | |||||
return err | |||||
} | |||||
hash := sha1.New() | |||||
hash.Write([]byte(originalData)) | |||||
return rsa.VerifyPKCS1v15(publicKey.(*rsa.PublicKey), crypto.SHA1, hash.Sum(nil), sign) | |||||
} | |||||
func getPrivateKey(msc *MerchSysConfig) (interface{}, error) { | |||||
priKeyString := msc.RspPriKey | |||||
if priKeyString == "" { | |||||
return nil, errors.New("Unknow private key data") | |||||
} | |||||
if !strings.Contains(priKeyString, "-----BEGIN PRIVATE KEY-----") { | |||||
priKeyString = "-----BEGIN PRIVATE KEY-----\n" + priKeyString | |||||
} | |||||
if !strings.Contains(priKeyString, "-----END PRIVATE KEY-----") { | |||||
priKeyString = priKeyString + "\n-----END PRIVATE KEY-----" | |||||
} | |||||
defer func() { | |||||
err := recover() | |||||
if err != nil { | |||||
Println("Error in get private key: ", err) | |||||
} | |||||
}() | |||||
keyByts, _ := pem.Decode([]byte(priKeyString)) | |||||
privateKey, err := x509.ParsePKCS8PrivateKey(keyByts.Bytes) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
return privateKey, nil | |||||
} | |||||
func getPublicKey(msc *MerchSysConfig) (interface{}, error) { | |||||
publicString := msc.RspPubKey | |||||
if publicString == "" { | |||||
return "", errors.New("Unknow public key data") | |||||
} | |||||
if !strings.Contains(publicString, "-----BEGIN PUBLIC KEY-----") { | |||||
publicString = "-----BEGIN PUBLIC KEY-----\n" + publicString | |||||
} | |||||
if !strings.Contains(publicString, "-----END PUBLIC KEY-----") { | |||||
publicString = publicString + "\n-----END PUBLIC KEY-----" | |||||
} | |||||
defer func() { | |||||
err := recover() | |||||
if err != nil { | |||||
Println("Error in get public key: ", err) | |||||
} | |||||
}() | |||||
keyByts, _ := pem.Decode([]byte(publicString)) | |||||
publicKey, err := x509.ParsePKIXPublicKey(keyByts.Bytes) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
return publicKey, nil | |||||
} |
@@ -0,0 +1,3 @@ | |||||
package adapayCore | |||||
const Version = "1.3.0" |
@@ -0,0 +1,18 @@ | |||||
package adapay | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type accountInterface interface { | |||||
Payment(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type Account struct { | |||||
*Adapay | |||||
} | |||||
func (w *Account) Payment(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := PAGE_BASE_URL + WALLET_PAY | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, w.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,157 @@ | |||||
package adapay | |||||
import ( | |||||
"errors" | |||||
"io/ioutil" | |||||
"path/filepath" | |||||
"strings" | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type Adapay struct { | |||||
MultiMerchSysConfigs map[string]*adapayCore.MerchSysConfig | |||||
DefaultMerchSysConfig *adapayCore.MerchSysConfig | |||||
AppId string | |||||
} | |||||
func InitDefaultMerchSysConfig(filePath string) (*Adapay, error) { | |||||
config, err := adapayCore.ReadMerchConfig(filePath) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
ada := &Adapay{ | |||||
DefaultMerchSysConfig: config, | |||||
} | |||||
return ada, nil | |||||
} | |||||
func InitMultiMerchSysConfigs(fileDir string) (*Adapay, error) { | |||||
dirs, _ := ioutil.ReadDir(fileDir) | |||||
configs := map[string]*adapayCore.MerchSysConfig{} | |||||
for _, f := range dirs { | |||||
ext := filepath.Ext(f.Name()) | |||||
if ext == ".json" { | |||||
config, err := adapayCore.ReadMerchConfig(fileDir + f.Name()) | |||||
if err != nil { | |||||
continue | |||||
} | |||||
key := strings.Replace(f.Name(), ".json", "", -1) | |||||
configs[key] = config | |||||
} | |||||
} | |||||
ada := &Adapay{ | |||||
MultiMerchSysConfigs: configs, | |||||
} | |||||
return ada, nil | |||||
} | |||||
func GetAdapayByDBSysConfig(configKey, appId, ApiKeyLive, ApiKeyTest, RspPubKey, RspPriKey string) (*Adapay, error) { | |||||
configs := map[string]*adapayCore.MerchSysConfig{} | |||||
if ApiKeyLive == "" || ApiKeyTest == "" || | |||||
RspPubKey == "" || RspPriKey == "" { | |||||
return nil, errors.New("Config Setting Failed ") | |||||
} | |||||
var config adapayCore.MerchSysConfig | |||||
config.ApiKeyLive = ApiKeyLive | |||||
config.ApiKeyTest = ApiKeyTest | |||||
config.RspPubKey = RspPubKey | |||||
config.RspPriKey = RspPriKey | |||||
configs[configKey] = &config | |||||
ada := &Adapay{ | |||||
MultiMerchSysConfigs: configs, | |||||
DefaultMerchSysConfig: &config, | |||||
AppId: appId, | |||||
} | |||||
return ada, nil | |||||
} | |||||
func (a *Adapay) HandleConfig(multiMerchConfigId ...string) *adapayCore.MerchSysConfig { | |||||
if multiMerchConfigId == nil { | |||||
return a.DefaultMerchSysConfig | |||||
} else { | |||||
return a.MultiMerchSysConfigs[multiMerchConfigId[0]] | |||||
} | |||||
} | |||||
func (a *Adapay) Payment() *Payment { | |||||
return &Payment{Adapay: a} | |||||
} | |||||
func (a *Adapay) PaymentConfirm() *PaymentConfirm { | |||||
return &PaymentConfirm{Adapay: a} | |||||
} | |||||
func (a *Adapay) PaymentReverse() *PaymentReverse { | |||||
return &PaymentReverse{Adapay: a} | |||||
} | |||||
func (a *Adapay) SettleAccount() *SettleAccount { | |||||
return &SettleAccount{Adapay: a} | |||||
} | |||||
func (a *Adapay) AdapayTools() *AdapayTools { | |||||
return &AdapayTools{Adapay: a} | |||||
} | |||||
func (a *Adapay) Drawcash() *Drawcash { | |||||
return &Drawcash{Adapay: a} | |||||
} | |||||
func (a *Adapay) CorpMember() *CorpMember { | |||||
return &CorpMember{Adapay: a} | |||||
} | |||||
func (a *Adapay) Member() *Member { | |||||
return &Member{Adapay: a} | |||||
} | |||||
func (a *Adapay) Refund() *Refund { | |||||
return &Refund{Adapay: a} | |||||
} | |||||
func (a *Adapay) Wallet() *Wallet { | |||||
return &Wallet{Adapay: a} | |||||
} | |||||
func (a *Adapay) Account() *Account { | |||||
return &Account{Adapay: a} | |||||
} | |||||
func (a *Adapay) Checkout() *Checkout { | |||||
return &Checkout{Adapay: a} | |||||
} | |||||
func (a *Adapay) FastPay() *FastPay { | |||||
return &FastPay{Adapay: a} | |||||
} | |||||
func (a *Adapay) FreezeAccount() *FreezeAccount { | |||||
return &FreezeAccount{Adapay: a} | |||||
} | |||||
func (a *Adapay) UnFreezeAccount() *UnFreezeAccount { | |||||
return &UnFreezeAccount{Adapay: a} | |||||
} | |||||
func (a *Adapay) Transfer() *Transfer { | |||||
return &Transfer{Adapay: a} | |||||
} | |||||
func (a *Adapay) Version() string { | |||||
return "1.3.1" | |||||
} |
@@ -0,0 +1,36 @@ | |||||
package adapay | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type adapayToolsInterface interface { | |||||
DownloadBill(bill_date string, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
UserIdentity(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
VerifySign(signData string, originalData string, multiMerchConfigId ...string) error | |||||
} | |||||
type AdapayTools struct { | |||||
*Adapay | |||||
} | |||||
func (b *AdapayTools) DownloadBill(bill_date string, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + BILL_DOWNLOAD | |||||
reqParam := make(map[string]interface{}) | |||||
reqParam["bill_date"] = bill_date | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, b.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (u *AdapayTools) UserIdentity(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + USER_IDENTITY | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, u.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (v *AdapayTools) VerifySign(signData string, originalData string, multiMerchConfigId ...string) error { | |||||
return adapayCore.RsaSignVerify(signData, originalData, v.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,67 @@ | |||||
package adapay | |||||
const SDK_VERSION = "1.3.1" | |||||
const BASE_URL = "https://api.adapay.tech" | |||||
const PAGE_BASE_URL = "https://page.adapay.tech" | |||||
const PAYMENT_CREATE = "/v1/payments" | |||||
const PAYMENT_QUERY = "/v1/payments/{payment_id}" | |||||
const PAYMENT_LIST_QUERY = "/v1/payments/list" | |||||
const PAYMENT_CLOSE = "/v1/payments/{payment_id}/close" | |||||
const PAYMENT_CONFIRM = "/v1/payments/confirm" | |||||
const PAYMENT_QUERY_CONFIRM = "/v1/payments/confirm/{payment_confirm_id}" | |||||
const PAYMENT_QUERY_CONFIRM_LIST = "/v1/payments/confirm/list" | |||||
const PAYMENT_REVERSE = "/v1/payments/reverse" | |||||
const PAYMENT_QUERY_REVERSE = "/v1/payments/reverse/{reverse_id}" | |||||
const PAYMENT_QUERY_REVERSE_LIST = "/v1/payments/reverse/list" | |||||
const REFUND_CREATE = "/v1/payments/{payment_id}/refunds" | |||||
const REFUND_QUERY = "/v1/payments/refunds" | |||||
const BILL_DOWNLOAD = "/v1/bill/download" | |||||
const QUERY_CASHS_STAT = "/v1/cashs/stat" | |||||
const MEMBER_CREATE = "/v1/members" | |||||
const MEMBER_CREATE_REALNAME = "/v1/members/realname" | |||||
const MEMBER_QUERY = "/v1/members/{member_id}" | |||||
const MEMBER_QUERY_LIST = "/v1/members/list" | |||||
const MEMBER_UPDATE = "/v1/members/update" | |||||
const SETTLE_ACCOUNT_CREATE = "/v1/settle_accounts" | |||||
const SETTLE_ACCOUNT_QUERY = "/v1/settle_accounts/{settle_account_id}" | |||||
const SETTLE_ACCOUNT_DELETE = "/v1/settle_accounts/delete" | |||||
const SETTLE_ACCOUNT_DETAIL_QUERY = "/v1/settle_accounts/settle_details" | |||||
const SETTLE_ACCOUNT_MODIFY = "/v1/settle_accounts/modify" | |||||
const SETTLE_ACCOUNT_BALANCE = "/v1/settle_accounts/balance" | |||||
const SETTLE_ACCOUNT_COMMISSIONS = "/v1/settle_accounts/commissions" | |||||
const SETTLE_ACCOUNT_COMMISSIONS_LIST = "/v1/settle_accounts/commissions/list" | |||||
const CORP_MEMBERS_CREATE = "/v1/corp_members" | |||||
const CORP_MEMBERS_QUERY = "/v1/corp_members/{member_id}" | |||||
const CREATE_CASHS = "/v1/cashs" | |||||
const USER_IDENTITY = "/v1/union/user_identity" | |||||
const WALLET_LOGIN = "/v1/walletLogin" | |||||
const WALLET_PAY = "/v1/account/payment" | |||||
const WALLET_CHECKOUT = "/v1/checkout" | |||||
const QUERY_CHECKOUT_LIST = "/v1/checkout/list" | |||||
const FAST_CARD_APPLY = "/v1/fast_card/apply" | |||||
const FAST_CARD_CONFIRM = "/v1/fast_card/confirm" | |||||
const FAST_CARD_LIST = "/v1/fast_card/list" | |||||
const FAST_PAY_CONFIRM = "/v1/fast_pay/confirm" | |||||
const FAST_PAY_SMS_CODE = "/v1/fast_pay/sms_code" | |||||
const FREEZE_ACCOUNT_FREEZE = "/v1/settle_accounts/freeze" | |||||
const FREEZE_ACCOUNT_FREEZE_LIST = "/v1/settle_accounts/freeze/list" | |||||
const UnFREEZE_ACCOUNT_FREEZE = "/v1/settle_accounts/unfreeze" | |||||
const UnFREEZE_ACCOUNT_FREEZE_LIST = "/v1/settle_accounts/unfreeze/list" | |||||
const TRANSFER_CREATE = "/v1/settle_accounts/transfer" | |||||
const TRANSFER_LIST = "/v1/settle_accounts/transfer/list" |
@@ -0,0 +1,18 @@ | |||||
package adapay | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type billInterface interface { | |||||
Download(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type Bill struct { | |||||
*Adapay | |||||
} | |||||
func (b *Bill) Download(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + BILL_DOWNLOAD | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, b.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,23 @@ | |||||
package adapay | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type checkoutInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type Checkout struct { | |||||
*Adapay | |||||
} | |||||
func (w *Checkout) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := PAGE_BASE_URL + WALLET_CHECKOUT | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, w.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (m *Checkout) QueryList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + QUERY_CHECKOUT_LIST | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, m.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,28 @@ | |||||
package adapay | |||||
import ( | |||||
"strings" | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type corpMemberInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type CorpMember struct { | |||||
*Adapay | |||||
} | |||||
func (c *CorpMember) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + CORP_MEMBERS_CREATE | |||||
return adapayCore.UploadAdaPay(reqUrl, reqParam, "attach_file", c.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (c *CorpMember) Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + strings.Replace(CORP_MEMBERS_QUERY, "{member_id}", adapayCore.ToString(reqParam["member_id"]), -1) | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, c.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,25 @@ | |||||
package adapay | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type drawcashInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type Drawcash struct { | |||||
*Adapay | |||||
} | |||||
func (c *Drawcash) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + BILL_DOWNLOAD | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, c.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (c *Drawcash) Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + QUERY_CASHS_STAT | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, c.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,42 @@ | |||||
package adapay | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type fastPayInterface interface { | |||||
CardBind(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
CardBindConfirm(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
CardBindlist(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Confirm(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
SmsCode(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type FastPay struct { | |||||
*Adapay | |||||
} | |||||
func (f *FastPay) CardBind(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := PAGE_BASE_URL + FAST_CARD_APPLY | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, f.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (f *FastPay) CardBindConfirm(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := PAGE_BASE_URL + FAST_CARD_CONFIRM | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, f.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (f *FastPay) CardBindlist(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := PAGE_BASE_URL + FAST_CARD_LIST | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, f.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (f *FastPay) Confirm(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + FAST_PAY_CONFIRM | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, f.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (f *FastPay) SmsCode(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + FAST_PAY_SMS_CODE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, f.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,24 @@ | |||||
package adapay | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type FreezeAccountInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
List(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type FreezeAccount struct { | |||||
*Adapay | |||||
} | |||||
func (f *FreezeAccount) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + FREEZE_ACCOUNT_FREEZE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, f.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (f *FreezeAccount) List(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + FREEZE_ACCOUNT_FREEZE_LIST | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, f.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,45 @@ | |||||
package adapay | |||||
import ( | |||||
"strings" | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type memberInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Update(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
QueryList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type Member struct { | |||||
*Adapay | |||||
} | |||||
func (m *Member) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + MEMBER_CREATE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, m.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (m *Member) CreateRealName(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + MEMBER_CREATE_REALNAME | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, m.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (m *Member) Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + strings.Replace(MEMBER_QUERY, "{member_id}", adapayCore.ToString(reqParam["member_id"]), -1) | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, m.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (m *Member) Update(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + MEMBER_UPDATE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, m.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (m *Member) QueryList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + MEMBER_QUERY_LIST | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, m.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,41 @@ | |||||
package adapay | |||||
import ( | |||||
"strings" | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type paymentInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
QueryList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Close(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type Payment struct { | |||||
*Adapay | |||||
} | |||||
func (p *Payment) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + PAYMENT_CREATE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, p.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (p *Payment) Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + strings.Replace(PAYMENT_QUERY, "{payment_id}", adapayCore.ToString(reqParam["payment_id"]), -1) | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, p.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (p *Payment) QueryList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + PAYMENT_LIST_QUERY | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, p.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (p *Payment) Close(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + strings.Replace(PAYMENT_CLOSE, "{payment_id}", adapayCore.ToString(reqParam["payment_id"]), -1) | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, p.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,34 @@ | |||||
package adapay | |||||
import ( | |||||
"strings" | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type paymentConfirmInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
QueryList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type PaymentConfirm struct { | |||||
*Adapay | |||||
} | |||||
func (p *PaymentConfirm) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + PAYMENT_CONFIRM | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, p.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (p *PaymentConfirm) Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + strings.Replace(PAYMENT_QUERY_CONFIRM, "{payment_confirm_id}", adapayCore.ToString(reqParam["payment_confirm_id"]), -1) | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, p.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (p *PaymentConfirm) QueryList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + PAYMENT_QUERY_CONFIRM_LIST | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, p.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,34 @@ | |||||
package adapay | |||||
import ( | |||||
"strings" | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type paymentReverseInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
QueryList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type PaymentReverse struct { | |||||
*Adapay | |||||
} | |||||
func (p *PaymentReverse) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + PAYMENT_REVERSE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, p.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (p *PaymentReverse) Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + strings.Replace(PAYMENT_QUERY_REVERSE, "{reverse_id}", adapayCore.ToString(reqParam["reverse_id"]), -1) | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, p.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (p *PaymentReverse) QueryList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + PAYMENT_QUERY_REVERSE_LIST | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, p.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,27 @@ | |||||
package adapay | |||||
import ( | |||||
"strings" | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type refundInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type Refund struct { | |||||
*Adapay | |||||
} | |||||
func (r *Refund) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + strings.Replace(REFUND_CREATE, "{payment_id}", adapayCore.ToString(reqParam["payment_id"]), -1) | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, r.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (r *Refund) Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + REFUND_QUERY | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, r.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,75 @@ | |||||
package adapay | |||||
import ( | |||||
"errors" | |||||
"fmt" | |||||
"strings" | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type settleAccountInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
DeleteAccount(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Detail(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Update(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Balance(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
Commission(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
CommissionList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type SettleAccount struct { | |||||
*Adapay | |||||
} | |||||
func (s *SettleAccount) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + SETTLE_ACCOUNT_CREATE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, s.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (s *SettleAccount) Query(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
if reqParam["settle_account_id"] == nil || reqParam["settle_account_id"] == "" { | |||||
return make(map[string]interface{}), nil, errors.New(fmt.Sprintf("请求参数错误 ==> %s", "settle_account_id")) | |||||
} | |||||
reqUrl := BASE_URL + strings.Replace(SETTLE_ACCOUNT_QUERY, "{settle_account_id}", adapayCore.ToString(reqParam["settle_account_id"]), -1) | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, s.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (s *SettleAccount) DeleteAccount(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + SETTLE_ACCOUNT_DELETE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, s.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (s *SettleAccount) Detail(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + SETTLE_ACCOUNT_DETAIL_QUERY | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, s.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (s *SettleAccount) Update(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + SETTLE_ACCOUNT_MODIFY | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, s.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (s *SettleAccount) Balance(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + SETTLE_ACCOUNT_BALANCE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, s.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (s *SettleAccount) Commission(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + SETTLE_ACCOUNT_COMMISSIONS | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, s.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (s *SettleAccount) CommissionList(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + SETTLE_ACCOUNT_COMMISSIONS_LIST | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, s.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,24 @@ | |||||
package adapay | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type TransferInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
List(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type Transfer struct { | |||||
*Adapay | |||||
} | |||||
func (t *Transfer) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + TRANSFER_CREATE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, t.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (t *Transfer) List(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + TRANSFER_LIST | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, t.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,24 @@ | |||||
package adapay | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type UnFreezeAccountInterface interface { | |||||
Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
List(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type UnFreezeAccount struct { | |||||
*Adapay | |||||
} | |||||
func (f *UnFreezeAccount) Create(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + UnFREEZE_ACCOUNT_FREEZE | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, f.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (f *UnFreezeAccount) List(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + UnFREEZE_ACCOUNT_FREEZE_LIST | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, f.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,18 @@ | |||||
package adapay | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type walletInterface interface { | |||||
Login(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type Wallet struct { | |||||
*Adapay | |||||
} | |||||
func (w *Wallet) Login(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := PAGE_BASE_URL + WALLET_LOGIN | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, w.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,16 @@ | |||||
package merchant | |||||
const SDK_VERSION = "1.0.0" | |||||
const BASE_URL = "https://api.adapay.tech" | |||||
const PAGE_BASE_URL = "https://api.adapay.tech" | |||||
const BATCH_ENTRYS = "/v1/batchEntrys/userEntry" | |||||
const QUERY_ENTRY = "/v1/batchEntrys/userEntry" | |||||
const MER_CONF = "/v1/batchInput/merConf" | |||||
const QUERY_MER_CONF = "/v1/batchInput/merConf" | |||||
const MER_RESIDENT_MODIFY = "/v1/batchInput/merResidentModify" | |||||
const MER_PROFILE_PICTURE = "/v1/merProfile/merProfilePicture" | |||||
const MER_PROFILE_FOR_AUDIT = "/v1/merProfile/merProfileForAudit" |
@@ -0,0 +1,32 @@ | |||||
package merchant | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type batchInputInterface interface { | |||||
MerConf(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
QueryMerConf(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
MerResidentModify(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type BatchInput struct { | |||||
*Merchant | |||||
} | |||||
func (b *BatchInput) MerConf(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + MER_CONF | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, b.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (b *BatchInput) QueryMerConf(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + QUERY_MER_CONF | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, b.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (b *BatchInput) MerResidentModify(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + MER_RESIDENT_MODIFY | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, b.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,25 @@ | |||||
package merchant | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type entryInterface interface { | |||||
BatchEntrys(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
QueryEntry(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type Entry struct { | |||||
*Merchant | |||||
} | |||||
func (e *Entry) BatchEntrys(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + BATCH_ENTRYS | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, e.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (e *Entry) QueryEntry(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + QUERY_ENTRY | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.GET, reqParam, e.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,26 @@ | |||||
package merchant | |||||
import ( | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type merProfileInterface interface { | |||||
MerProfilePicture(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
MerProfileForAudit(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) | |||||
} | |||||
type MerProfile struct { | |||||
*Merchant | |||||
} | |||||
func (e *MerProfile) MerProfilePicture(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + MER_PROFILE_PICTURE | |||||
return adapayCore.UploadAdaPay(reqUrl, reqParam, "file", e.HandleConfig(multiMerchConfigId...)) | |||||
} | |||||
func (e *MerProfile) MerProfileForAudit(reqParam map[string]interface{}, multiMerchConfigId ...string) (map[string]interface{}, *adapayCore.ApiError, error) { | |||||
reqUrl := BASE_URL + MER_PROFILE_FOR_AUDIT | |||||
return adapayCore.RequestAdaPay(reqUrl, adapayCore.POST, reqParam, e.HandleConfig(multiMerchConfigId...)) | |||||
} |
@@ -0,0 +1,101 @@ | |||||
package merchant | |||||
import ( | |||||
"errors" | |||||
"io/ioutil" | |||||
"path/filepath" | |||||
"strings" | |||||
adapayCore "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay-core" | |||||
) | |||||
type Merchant struct { | |||||
MultiMerchSysConfigs map[string]*adapayCore.MerchSysConfig | |||||
DefaultMerchSysConfig *adapayCore.MerchSysConfig | |||||
} | |||||
func InitDefaultMerchSysConfig(filePath string) (*Merchant, error) { | |||||
config, err := adapayCore.ReadMerchConfig(filePath) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
ada := &Merchant{ | |||||
DefaultMerchSysConfig: config, | |||||
} | |||||
return ada, nil | |||||
} | |||||
func InitMultiMerchSysConfigs(fileDir string) (*Merchant, error) { | |||||
dirs, _ := ioutil.ReadDir(fileDir) | |||||
configs := map[string]*adapayCore.MerchSysConfig{} | |||||
for _, f := range dirs { | |||||
ext := filepath.Ext(f.Name()) | |||||
if ext == ".json" { | |||||
config, err := adapayCore.ReadMerchConfig(fileDir + f.Name()) | |||||
if err != nil { | |||||
continue | |||||
} | |||||
key := strings.Replace(f.Name(), ".json", "", -1) | |||||
configs[key] = config | |||||
} | |||||
} | |||||
ada := &Merchant{ | |||||
MultiMerchSysConfigs: configs, | |||||
} | |||||
return ada, nil | |||||
} | |||||
func GetMerchantByDBSysConfig(configKey, ApiKeyLive, ApiKeyTest, RspPubKey, RspPriKey string) (*Merchant, error) { | |||||
configs := map[string]*adapayCore.MerchSysConfig{} | |||||
if ApiKeyLive == "" || ApiKeyTest == "" || | |||||
RspPubKey == "" || RspPriKey == "" { | |||||
return nil, errors.New("Config Setting Failed ") | |||||
} | |||||
var config adapayCore.MerchSysConfig | |||||
config.ApiKeyLive = ApiKeyLive | |||||
config.ApiKeyTest = ApiKeyTest | |||||
config.RspPubKey = RspPubKey | |||||
config.RspPriKey = RspPriKey | |||||
configs[configKey] = &config | |||||
ada := &Merchant{ | |||||
MultiMerchSysConfigs: configs, | |||||
DefaultMerchSysConfig: &config, | |||||
} | |||||
return ada, nil | |||||
} | |||||
func (a *Merchant) HandleConfig(multiMerchConfigId ...string) *adapayCore.MerchSysConfig { | |||||
if multiMerchConfigId == nil { | |||||
return a.DefaultMerchSysConfig | |||||
} else { | |||||
return a.MultiMerchSysConfigs[multiMerchConfigId[0]] | |||||
} | |||||
} | |||||
func (m *Merchant) BatchInput() *BatchInput { | |||||
return &BatchInput{Merchant: m} | |||||
} | |||||
func (a *Merchant) Entry() *Entry { | |||||
return &Entry{Merchant: a} | |||||
} | |||||
func (a *Merchant) MerProfile() *MerProfile { | |||||
return &MerProfile{Merchant: a} | |||||
} | |||||
func (a *Merchant) Version() string { | |||||
return "1.0.0" | |||||
} |
@@ -1 +1,30 @@ | |||||
package boc | package boc | ||||
import ( | |||||
zhios_pay_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/utils" | |||||
"fmt" | |||||
) | |||||
func Send(prd bool, appId, privateKeyStr string, param map[string]string) (string, error) { | |||||
data := zhios_pay_utils.JoinStringsInASCII(param, "", "", false, false) | |||||
sign, err := zhios_pay_utils.GetSign(privateKeyStr, data) | |||||
if err != nil { | |||||
return "", err | |||||
} | |||||
url := "https://cuaas.bocmacau.com/w/rsa/mercapi_ol" | |||||
if prd { | |||||
url = "https://aas.bocmacau.com/w/rsa/mercapi_ol" | |||||
} | |||||
headers := map[string]string{ | |||||
"Content-Type": "application/json", | |||||
} | |||||
param["merchantSign"] = sign | |||||
fmt.Println(zhios_pay_utils.SerializeStr(param)) | |||||
fmt.Println(url) | |||||
res, err := zhios_pay_utils.CurlPost(url, param, headers) | |||||
if err != nil { | |||||
return "", err | |||||
} | |||||
fmt.Println(string(res)) | |||||
return string(res), nil | |||||
} |
@@ -0,0 +1,46 @@ | |||||
package md | |||||
type MacaoBOCPublicParameter struct { | |||||
RequestId string `json:"requestId" name:"商戶系統請求流水號" label:"建議同一商户每次請求保持唯一,作為技術核實問題的快捷要素"` | |||||
Service string `json:"service" name:"接口類型" label:"原樣返回請求參數頭中的service"` | |||||
Version string `json:"version" name:"接口版本" label:"當前文檔接口版本送值:2.0"` | |||||
IpAddress string `json:"ipAddress" name:"用戶瀏覽器IP地址" label:"非必传"` | |||||
SignType string `json:"signType" name:"固定值RSA2" label:"當前僅支持RSA2"` | |||||
MerchantId string `json:"merchantId" name:"合作商戶編號" label:"中銀智慧付給合作商戶分配的唯一標識"` | |||||
TerminalNo string `json:"terminalNo" name:"終端號" label:"長度8位數字,進件時生成終端號。可在商戶管理端的“商戶管理”模塊查詢。"` | |||||
MerchantSign string `json:"merchantSign" name:"簽名串" label:"簽名機制詳見2.1"` | |||||
} | |||||
//注:交易的成功與否不用根據returnCode判斷,請根據返回參數中result判斷,result爲空就是交易失敗,returnMessage是對應失敗的原因。result返回A,Z,需發起查詢判斷具體交易狀態。 | |||||
// 若接口報文頭應答參數中的【returnCode】欄位返回值爲【888888】表示中銀智慧付系統在進行升級維護, | |||||
//此時中銀智慧付系統無法提供支付能力。商戶系統需要在合適的位置展示【returnMessage】 | |||||
//欄位中的信息友好的告知用戶此項功能暫不可用。 | |||||
type MacaoBOCPublicResponse struct { | |||||
RequestId string `json:"requestId" name:"商戶系統請求流水號" label:"建議同一商户每次請求保持唯一,作為技術核實問題的快捷要素"` | |||||
Service string `json:"service" name:"接口類型" label:"原樣返回請求參數頭中的service"` | |||||
Version string `json:"version" name:"接口版本" label:"當前文檔接口版本送值:2.0"` | |||||
SignType string `json:"signType" name:"固定值RSA2" label:"當前僅支持RSA2"` | |||||
MerchantId string `json:"merchantId" name:"合作商戶編號" label:"中銀智慧付給合作商戶分配的唯一標識"` | |||||
TerminalNo string `json:"terminalNo" name:"終端號" label:"長度8位數字,進件時生成終端號。可在商戶管理端的“商戶管理”模塊查詢。"` | |||||
ReturnCode string `json:"returnCode" name:"返回信息碼" label:"000000-成功。返回碼請參照附錄"` | |||||
ReturnMessage string `json:"returnMessage" name:"返回信息碼描述" label:"返回信息提示。"` | |||||
ServerSign string `json:"serverSign" name:"簽名串" label:"簽名機制詳見2.1"` | |||||
} | |||||
type CreateBocPayAppTradeReq struct { | |||||
MacaoBOCPublicParameter | |||||
Amount string `json:"amount" name:"订单金額" label:"以分爲單位,如1元表示爲100"` | |||||
OriginalAmount string `json:"originalAmount" name:"原订单金额" label:"以分爲單位,如1元表示爲100若无优惠请跟订单金额【amount】一致"` | |||||
MerchantPreferentialCnName string `json:"merchantPreferentialCnName" name:"商户系统优惠活动中文名称" label:"非必传"` | |||||
MerchantPreferentialEnName string `json:"merchantPreferentialEnName" name:"商户系统优惠活动英文名称" label:"非必传"` | |||||
Subject string `json:"subject" name:"訂單標題" label:"非必传,用戶支付完成後顯示在手機上的訂單名稱"` | |||||
ProductDesc string `json:"productDesc" name:"商品描述" label:"非必传,對一筆交易的具體描述信息,如果是多種商品,請將商品描述字符串累加傳給body。特殊字符不支持"` | |||||
MercOrderNo string `json:"mercOrderNo" name:"商戶系統消費訂單號" label:"商戶系統必須確保該訂單號在商戶系統是唯一的不能包含單引號“’”、尖括號“<”“>”和逗號“,”"` | |||||
OrderDate string `json:"orderDate" name:"訂單創建日期" label:"格式:yyyyMMdd"` | |||||
OrderTime string `json:"orderTime" name:"訂單創建時間" label:"格式:HHmmss"` | |||||
ValidNumber string `json:"validNumber" name:"有效期" label:"單位:秒 默認值1200"` | |||||
NotifyUrl string `json:"notifyUrl" name:"支付結果後台通知地址" label:"支付通知地址(后缀),商户在商戶服務管理後台配置好通知地址(域名)后,聚合平台会将域名和后缀拼接组成完整的通知地址,并在订单支付成后向此通知地址发送支付结果通知。"` | |||||
Reserved1 string `json:"reserved1" name:"商戶備用字段" label:"交易成功后原樣返回給商戶"` | |||||
Reserved2 string `json:"reserved2" name:"商戶備用字段" label:"交易成功后原樣返回給商戶"` | |||||
Reserved3 string `json:"reserved3" name:"商戶備用字段" label:"交易成功后原樣返回給商戶"` | |||||
} |
@@ -0,0 +1,120 @@ | |||||
package test | |||||
import ( | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/adapay-sdk/adapay" | |||||
zhios_pay_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/utils" | |||||
"testing" | |||||
) | |||||
func TestMemberCreate(t *testing.T) { | |||||
Adapay, err := adapay.GetAdapayByDBSysConfig("jiuhuicang", "app_a794b158-359b-4e5a-8464-5bd8f171bb6e", "api_live_419ec107-9854-45e8-af12-070efcef6ae9", "api_test_d6485653-c09e-405f-b386-8ef2936dfb97", "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB", | |||||
"MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMxVAwWM79+2Lx1TYA4muHy40AbwcBwXmvgNJGp2gq7bcDaNd5cmvXndwS6exV2hIGo8er0Qu3myGrwD/4BIoqCDSuqYfJkrlKzKM30+WAfwRulrFW+SOr6qCvGFF2bMdL884NMgd5PCpayASONq/blefQ3/Ic+c0gtZQxJzYzxLAgMBAAECgYEAyS+rGfv68zpeiXFeUpCtdaBCs5Jp0D8txq6p/GlTovdNNWl1Js5uIV/GpjCOA/JyCCgkcaPX86r5x8Xn/FeIRt/U1kkGs2zvKcxQntkOhmzMdDe7/FuwbRUUeM6LWGIc5AeQcBWYZeS8HAFMnlWho+knMqqgHC/fgUyon6YgMAECQQDyjJYSp+hdhTnvo88GPisQEPOoZRbrUnVFbwjD/OrQT7s6uSlbTAJRXGEYfdeaWsh2CoFl986pOqc/84E/Lr3LAkEA16nd1J3stk9XtC4i+iiXY0codiK24kU+pMcEm8NNyMV1nQT5iTcDA1ZeJCgamJZFeqcfyusimBNbCXdBKk2rgQJBAIymodAntkOlIjepEkBYhLhIXENme6fypTaicL7WR4SM99HR1f2vUhjELTn6n7BOvLhW1zq+PQU9kgcvud9dx4kCQFSMXtBFHZEXp/2WfNXv5fHg6sbtsx8gIH//GhpqxerpJsPpOF8H9yFu0beBFXQurYx5SqiF6GkQZYdffme0TYECQQDgOdQxysI1FEM/l8BDnQgmnO7sJqUtP9HsVcKElGdkJMZGqb8B5rt12y4dxpyVfyaTMZZZjqIx8zgQBhn+l0NJ") | |||||
if err != nil { | |||||
t.Error(err) | |||||
} | |||||
data, apiError, err := Adapay.Member().Create(map[string]interface{}{ | |||||
"app_id": Adapay.AppId, | |||||
"member_id": "1000000_1", | |||||
"location": "上海市徐汇区宜山路", | |||||
"email": "123@163.com", | |||||
"gender": "MALE", | |||||
"tel_no": "13192207503", | |||||
"nickname": "jiao", | |||||
"user_name": "焦柏翔", | |||||
"cert_type": "00", | |||||
"cert_id": "441283199612264097", | |||||
}) | |||||
if err != nil || apiError != nil { // 网络或本应用异常 | |||||
t.Error(err) | |||||
t.Error(apiError) | |||||
return | |||||
} | |||||
t.Log(data) | |||||
} | |||||
func TestMemberCreateRealName(t *testing.T) { | |||||
Adapay, err := adapay.GetAdapayByDBSysConfig("jiuhuicang", "app_a794b158-359b-4e5a-8464-5bd8f171bb6e", "api_live_419ec107-9854-45e8-af12-070efcef6ae9", "api_test_d6485653-c09e-405f-b386-8ef2936dfb97", "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB", | |||||
"MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMxVAwWM79+2Lx1TYA4muHy40AbwcBwXmvgNJGp2gq7bcDaNd5cmvXndwS6exV2hIGo8er0Qu3myGrwD/4BIoqCDSuqYfJkrlKzKM30+WAfwRulrFW+SOr6qCvGFF2bMdL884NMgd5PCpayASONq/blefQ3/Ic+c0gtZQxJzYzxLAgMBAAECgYEAyS+rGfv68zpeiXFeUpCtdaBCs5Jp0D8txq6p/GlTovdNNWl1Js5uIV/GpjCOA/JyCCgkcaPX86r5x8Xn/FeIRt/U1kkGs2zvKcxQntkOhmzMdDe7/FuwbRUUeM6LWGIc5AeQcBWYZeS8HAFMnlWho+knMqqgHC/fgUyon6YgMAECQQDyjJYSp+hdhTnvo88GPisQEPOoZRbrUnVFbwjD/OrQT7s6uSlbTAJRXGEYfdeaWsh2CoFl986pOqc/84E/Lr3LAkEA16nd1J3stk9XtC4i+iiXY0codiK24kU+pMcEm8NNyMV1nQT5iTcDA1ZeJCgamJZFeqcfyusimBNbCXdBKk2rgQJBAIymodAntkOlIjepEkBYhLhIXENme6fypTaicL7WR4SM99HR1f2vUhjELTn6n7BOvLhW1zq+PQU9kgcvud9dx4kCQFSMXtBFHZEXp/2WfNXv5fHg6sbtsx8gIH//GhpqxerpJsPpOF8H9yFu0beBFXQurYx5SqiF6GkQZYdffme0TYECQQDgOdQxysI1FEM/l8BDnQgmnO7sJqUtP9HsVcKElGdkJMZGqb8B5rt12y4dxpyVfyaTMZZZjqIx8zgQBhn+l0NJ") | |||||
if err != nil { | |||||
t.Error(err) | |||||
} | |||||
data, apiError, err := Adapay.Member().CreateRealName(map[string]interface{}{ | |||||
"app_id": Adapay.AppId, | |||||
"member_id": "1000000_0", | |||||
"location": "上海市徐汇区宜山路", | |||||
"email": "123@163.com", | |||||
"gender": "MALE", | |||||
"tel_no": "13192207503", | |||||
"nickname": "jiao", | |||||
"user_name": "焦柏翔", | |||||
"cert_type": "00", | |||||
"cert_id": "441283199612264097", | |||||
}) | |||||
if err != nil || apiError != nil { // 网络或本应用异常 | |||||
t.Error(err) | |||||
t.Error(apiError) | |||||
return | |||||
} | |||||
t.Log(data) | |||||
} | |||||
func TestMemberUpdate(t *testing.T) { | |||||
Adapay, err := adapay.GetAdapayByDBSysConfig("jiuhuicang", "app_a794b158-359b-4e5a-8464-5bd8f171bb6e", "api_live_419ec107-9854-45e8-af12-070efcef6ae9", "api_test_d6485653-c09e-405f-b386-8ef2936dfb97", "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB", | |||||
"MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMxVAwWM79+2Lx1TYA4muHy40AbwcBwXmvgNJGp2gq7bcDaNd5cmvXndwS6exV2hIGo8er0Qu3myGrwD/4BIoqCDSuqYfJkrlKzKM30+WAfwRulrFW+SOr6qCvGFF2bMdL884NMgd5PCpayASONq/blefQ3/Ic+c0gtZQxJzYzxLAgMBAAECgYEAyS+rGfv68zpeiXFeUpCtdaBCs5Jp0D8txq6p/GlTovdNNWl1Js5uIV/GpjCOA/JyCCgkcaPX86r5x8Xn/FeIRt/U1kkGs2zvKcxQntkOhmzMdDe7/FuwbRUUeM6LWGIc5AeQcBWYZeS8HAFMnlWho+knMqqgHC/fgUyon6YgMAECQQDyjJYSp+hdhTnvo88GPisQEPOoZRbrUnVFbwjD/OrQT7s6uSlbTAJRXGEYfdeaWsh2CoFl986pOqc/84E/Lr3LAkEA16nd1J3stk9XtC4i+iiXY0codiK24kU+pMcEm8NNyMV1nQT5iTcDA1ZeJCgamJZFeqcfyusimBNbCXdBKk2rgQJBAIymodAntkOlIjepEkBYhLhIXENme6fypTaicL7WR4SM99HR1f2vUhjELTn6n7BOvLhW1zq+PQU9kgcvud9dx4kCQFSMXtBFHZEXp/2WfNXv5fHg6sbtsx8gIH//GhpqxerpJsPpOF8H9yFu0beBFXQurYx5SqiF6GkQZYdffme0TYECQQDgOdQxysI1FEM/l8BDnQgmnO7sJqUtP9HsVcKElGdkJMZGqb8B5rt12y4dxpyVfyaTMZZZjqIx8zgQBhn+l0NJ") | |||||
if err != nil { | |||||
t.Error(err) | |||||
} | |||||
data, apiError, err := Adapay.Member().Update(map[string]interface{}{ | |||||
"app_id": Adapay.AppId, | |||||
"member_id": "10000001", | |||||
"location": "上海市徐汇区宜山路", | |||||
"email": "123@163.com", | |||||
"gender": "MALE", | |||||
"tel_no": "13192207503", | |||||
"nickname": "jiao", | |||||
}) | |||||
if err != nil || apiError != nil { // 网络或本应用异常 | |||||
t.Error(err) | |||||
t.Error(apiError) | |||||
return | |||||
} | |||||
t.Log(data) | |||||
} | |||||
func TestMemberQuery(t *testing.T) { | |||||
Adapay, err := adapay.GetAdapayByDBSysConfig("jiuhuicang", "app_ab8e23b3-2d68-4931-84e0-0cdd8402eca2", "api_live_9c355fcf-6124-4b60-b248-ba433df00c5d", "api_test_b4b8456a-5417-4aca-8034-784e05f1ef0e", "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB", | |||||
"MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMxVAwWM79+2Lx1TYA4muHy40AbwcBwXmvgNJGp2gq7bcDaNd5cmvXndwS6exV2hIGo8er0Qu3myGrwD/4BIoqCDSuqYfJkrlKzKM30+WAfwRulrFW+SOr6qCvGFF2bMdL884NMgd5PCpayASONq/blefQ3/Ic+c0gtZQxJzYzxLAgMBAAECgYEAyS+rGfv68zpeiXFeUpCtdaBCs5Jp0D8txq6p/GlTovdNNWl1Js5uIV/GpjCOA/JyCCgkcaPX86r5x8Xn/FeIRt/U1kkGs2zvKcxQntkOhmzMdDe7/FuwbRUUeM6LWGIc5AeQcBWYZeS8HAFMnlWho+knMqqgHC/fgUyon6YgMAECQQDyjJYSp+hdhTnvo88GPisQEPOoZRbrUnVFbwjD/OrQT7s6uSlbTAJRXGEYfdeaWsh2CoFl986pOqc/84E/Lr3LAkEA16nd1J3stk9XtC4i+iiXY0codiK24kU+pMcEm8NNyMV1nQT5iTcDA1ZeJCgamJZFeqcfyusimBNbCXdBKk2rgQJBAIymodAntkOlIjepEkBYhLhIXENme6fypTaicL7WR4SM99HR1f2vUhjELTn6n7BOvLhW1zq+PQU9kgcvud9dx4kCQFSMXtBFHZEXp/2WfNXv5fHg6sbtsx8gIH//GhpqxerpJsPpOF8H9yFu0beBFXQurYx5SqiF6GkQZYdffme0TYECQQDgOdQxysI1FEM/l8BDnQgmnO7sJqUtP9HsVcKElGdkJMZGqb8B5rt12y4dxpyVfyaTMZZZjqIx8zgQBhn+l0NJ") | |||||
if err != nil { | |||||
t.Error(err) | |||||
} | |||||
data, apiError, err := Adapay.Member().Query(map[string]interface{}{ | |||||
"app_id": Adapay.AppId, | |||||
"member_id": "1000000_2", | |||||
}) | |||||
if err != nil || apiError != nil { // 网络或本应用异常 | |||||
t.Error(err) | |||||
t.Error(apiError) | |||||
return | |||||
} | |||||
t.Log(zhios_pay_utils.SerializeStr(data)) | |||||
} | |||||
func TestFastPayCardBind(t *testing.T) { | |||||
Adapay, err := adapay.GetAdapayByDBSysConfig("jiuhuicang", "app_a794b158-359b-4e5a-8464-5bd8f171bb6e", "api_live_419ec107-9854-45e8-af12-070efcef6ae9", "api_test_d6485653-c09e-405f-b386-8ef2936dfb97", "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB", | |||||
"MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMxVAwWM79+2Lx1TYA4muHy40AbwcBwXmvgNJGp2gq7bcDaNd5cmvXndwS6exV2hIGo8er0Qu3myGrwD/4BIoqCDSuqYfJkrlKzKM30+WAfwRulrFW+SOr6qCvGFF2bMdL884NMgd5PCpayASONq/blefQ3/Ic+c0gtZQxJzYzxLAgMBAAECgYEAyS+rGfv68zpeiXFeUpCtdaBCs5Jp0D8txq6p/GlTovdNNWl1Js5uIV/GpjCOA/JyCCgkcaPX86r5x8Xn/FeIRt/U1kkGs2zvKcxQntkOhmzMdDe7/FuwbRUUeM6LWGIc5AeQcBWYZeS8HAFMnlWho+knMqqgHC/fgUyon6YgMAECQQDyjJYSp+hdhTnvo88GPisQEPOoZRbrUnVFbwjD/OrQT7s6uSlbTAJRXGEYfdeaWsh2CoFl986pOqc/84E/Lr3LAkEA16nd1J3stk9XtC4i+iiXY0codiK24kU+pMcEm8NNyMV1nQT5iTcDA1ZeJCgamJZFeqcfyusimBNbCXdBKk2rgQJBAIymodAntkOlIjepEkBYhLhIXENme6fypTaicL7WR4SM99HR1f2vUhjELTn6n7BOvLhW1zq+PQU9kgcvud9dx4kCQFSMXtBFHZEXp/2WfNXv5fHg6sbtsx8gIH//GhpqxerpJsPpOF8H9yFu0beBFXQurYx5SqiF6GkQZYdffme0TYECQQDgOdQxysI1FEM/l8BDnQgmnO7sJqUtP9HsVcKElGdkJMZGqb8B5rt12y4dxpyVfyaTMZZZjqIx8zgQBhn+l0NJ") | |||||
if err != nil { | |||||
t.Error(err) | |||||
} | |||||
createParams := make(map[string]interface{}) | |||||
createParams["app_id"] = Adapay.AppId | |||||
createParams["member_id"] = "1000000_0" | |||||
createParams["card_id"] = "6217857000103408884" | |||||
createParams["tel_no"] = "13192207503" | |||||
data, apiError, err := Adapay.FastPay().CardBind(createParams) | |||||
if err != nil || apiError != nil { // 网络或本应用异常 | |||||
t.Error(err) | |||||
t.Error(apiError) | |||||
return | |||||
} | |||||
t.Log(data) | |||||
} |
@@ -11,24 +11,11 @@ import ( | |||||
"strings" | "strings" | ||||
) | ) | ||||
func GetSign(method, privateKeyStr string, param map[string]interface{}) (string, error) { | |||||
func GetSign(privateKeyStr, data string) (string, error) { | |||||
privateKey, err := ssh.ParseRawPrivateKey([]byte(privateKeyStr)) | privateKey, err := ssh.ParseRawPrivateKey([]byte(privateKeyStr)) | ||||
if err != nil { | if err != nil { | ||||
return "", err | return "", err | ||||
} | } | ||||
keys := make([]string, 0, len(param)) | |||||
for k := range param { | |||||
keys = append(keys, k) | |||||
} | |||||
sort.Strings(keys) | |||||
data := "/api" + method | |||||
for _, v := range keys { | |||||
if strings.Contains(data, "?") == false { | |||||
data += "?" + v + "=" + param[v].(string) | |||||
} else { | |||||
data += "&" + v + "=" + param[v].(string) | |||||
} | |||||
} | |||||
fmt.Println(privateKey.(*rsa.PrivateKey)) | fmt.Println(privateKey.(*rsa.PrivateKey)) | ||||
fmt.Println(data) | fmt.Println(data) | ||||
h := crypto.Hash.New(crypto.SHA256) | h := crypto.Hash.New(crypto.SHA256) | ||||