forked from leebenson/paypal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapture.go
More file actions
42 lines (32 loc) · 940 Bytes
/
capture.go
File metadata and controls
42 lines (32 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package paypal
import "fmt"
// https://developer.paypal.com/webapps/developer/docs/api/#captures
// GetCapture returns details about a captured payment
func (c *Client) GetCapture(captureID string) (*Capture, error) {
req, err := NewRequest("GET", fmt.Sprintf("%s/payments/capture/%s", c.APIBase, captureID), nil)
if err != nil {
return nil, err
}
v := &Capture{}
err = c.SendWithAuth(req, v)
if err != nil {
return nil, err
}
return v, nil
}
// RefundCapture refund a captured payment. For partial refunds, a lower
// Amount object can be passed in.
func (c *Client) RefundCapture(captureID string, a *Amount) (*Refund, error) {
req, err := NewRequest("POST", fmt.Sprintf("%s/payments/capture/%s/refund", c.APIBase, captureID), struct {
Amount *Amount `json:"amount"`
}{a})
if err != nil {
return nil, err
}
v := &Refund{}
err = c.SendWithAuth(req, v)
if err != nil {
return nil, err
}
return v, nil
}