diff --git a/order.go b/order.go index 30df7ef..0ae69d3 100644 --- a/order.go +++ b/order.go @@ -94,3 +94,19 @@ func (c *Client) CaptureOrder(orderID string, captureOrderRequest CaptureOrderRe return capture, nil } + +// RefundCapture - https://developer.paypal.com/docs/api/payments/v2/#captures_refund +// Endpoint: POST /v2/payments/captures/ID/refund +func (c *Client) RefundCapture(captureID string, refundCaptureRequest RefundCaptureRequest) (*RefundResponse, error) { + refund := &RefundResponse{} + + req, err := c.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v2/payments/captures/"+captureID+"/refund"), refundCaptureRequest) + if err != nil { + return refund, err + } + + if err = c.SendWithAuth(req, refund); err != nil { + return refund, err + } + return refund, nil +} diff --git a/types.go b/types.go index 7146d0d..ea810e6 100644 --- a/types.go +++ b/types.go @@ -243,6 +243,13 @@ type ( PaymentSource *PaymentSource `json:"payment_source"` } + // RefundOrderRequest - https://developer.paypal.com/docs/api/payments/v2/#captures_refund + RefundCaptureRequest struct { + Amount *Money `json:"amount,omitempty"` + InvoiceID string `json:"invoice_id,omitempty"` + NoteToPayer string `json:"note_to_payer,omitempty"` + } + // BatchHeader struct BatchHeader struct { Amount *AmountPayout `json:"amount,omitempty"`