Skip to content

Commit 1ecbd79

Browse files
authored
fix(paypal): fulfill paypal order authorize response model (#403)
* fix(paypal): fulfill paypal order authorize response model * feat(paypal): add custom client for paypal
1 parent d3c76b6 commit 1ecbd79

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

paypal/client.go

+5
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,8 @@ func (c *Client) SetProxyUrl(proxyUrlProd, proxyUrlSandbox string) {
9191
c.baseUrlProd = proxyUrlProd
9292
c.baseUrlSandbox = proxyUrlSandbox
9393
}
94+
95+
// SetHttpClient 设置自定义的xhttp.Client
96+
func (c *Client) SetHttpClient(client *xhttp.Client) {
97+
c.hc = client
98+
}

paypal/model.go

+20-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,26 @@ type Payments struct {
467467
}
468468

469469
type Authorization struct {
470-
ProcessorResponse *Processor `json:"processor_response,omitempty"`
470+
Id string `json:"id,omitempty"`
471+
Status string `json:"status,omitempty"` // CREATED、CAPTURED、DENIED、PARTIALLY_CAPTURED、VOIDED、PENDING
472+
StatusDetails *StatusDetails `json:"status_details,omitempty"`
473+
InvoiceId string `json:"invoice_id,omitempty"`
474+
CustomId string `json:"custom_id,omitempty"`
475+
Links []*Link `json:"links,omitempty"`
476+
Amount *Amount `json:"amount"`
477+
NetworkTransactionReference *NetworkTransactionReference `json:"network_transaction_reference"`
478+
SellerProtection *SellerProtection `json:"seller_protection,omitempty"`
479+
ExpirationTime string `json:"expiration_time,omitempty"`
480+
CreateTime string `json:"create_time,omitempty"`
481+
UpdateTime string `json:"update_time,omitempty"`
482+
ProcessorResponse *Processor `json:"processor_response,omitempty"`
483+
}
484+
485+
type NetworkTransactionReference struct {
486+
Id string `json:"id"`
487+
Date string `json:"date"`
488+
AcquirerReferenceNumber string `json:"acquirer_reference_number"`
489+
Network string `json:"network"`
471490
}
472491

473492
type Processor struct {

paypal/order_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func TestCreateOrder(t *testing.T) {
2020
pus = append(pus, item)
2121

2222
bm := make(gopay.BodyMap)
23+
// can be AUTHORIZE
2324
bm.Set("intent", "CAPTURE").
2425
Set("purchase_units", pus).
2526
SetBodyMap("application_context", func(b gopay.BodyMap) {
@@ -131,6 +132,9 @@ func TestOrderAuthorize(t *testing.T) {
131132
xlog.Debugf("ppRsp.Response.PurchaseUnit.Shipping.Address: %+v", v.Shipping.Address)
132133
}
133134
xlog.Debugf("ppRsp.Response.PurchaseUnit.Description: %+v", v.Description)
135+
if v.Payments != nil && v.Payments.Authorizations != nil {
136+
xlog.Debugf("ppRsp.Response.PurchaseUnit.Payments.Authorizations: %+v", v.Payments.Authorizations)
137+
}
134138
}
135139
for _, v := range ppRsp.Response.Links {
136140
xlog.Debugf("ppRsp.Response.Links: %+v", v)

0 commit comments

Comments
 (0)