feat: Added AuthCode and RRN support to card payment system
This commit is contained in:
16
api/kasa.go
16
api/kasa.go
@@ -40,7 +40,7 @@ func createReceiptPayCash(PayType int, sum float64, comment string) ReceiptPay {
|
||||
}
|
||||
}
|
||||
|
||||
func createReceiptPayCard(PayType int, sum float64, comment string, cardmask string, bankID string) ReceiptPay {
|
||||
func createReceiptPayCard(PayType int, sum float64, comment string, cardmask string, bankID string, rrnCode string, authCode string) ReceiptPay {
|
||||
return ReceiptPay{
|
||||
Type: PayType,
|
||||
Sum: sum,
|
||||
@@ -48,6 +48,8 @@ func createReceiptPayCard(PayType int, sum float64, comment string, cardmask str
|
||||
Paysys: "parking_pos",
|
||||
Cardmask: cardmask,
|
||||
BankID: bankID,
|
||||
Rrn: rrnCode,
|
||||
AuthCode: authCode,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +61,7 @@ func getReceiptSum(rows []ReceiptRow, taxgrp string) float64 {
|
||||
return sum
|
||||
}
|
||||
|
||||
func createReceipt(PayType int, sum float64, comment string, cardmask string, bankID string, name string, cnt int, price float64, disc float64, taxgrp string) Receipt {
|
||||
func createReceipt(PayType int, sum float64, comment string, cardmask string, bankID string, name string, cnt int, price float64, disc float64, taxgrp string, rrnCode string, authCode string) Receipt {
|
||||
rows := []ReceiptRow{createReceiptRow(name, cnt, price, comment, disc, taxgrp)}
|
||||
sum = getReceiptSum(rows, taxgrp)
|
||||
|
||||
@@ -69,7 +71,7 @@ func createReceipt(PayType int, sum float64, comment string, cardmask string, ba
|
||||
Disc: 0,
|
||||
DiscType: 0,
|
||||
Rows: rows,
|
||||
Pays: []ReceiptPay{createReceiptPayCard(PayType, sum, comment, cardmask, bankID)},
|
||||
Pays: []ReceiptPay{createReceiptPayCard(PayType, sum, comment, cardmask, bankID, rrnCode, authCode)},
|
||||
}
|
||||
|
||||
fmt.Println("Receipt sum:", r.Sum)
|
||||
@@ -109,19 +111,19 @@ func createReceipt(PayType int, sum float64, comment string, cardmask string, ba
|
||||
// }
|
||||
// }
|
||||
|
||||
func createFiscal(source string, cashier string, PayType int, sum float64, comment string, cardmask string, bankID string, name string, cnt int, price float64, disc float64, taxgrp string) FiskalCheck {
|
||||
func createFiscal(source string, cashier string, PayType int, sum float64, comment string, cardmask string, bankID string, name string, cnt int, price float64, disc float64, taxgrp string, rrnCode string, authCode string) FiskalCheck {
|
||||
return FiskalCheck{
|
||||
Source: source,
|
||||
Fiscal: Fiscal{
|
||||
Task: 1,
|
||||
Cashier: cashier,
|
||||
Receipt: createReceipt(PayType, sum, comment, cardmask, bankID, name, cnt, price, disc, taxgrp),
|
||||
Receipt: createReceipt(PayType, sum, comment, cardmask, bankID, name, cnt, price, disc, taxgrp, rrnCode, authCode),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (k *Kasa) NewSell(ctx context.Context, PayType int, sum float64, comment string, cardmask string, bankID string, name string, cnt int, price float64, disc float64, taxgrp string) (*KasaResponse, error) {
|
||||
fiscal := createFiscal("kasa", "test", PayType, sum, comment, cardmask, bankID, name, cnt, price, disc, taxgrp)
|
||||
func (k *Kasa) NewSell(ctx context.Context, PayType int, sum float64, comment string, cardmask string, bankID string, name string, cnt int, price float64, disc float64, taxgrp string, rrnCode string, authCode string) (*KasaResponse, error) {
|
||||
fiscal := createFiscal("kasa", "test", PayType, sum, comment, cardmask, bankID, name, cnt, price, disc, taxgrp, rrnCode, authCode)
|
||||
|
||||
// create a POST request to the kasa api https://kasa.vchasno.ua/api/v3/fiscal/execute with resty
|
||||
request, err := k.resty.R().SetBody(fiscal).SetHeader("Authorization", k.token).Post("https://kasa.vchasno.ua/api/v3/fiscal/execute")
|
||||
|
||||
Reference in New Issue
Block a user