package utils import ( "encoding/base64" "fmt" "strings" "gitea.pena/PenaSide/treasurer/internal/proto/treasurer" "gitea.pena/PenaSide/treasurer/internal/models/yandex" ) func ConvertYoomoneySercetsToAuth(authType, storeID, secretKey string) string { credentials := fmt.Sprintf("%s:%s", storeID, secretKey) encoded := base64.StdEncoding.EncodeToString([]byte(credentials)) trimedAuthType := strings.TrimSpace(authType) return fmt.Sprintf("%s %s", trimedAuthType, encoded) } func ProtoItem2ReceiptItem(in *treasurer.Item) yandex.Item { return yandex.Item{ Description: in.Description, Amount: yandex.ReceiptAmount{ Value: in.Money, Currency: in.Currency, }, VatCode: 1, Quantity: 1, Measure: in.Measure, PaymentSubject: "service", PaymentMode: "full_prepayment", } } func ProtoItems2ReceiptItems(in []*treasurer.Item) []yandex.Item { length := len(in) out := make([]yandex.Item, length, length) for i, item := range in { out[i] = ProtoItem2ReceiptItem(item) } return out }