-
Notifications
You must be signed in to change notification settings - Fork 2
/
payments_service.go
32 lines (26 loc) · 935 Bytes
/
payments_service.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
package flutterwave
import (
"context"
"encoding/json"
"net/http"
)
// paymentsService is the API client for the `/gateway` endpoint
type paymentsService service
// GetPaymentLink Call flutterwave to get a payment link, redirect your customer to the link, and flutterwave will redirect back when payment is done.
//
// API Docs: https://developer.flutterwave.com/docs/collecting-payments/standard
func (service *paymentsService) GetPaymentLink(ctx context.Context, payload *GetPaymentLinkRequest) (*GetPaymentLinkResponse, *Response, error) {
request, err := service.client.newRequest(ctx, http.MethodPost, "/v3/payments", payload)
if err != nil {
return nil, nil, err
}
response, err := service.client.do(request)
if err != nil {
return nil, response, err
}
var data GetPaymentLinkResponse
if err = json.Unmarshal(*response.Body, &data); err != nil {
return nil, response, err
}
return &data, response, nil
}