Skip to content

Commit a458796

Browse files
authored
Merge pull request #3 from alipay/feature-update-p1
update-p1
2 parents af40706 + d23b3ec commit a458796

File tree

62 files changed

+1393
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1393
-23
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Changelog
22

33

4+
## 1.2.1 - 2024-09-30
5+
* [#3](https://github.com/alipay/global-open-sdk-go/pull/3) update-p1
6+
* add MARKETPLACE - demo
7+
* add vaulting - demo
8+
* add Dispute - demo
9+
* add risk
10+
* add Notify
11+
12+
413
## 1.2.0 - 2024-09-27
514
* [#2](https://github.com/alipay/global-open-sdk-go/pull/2) go-sdk-update-release
615
* go-sdk-update-release

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
```
22
Language:GO
33
GO version:1.22.5+
4-
Tags:v1.2.0
4+
Tags:v1.2.1
55
Copyright:Ant financial services group
66
```
77

com/alipay/api/defaultAlipayClient.go

+22-9
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@ import (
1515
"github.com/alipay/global-open-sdk-go/com/alipay/api/request"
1616
"io/ioutil"
1717
"log"
18+
"net"
1819
"net/http"
1920
"net/url"
2021
"strconv"
2122
"strings"
2223
"time"
2324
)
2425

26+
const readTimeout = 15 * time.Second
27+
const connectTimeout = 15 * time.Second
28+
const totalTimeout = 30 * time.Second
29+
2530
type DefaultAlipayClient struct {
2631
GatewayUrl string
2732
ClientId string
@@ -61,14 +66,22 @@ func NewDefaultAlipayClient(gatewayUrl string, clientId string, merchantPrivateK
6166
// @Return 返回类型 "错误信息"
6267
func (alipayClient *DefaultAlipayClient) httpDo(url, method string, params, headers map[string]string, data []byte, alipayResponse any) (any, error) {
6368

64-
//自定义cient
69+
trans := &http.Transport{
70+
DialContext: (&net.Dialer{
71+
Timeout: connectTimeout,
72+
}).DialContext,
73+
ResponseHeaderTimeout: readTimeout,
74+
}
75+
76+
//自定义client
6577
client := &http.Client{
66-
Timeout: 5 * time.Second, // 超时时间:5秒
78+
Timeout: totalTimeout,
79+
Transport: trans,
6780
}
6881
//http.post等方法只是在NewRequest上又封装来了一层而已
6982
req, err := http.NewRequest(method, url, bytes.NewBuffer(data))
7083
if err != nil {
71-
return nil, &exception.AlipaySDKError{Message: "http.NewRequest is fail " + err.Error()}
84+
return nil, &exception.AlipayLibraryError{Message: "http.NewRequest is fail " + err.Error()}
7285
}
7386
req.Header.Set("Content-type", "application/json")
7487

@@ -87,7 +100,7 @@ func (alipayClient *DefaultAlipayClient) httpDo(url, method string, params, head
87100
}
88101
resp, err := client.Do(req)
89102
if err != nil {
90-
return nil, &exception.AlipaySDKError{Message: "client.Do is fail " + err.Error()}
103+
return nil, &exception.AlipayLibraryError{Message: "client.Do is fail " + err.Error()}
91104
}
92105
defer resp.Body.Close()
93106

@@ -96,7 +109,7 @@ func (alipayClient *DefaultAlipayClient) httpDo(url, method string, params, head
96109
//但是我们在上次必然已经定义了any的类型
97110
err = json.Unmarshal(body, alipayResponse)
98111
if err != nil {
99-
return nil, &exception.AlipaySDKError{Message: "json.Unmarshal is fail " + err.Error()}
112+
return nil, &exception.AlipayLibraryError{Message: "json.Unmarshal is fail " + err.Error()}
100113
}
101114

102115
return alipayResponse, nil
@@ -105,7 +118,7 @@ func (alipayClient *DefaultAlipayClient) httpDo(url, method string, params, head
105118
func (alipayClient *DefaultAlipayClient) Execute(alipayRequest *request.AlipayRequest) (any, error) {
106119
reqPayload, err := json.Marshal(alipayRequest.Param)
107120
if err != nil {
108-
return nil, &exception.AlipaySDKError{Message: "json.Marshal is fail " + err.Error()}
121+
return nil, &exception.AlipayLibraryError{Message: "json.Marshal is fail " + err.Error()}
109122
}
110123
path := alipayRequest.Path
111124
httpMethod := alipayRequest.HttpMethod
@@ -128,16 +141,16 @@ func getPkcsKeu(key string) string {
128141
func genSign(httpMethod string, path string, clientId string, reqTime string, reqBody string, merchantPrivateKey string) (string, error) {
129142
block, _ := pem.Decode([]byte(merchantPrivateKey))
130143
if block == nil {
131-
return "", &exception.AlipaySDKError{Message: "Failed to decode private key"}
144+
return "", &exception.AlipayLibraryError{Message: "Failed to decode private key"}
132145
}
133146
privateKey, err := x509.ParsePKCS8PrivateKey(block.Bytes)
134147
if err != nil {
135-
return "", &exception.AlipaySDKError{Message: "Failed to parse private key " + err.Error()}
148+
return "", &exception.AlipayLibraryError{Message: "Failed to parse private key " + err.Error()}
136149
}
137150
payload := genSignContent(httpMethod, path, clientId, reqTime, reqBody)
138151
signature, err := Sign(privateKey.(*rsa.PrivateKey), []byte(payload))
139152
if err != nil {
140-
return "", &exception.AlipaySDKError{Message: "Failed to sign data " + err.Error()}
153+
return "", &exception.AlipayLibraryError{Message: "Failed to sign data " + err.Error()}
141154
}
142155

143156
return signature, nil

com/alipay/api/exception/exception.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package exception
22

33
import "fmt"
44

5-
type AlipaySDKError struct {
5+
type AlipayLibraryError struct {
66
Message string
77
}
88

9-
func (p *AlipaySDKError) Error() string {
9+
func (p *AlipayLibraryError) Error() string {
1010
return fmt.Sprintf("AlipaySDKErrore=%s", p.Message)
1111
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package model
2+
3+
type AccountBalance struct {
4+
AccountNo string `json:"accountNo,omitempty"`
5+
Currency string `json:"currency,omitempty"`
6+
AvailableBalance *Amount `json:"availableBalance,omitempty"`
7+
FrozenBalance *Amount `json:"frozenBalance,omitempty"`
8+
TotalBalance *Amount `json:"totalBalance,omitempty"`
9+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package model
2+
3+
type AttachmentType string
4+
5+
const (
6+
AttachmentType_SIGNATURE_AUTHORIZATION_LETTER AttachmentType = "SIGNATURE_AUTHORIZATION_LETTER"
7+
AttachmentType_ARTICLES_OF_ASSOCIATION AttachmentType = "ARTICLES_OF_ASSOCIATION"
8+
AttachmentType_LOGO AttachmentType = "LOGO"
9+
10+
AttachmentType_AUTHORIZER_SIGNATURE_CONFIRMATION_LETTER AttachmentType = "AUTHORIZER_SIGNATURE_CONFIRMATION_LETTER"
11+
AttachmentType_ASSOCIATION_ARTICLE AttachmentType = "ASSOCIATION_ARTICLE"
12+
AttachmentType_FINANCIAL_REPORT AttachmentType = "FINANCIAL_REPORT"
13+
AttachmentType_OWNERSHIP_STRUCTURE_PIC AttachmentType = "OWNERSHIP_STRUCTURE_PIC"
14+
AttachmentType_ADDRESS_PROOF AttachmentType = "ADDRESS_PROOF"
15+
AttachmentType_UBO_PROVE AttachmentType = "UBO_PROVE"
16+
AttachmentType_ENTERPRISE_REGISTRATION AttachmentType = "ENTERPRISE_REGISTRATION"
17+
AttachmentType_LICENSE_INFO AttachmentType = "LICENSE_INFO"
18+
AttachmentType_ID_CARD AttachmentType = "ID_CARD"
19+
AttachmentType_PASSPORT AttachmentType = "PASSPORT"
20+
AttachmentType_DRIVING_LICENSE AttachmentType = "DRIVING_LICENSE"
21+
AttachmentType_CPF AttachmentType = "CPF"
22+
AttachmentType_CNPJ AttachmentType = "CNPJ"
23+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package model
2+
3+
type AuthorizationError struct {
4+
ErrorCode string `json:"errorCode,omitempty"`
5+
ErrorMessage string `json:"errorMessage,omitempty"`
6+
}

com/alipay/api/model/Certificate.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package model
22

33
type Certificate struct {
4-
CertificateType CertificateType `json:"certificate_type,omitempty"`
5-
CertificateNo string `json:"certificate_no,omitempty"`
6-
HolderName *UserName `json:"holder_name,omitempty"`
7-
FileKeys []string `json:"file_keys,omitempty"`
8-
CertificateAuthority string `json:"certificate_authority,omitempty"`
9-
GrantType string `json:"grant_type,omitempty"`
4+
CertificateType CertificateType `json:"certificateType,omitempty"`
5+
CertificateNo string `json:"certificateNo,omitempty"`
6+
HolderName *UserName `json:"holderName,omitempty"`
7+
FileKeys []string `json:"fileKeys,omitempty"`
8+
CertificateAuthority string `json:"certificateAuthority,omitempty"`
9+
GrantType string `json:"grantType,omitempty"`
1010
}
1111

1212
type CertificateType string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package model
2+
3+
type DisputeEvidenceFormatType string
4+
5+
const (
6+
DisputeEvidenceFormatType_PDF DisputeEvidenceFormatType = "PDF"
7+
DisputeEvidenceFormatType_WORD DisputeEvidenceFormatType = "WORD"
8+
)
9+
10+
type DisputeEvidenceType string
11+
12+
const (
13+
DisputeEvidenceType_DISPUTE_EVIDENCE_TEMPLATE DisputeEvidenceType = "DISPUTE_EVIDENCE_TEMPLATE"
14+
DisputeEvidenceType_DISPUTE_EVIDENCE_FILE DisputeEvidenceType = "DISPUTE_EVIDENCE_FILE"
15+
)

com/alipay/api/model/MerchantInfo.go

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package model
2+
3+
type MerchantInfo struct {
4+
ReferenceMerchantId string `json:"referenceMerchantId,omitempty"`
5+
LoginId string `json:"loginId,omitempty"`
6+
LegalEntityType LegalEntityType `json:"legalEntityType,omitempty"`
7+
Company *Company `json:"company,omitempty"`
8+
BusinessInfo *BusinessInfo `json:"businessInfo,omitempty"`
9+
EntityAssociations []*EntityAssociations `json:"entityAssociations,omitempty"`
10+
}
11+
12+
type LegalEntityType string
13+
14+
const (
15+
LegalEntityType_Company LegalEntityType = "COMPANY"
16+
LegalEntityType_INDIVIDUAL LegalEntityType = "INDIVIDUAL"
17+
)
18+
19+
type Company struct {
20+
LegalName string `json:"legalName,omitempty"`
21+
CompanyType CompanyType `json:"companyType,omitempty"`
22+
RegisteredAddress *Address `json:"registeredAddress,omitempty"`
23+
OperatingAddress *Address `json:"operatingAddress,omitempty"`
24+
IncorporationDate string `json:"incorporationDate,omitempty"`
25+
StockInfo *StockInfo `json:"stockInfo,omitempty"`
26+
Certificates *Certificate `json:"certificates,omitempty"`
27+
Attachments []*Attachment `json:"attachments,omitempty"`
28+
CompanyUnit *CompanyUnitType `json:"companyUnit,omitempty"`
29+
Contacts []*Contact `json:"contacts,omitempty"`
30+
VatNo string `json:"vatNo,omitempty"`
31+
}
32+
33+
type BusinessInfo struct {
34+
Mcc string `json:"mcc,omitempty"`
35+
Websites []*WebSite `json:"websites,omitempty"`
36+
EnglishName string `json:"englishName,omitempty"`
37+
DoingBusinessAs string `json:"doingBusinessAs,omitempty"`
38+
MainSalesCountry string `json:"mainSalesCountry,omitempty"`
39+
AppName string `json:"appName,omitempty"`
40+
ServiceDescription string `json:"serviceDescription,omitempty"`
41+
}
42+
43+
type EntityAssociations struct {
44+
AssociationType AssociationType `json:"associationType,omitempty"`
45+
LegalEntityType LegalEntityType `json:"legalEntityType,omitempty"`
46+
Company *Company `json:"company,omitempty"`
47+
Individual *Individual `json:"individual,omitempty"`
48+
ShareholdingRatio string `json:"shareholdingRatio,omitempty"`
49+
}
50+
51+
type Individual struct {
52+
Name *UserName `json:"name,omitempty"`
53+
EnglishName *UserName `json:"englishName,omitempty"`
54+
DateOfBirth string `json:"dateOfBirth,omitempty"`
55+
PlaceOfBirth *Address `json:"placeOfBirth,omitempty"`
56+
Certificates *Certificate `json:"certificates,omitempty"`
57+
Nationality string `json:"nationality,omitempty"`
58+
Contacts []*Contact `json:"contacts,omitempty"`
59+
}
60+
61+
type AssociationType string
62+
63+
const (
64+
AssociationType_LEGAL_REPRESENTATIVE AssociationType = "LEGAL_REPRESENTATIVE"
65+
AssociationType_UBO AssociationType = "UBO"
66+
AssociationType_CONTACT AssociationType = "CONTACT"
67+
AssociationType_DIRECTOR AssociationType = "DIRECTOR"
68+
AssociationType_AUTHORIZER AssociationType = "AUTHORIZER"
69+
AssociationType_BOARD_MEMBER AssociationType = "BOARD_MEMBER"
70+
)
71+
72+
type WebSite struct {
73+
Name string `json:"name,omitempty"`
74+
Url string `json:"url,omitempty"`
75+
Desc string `json:"desc,omitempty"`
76+
Type string `json:"type,omitempty"`
77+
}
78+
79+
type StockInfo struct {
80+
ListedRegion string `json:"listedRegion,omitempty"`
81+
TickerSymbol string `json:"tickerSymbol,omitempty"`
82+
}
83+
84+
type Attachment struct {
85+
AttachmentType AttachmentType `json:"attachmentType,omitempty"`
86+
File string `json:"file,omitempty"`
87+
AttachmentName string `json:"attachmentName,omitempty"`
88+
FileKey string `json:"fileKey,omitempty"`
89+
}
90+
91+
type CompanyUnitType string
92+
93+
const (
94+
CompanyUnitType_HEADQUARTER CompanyUnitType = "HEADQUARTER"
95+
CompanyUnitType_BRANCH CompanyUnitType = "BRANCH"
96+
)
97+
98+
type CompanyType string
99+
100+
const (
101+
CompanyType_ENTERPRISE CompanyType = "ENTERPRISE"
102+
CompanyType_SOLE_PROPRIETORSHIP CompanyType = "SOLE_PROPRIETORSHIP"
103+
CompanyType_PARTNERSHIP CompanyType = "PARTNERSHIP"
104+
CompanyType_STATE_OWNED_BUSINESS CompanyType = "STATE_OWNED_BUSINESS"
105+
CompanyType_PRIVATELY_OWNED_BUSINESS CompanyType = "PRIVATELY_OWNED_BUSINESS"
106+
CompanyType_PUBLICLY_LISTED_BUSINESS CompanyType = "PUBLICLY_LISTED_BUSINESS"
107+
CompanyType_LTDA CompanyType = "LTDA"
108+
CompanyType_SA CompanyType = "SA"
109+
CompanyType_EIRELI CompanyType = "EIRELI"
110+
CompanyType_BOFC CompanyType = "BOFC"
111+
CompanyType_MEI CompanyType = "MEI"
112+
CompanyType_EI CompanyType = "EI"
113+
)
114+
115+
type Contact struct {
116+
Type ContactType `json:"type,omitempty"`
117+
Info string `json:"info,omitempty"`
118+
}
119+
120+
type ContactType string
121+
122+
const (
123+
ContactType_EMAIL ContactType = "EMAIL"
124+
ContactType_PHONE_NO ContactType = "PHONE_NO"
125+
ContactType_COMMERCIAL_PHONE_NO ContactType = "COMMERCIAL_PHONE_NO"
126+
)

com/alipay/api/model/Order.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ type Buyer struct {
6363
BuyerPhoneNo string `json:"buyerPhoneNo,omitempty"`
6464
BuyerEmail string `json:"buyerEmail,omitempty"`
6565
BuyerRegistrationTime string `json:"buyerRegistrationTime,omitempty"`
66-
67-
IsAccountVerified *bool `json:"isAccountVerified,omitempty"`
68-
SuccessfulOrderCount *int `json:"successfulOrderCount,omitempty"`
66+
IsAccountVerified *bool `json:"isAccountVerified,omitempty"`
67+
SuccessfulOrderCount *int `json:"successfulOrderCount,omitempty"`
6968
}
7069

7170
type BrowserInfo struct {
@@ -123,7 +122,7 @@ type Address struct {
123122
City string `json:"city,omitempty"`
124123
Address1 string `json:"address1,omitempty"`
125124
Address2 string `json:"address2,omitempty"`
126-
ZipCode string `json:"zip_code,omitempty"`
125+
ZipCode string `json:"zipCode,omitempty"`
127126
Label string `json:"label,omitempty"`
128127
}
129128

@@ -164,4 +163,5 @@ type Order struct {
164163
Transit *Transit `json:"transit,omitempty"`
165164
Lodging *Lodging `json:"lodging,omitempty"`
166165
Gaming *Gaming `json:"gaming,omitempty"`
166+
OrderCreatedTime string `json:"orderCreatedTime,omitempty"`
167167
}

com/alipay/api/model/PaymentDetail.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package model
2+
3+
type PaymentDetail struct {
4+
Amount *Amount `json:"amount,omitempty"`
5+
PaymentMethod *PaymentMethod `json:"paymentMethod,omitempty"`
6+
}
7+
8+
type AuthorizationPhase string
9+
10+
const (
11+
AuthorizationPhase_PRE_AUTHORIZATION AuthorizationPhase = "PRE_AUTHORIZATION"
12+
AuthorizationPhase_POST_AUTHORIZATION AuthorizationPhase = "POST_AUTHORIZATION"
13+
)

0 commit comments

Comments
 (0)