mirror of
https://github.com/plutov/paypal.git
synced 2025-01-23 10:21:03 +01:00
Refund from capture endpoint function (#141)
* Capture refund API call * .
This commit is contained in:
parent
6f0fe4d870
commit
2091d46d04
16
order.go
16
order.go
|
@ -94,3 +94,19 @@ func (c *Client) CaptureOrder(orderID string, captureOrderRequest CaptureOrderRe
|
||||||
|
|
||||||
return capture, nil
|
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
|
||||||
|
}
|
||||||
|
|
7
types.go
7
types.go
|
@ -243,6 +243,13 @@ type (
|
||||||
PaymentSource *PaymentSource `json:"payment_source"`
|
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
|
||||||
BatchHeader struct {
|
BatchHeader struct {
|
||||||
Amount *AmountPayout `json:"amount,omitempty"`
|
Amount *AmountPayout `json:"amount,omitempty"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user