mirror of
https://github.com/plutov/paypal.git
synced 2025-01-23 10:21:03 +01:00
payments/refund
This commit is contained in:
parent
27411f215f
commit
7913ad67ae
|
@ -13,6 +13,7 @@
|
||||||
* POST /v1/payments/authorization/**ID**/reauthorize
|
* POST /v1/payments/authorization/**ID**/reauthorize
|
||||||
* GET /v1/payments/sale/**ID**
|
* GET /v1/payments/sale/**ID**
|
||||||
* POST /v1/payments/sale/**ID**/refund
|
* POST /v1/payments/sale/**ID**/refund
|
||||||
|
* GET /v1/payments/refund/**ID**
|
||||||
|
|
||||||
#### Create client
|
#### Create client
|
||||||
|
|
||||||
|
@ -146,3 +147,9 @@ refund, err := c.RefundSale("1", nil)
|
||||||
// Partial
|
// Partial
|
||||||
refund, err := c.RefundSale("1", &paypalsdk.Amount{Total: "100", Currency: "USD"})
|
refund, err := c.RefundSale("1", &paypalsdk.Amount{Total: "100", Currency: "USD"})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Get Refund by ID
|
||||||
|
|
||||||
|
```go
|
||||||
|
refund, err := c.GetRefund("1")
|
||||||
|
```
|
||||||
|
|
|
@ -83,4 +83,12 @@ func main() {
|
||||||
fmt.Println("ERROR: " + err.Error())
|
fmt.Println("ERROR: " + err.Error())
|
||||||
}
|
}
|
||||||
fmt.Println("OK")
|
fmt.Println("OK")
|
||||||
|
|
||||||
|
refund, err = client.GetRefund("1")
|
||||||
|
if err == nil {
|
||||||
|
fmt.Println("DEBUG: RefundID=" + refund.ID)
|
||||||
|
} else {
|
||||||
|
fmt.Println("ERROR: " + err.Error())
|
||||||
|
}
|
||||||
|
fmt.Println("OK")
|
||||||
}
|
}
|
||||||
|
|
17
sale.go
17
sale.go
|
@ -40,3 +40,20 @@ func (c *Client) RefundSale(saleID string, a *Amount) (*Refund, error) {
|
||||||
|
|
||||||
return refund, nil
|
return refund, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRefund by ID
|
||||||
|
func (c *Client) GetRefund(refundID string) (*Refund, error) {
|
||||||
|
refund := &Refund{}
|
||||||
|
|
||||||
|
req, err := c.NewRequest("GET", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/refund/"+refundID), nil)
|
||||||
|
if err != nil {
|
||||||
|
return refund, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.SendWithAuth(req, refund)
|
||||||
|
if err != nil {
|
||||||
|
return refund, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return refund, nil
|
||||||
|
}
|
||||||
|
|
10
sale_test.go
10
sale_test.go
|
@ -26,3 +26,13 @@ func TestRefundSale(t *testing.T) {
|
||||||
t.Errorf("RefundSale must be failed")
|
t.Errorf("RefundSale must be failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetRefund(t *testing.T) {
|
||||||
|
c, _ := NewClient("clid", "secret", APIBaseSandBox)
|
||||||
|
c.GetAccessToken()
|
||||||
|
|
||||||
|
_, err := c.GetRefund("1")
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("GetRefund must be failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user