-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoice_payment_direct.go
61 lines (55 loc) · 1.95 KB
/
invoice_payment_direct.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 acquiring
import (
"context"
"net/http"
"time"
"github.com/FairyTale5571/go-mono/internal/api"
)
type CardData struct {
Pan string `json:"pan"`
Exp string `json:"exp"`
CVV int `json:"cvv"`
}
// InvoicePaymentDirectRequest тіло запиту на створення рахунку
type InvoicePaymentDirectRequest struct {
Amount int `json:"amount"`
Ccy int `json:"ccy"`
CardData *CardData `json:"cardData"`
MerchantPaymInfo *MerchantPaymInfo `json:"merchantPaymInfo"`
WebHookURL string `json:"webHookUrl"`
RedirectURL string `json:"redirectUrl"`
PaymentType PaymentType `json:"paymentType"`
SaveCardData *SaveCardData `json:"saveCardData"`
InitiationKind string `json:"initiationKind"`
TDS bool `json:"tds"`
}
// InvoicePaymentDirectResponse тіло відповіді на створення рахунку
type InvoicePaymentDirectResponse struct {
InvoiceID string `json:"invoiceId"`
TdsURL string `json:"tdsUrl"`
Status string `json:"status"`
FailureReason string `json:"failureReason"`
Amount int `json:"amount"`
Ccy int `json:"ccy"`
CreatedDate time.Time `json:"createdDate"`
ModifiedDate time.Time `json:"modifiedDate"`
}
// CreateInvoicePaymentDirect Створення рахунку для оплати
func (a *Acquiring) CreateInvoicePaymentDirect(ctx context.Context, req *InvoicePaymentDirectRequest) (*InvoicePaymentDirectResponse, error) {
var resp InvoicePaymentDirectResponse
err := a.apiClient.SendRequest(ctx, api.Request{
Method: http.MethodPost,
Path: "/invoice/payment-direct",
Body: req,
Headers: map[string]string{
"X-Token": a.token,
"X-Cms": a.cmsName,
"X-Cms-Version": a.cmsVersion,
},
Response: &resp,
})
if err != nil {
return nil, err
}
return &resp, nil
}