From a3c2eaa0d4383f5ffdeed4d03d31c99620b21764 Mon Sep 17 00:00:00 2001 From: Yuusuke Date: Sun, 7 Feb 2021 00:56:29 +0900 Subject: [PATCH] add capture detail interface --- order.go | 16 ++++++++++++++++ types.go | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/order.go b/order.go index e32d81f..5e2a6b6 100644 --- a/order.go +++ b/order.go @@ -158,3 +158,19 @@ func (c *Client) RefundCaptureWithPaypalRequestId(ctx context.Context, } return refund, nil } + +// CapturedDetail - https://developer.paypal.com/docs/api/payments/v2/#captures_get +// Endpoint: GET /v2/payments/captures/ID +func (c *Client) CapturedDetail(ctx context.Context, captureID string ) (*CaptureDetailsResponse, error) { + response := &CaptureDetailsResponse{} + + req, err := c.NewRequest(ctx, "GET", fmt.Sprintf("%s%s", c.APIBase, "/v2/payments/captures/"+captureID), nil) + if err != nil { + return response, err + } + + if err = c.SendWithAuth(req, response); err != nil { + return response, err + } + return response, nil +} \ No newline at end of file diff --git a/types.go b/types.go index 1279f2b..e333884 100644 --- a/types.go +++ b/types.go @@ -277,6 +277,23 @@ type ( Links []Link `json:"links,omitempty"` } + //https://developer.paypal.com/docs/api/payments/v2/#captures_get + CaptureDetailsResponse struct { + Status string `json:"status,omitempty"` + StatusDetails *CaptureStatusDetails `json:"status_details,omitempty"` + ID string `json:"id,omitempty"` + Amount *Money `json:"amount,omitempty"` + InvoiceID string `json:"invoice_id,omitempty"` + CustomID string `json:"custom_id,omitempty"` + SellerProtection *SellerProtection `json:"seller_protection,omitempty"` + FinalCapture bool `json:"final_capture,omitempty"` + SellerReceivableBreakdown *SellerReceivableBreakdown `json:"seller_receivable_breakdown,omitempty"` + DisbursementMode string `json:"disbursement_mode,omitempty"` + Links []Link `json:"links,omitempty"` + UpdateTime *time.Time `json:"update_time,omitempty"` + CreateTime *time.Time `json:"create_time,omitempty"` + } + // CaptureOrderRequest - https://developer.paypal.com/docs/api/orders/v2/#orders_capture CaptureOrderRequest struct { PaymentSource *PaymentSource `json:"payment_source"`