-
Notifications
You must be signed in to change notification settings - Fork 4
/
cancelations.go
61 lines (49 loc) · 1.51 KB
/
cancelations.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package cielo
import (
"bytes"
"fmt"
)
//CancelByPaymentId returns the payment/sale cancel by paymentId
//Endpoint POST /1/sales/{payment_id}/void
func (c *Client) CancelByPaymentId(paymentId string) (*Payment, error) {
buf := bytes.NewBuffer([]byte(""))
req, err := c.NewRequest("PUT", fmt.Sprintf("%s%s%s", c.Environment.APIUrl, "/1/sales/", paymentId), buf)
salePayment := &Payment{}
if err != nil {
return salePayment, err
}
err = c.Send(req, salePayment)
if err != nil {
return salePayment, err
}
return salePayment, nil
}
//CancelByPaymentId returns the payment/sale cancel by merchantOrderId
//Endpoint POST /1/sales/{merchantOrder_id}/void
func (c *Client) CancelByMerchantOrderId(mOrderId string) (*Payment, error) {
buf := bytes.NewBuffer([]byte(""))
req, err := c.NewRequest("PUT", fmt.Sprintf("%s%s%s", c.Environment.APIUrl, "/1/sales/", mOrderId), buf)
salePayment := &Payment{}
if err != nil {
return salePayment, err
}
err = c.Send(req, salePayment)
if err != nil {
return salePayment, err
}
return salePayment, nil
}
//CancelRecurrentPayment returns the payment/sale of cancel by PaymentId
//Endpoint PUT /1/RecurrentPayment/{RecurrentPaymentId}/Payment
func (c *Client) CancelRecurrentPayment(paymentId string) error {
buf := bytes.NewBuffer([]byte(""))
req, err := c.NewRequest("PUT", fmt.Sprintf("%s%s%s%s", c.Environment.APIUrl, "/1/RecurrentPayment/", paymentId, "/Deactivate"), buf)
if err != nil {
return err
}
err = c.Send(req, nil)
if err != nil {
return err
}
return nil
}