Refund from capture endpoint function (#141)

* Capture refund API call

* .
This commit is contained in:
kenbolt 2020-04-08 09:51:17 -07:00 committed by GitHub
parent 6f0fe4d870
commit 2091d46d04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -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
}

View File

@ -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"`