Skip to content

Commit

Permalink
fix(paypal): fulfill paypal order authorize response model (#403)
Browse files Browse the repository at this point in the history
* fix(paypal): fulfill paypal order authorize response model

* feat(paypal): add custom client for paypal
  • Loading branch information
Alice52 authored Jul 11, 2024
1 parent d3c76b6 commit 1ecbd79
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions paypal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ func (c *Client) SetProxyUrl(proxyUrlProd, proxyUrlSandbox string) {
c.baseUrlProd = proxyUrlProd
c.baseUrlSandbox = proxyUrlSandbox
}

// SetHttpClient 设置自定义的xhttp.Client
func (c *Client) SetHttpClient(client *xhttp.Client) {

Check failure on line 96 in paypal/client.go

View workflow job for this annotation

GitHub Actions / lint

method Client.SetHttpClient already declared at paypal/client.go:75:18
c.hc = client
}
21 changes: 20 additions & 1 deletion paypal/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,26 @@ type Payments struct {
}

type Authorization struct {
ProcessorResponse *Processor `json:"processor_response,omitempty"`
Id string `json:"id,omitempty"`
Status string `json:"status,omitempty"` // CREATED、CAPTURED、DENIED、PARTIALLY_CAPTURED、VOIDED、PENDING
StatusDetails *StatusDetails `json:"status_details,omitempty"`
InvoiceId string `json:"invoice_id,omitempty"`
CustomId string `json:"custom_id,omitempty"`
Links []*Link `json:"links,omitempty"`
Amount *Amount `json:"amount"`
NetworkTransactionReference *NetworkTransactionReference `json:"network_transaction_reference"`
SellerProtection *SellerProtection `json:"seller_protection,omitempty"`
ExpirationTime string `json:"expiration_time,omitempty"`
CreateTime string `json:"create_time,omitempty"`
UpdateTime string `json:"update_time,omitempty"`
ProcessorResponse *Processor `json:"processor_response,omitempty"`
}

type NetworkTransactionReference struct {
Id string `json:"id"`
Date string `json:"date"`
AcquirerReferenceNumber string `json:"acquirer_reference_number"`
Network string `json:"network"`
}

type Processor struct {
Expand Down
4 changes: 4 additions & 0 deletions paypal/order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestCreateOrder(t *testing.T) {
pus = append(pus, item)

bm := make(gopay.BodyMap)
// can be AUTHORIZE
bm.Set("intent", "CAPTURE").
Set("purchase_units", pus).
SetBodyMap("application_context", func(b gopay.BodyMap) {
Expand Down Expand Up @@ -131,6 +132,9 @@ func TestOrderAuthorize(t *testing.T) {
xlog.Debugf("ppRsp.Response.PurchaseUnit.Shipping.Address: %+v", v.Shipping.Address)
}
xlog.Debugf("ppRsp.Response.PurchaseUnit.Description: %+v", v.Description)
if v.Payments != nil && v.Payments.Authorizations != nil {
xlog.Debugf("ppRsp.Response.PurchaseUnit.Payments.Authorizations: %+v", v.Payments.Authorizations)
}
}
for _, v := range ppRsp.Response.Links {
xlog.Debugf("ppRsp.Response.Links: %+v", v)
Expand Down

0 comments on commit 1ecbd79

Please sign in to comment.