/
merchant_wallet_payment.go
53 lines (48 loc) · 1.75 KB
/
merchant_wallet_payment.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
package acquiring
import (
"context"
"net/http"
"time"
"github.com/FairyTale5571/go-mono/internal/api"
)
// MerchantWalletPaymentRequest запит оплати за токеном картки
type MerchantWalletPaymentRequest struct {
CardToken string `json:"cardToken"`
Amount int `json:"amount"`
Ccy int `json:"ccy"`
Tds bool `json:"tds"`
RedirectURL string `json:"redirectUrl"`
WebHookURL string `json:"webHookUrl"`
InitiationKind string `json:"initiationKind"`
MerchantPaymInfo *MerchantPaymInfo `json:"merchantPaymInfo"`
}
// MerchantWalletPaymentResponse відповідь на запит оплати за токеном картки
type MerchantWalletPaymentResponse 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"`
}
// MerchantWalletPayment запит оплати за токеном картки
func (a *Acquiring) MerchantWalletPayment(ctx context.Context, req MerchantWalletPaymentRequest) (*MerchantWalletPaymentResponse, error) {
var resp MerchantWalletPaymentResponse
err := a.apiClient.SendRequest(ctx, api.Request{
Method: http.MethodPost,
Path: "/wallet/payment",
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
}