fix make order
parent
54b7fedcdb
commit
802b70a601
|
@ -3,11 +3,11 @@ package AgentType
|
||||||
type AgentType string
|
type AgentType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
BANKING_PAYMENT_AGENT = "banking_payment_agent" // Банковский платежный агент
|
BANKING_PAYMENT_AGENT AgentType = "banking_payment_agent" // Банковский платежный агент
|
||||||
BANKING_PAYMENT_SUBAGENT = "banking_payment_subagent" // Банковский платежный субагент
|
BANKING_PAYMENT_SUBAGENT AgentType = "banking_payment_subagent" // Банковский платежный субагент
|
||||||
PAYMENT_AGENT = "payment_agent" // Платежный агент
|
PAYMENT_AGENT AgentType = "payment_agent" // Платежный агент
|
||||||
PAYMENT_SUBAGENT = "payment_subagent" // Платежный субагент
|
PAYMENT_SUBAGENT AgentType = "payment_subagent" // Платежный субагент
|
||||||
ATTORNEY = "attorney" // Поверенный
|
ATTORNEY AgentType = "attorney" // Поверенный
|
||||||
COMMISSIONER = "commissioner" // Комиссионер
|
COMMISSIONER AgentType = "commissioner" // Комиссионер
|
||||||
AGENT = "agent" // Агент
|
AGENT AgentType = "agent" // Агент
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,28 +3,28 @@ package Measure
|
||||||
type Measure string
|
type Measure string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PIECE = "piece" // Штука, единица товара
|
PIECE Measure = "piece" // Штука, единица товара
|
||||||
GRAM = "gram" // Грамм
|
GRAM Measure = "gram" // Грамм
|
||||||
KILOGRAM = "kilogram" // Килограмм
|
KILOGRAM Measure = "kilogram" // Килограмм
|
||||||
TON = "ton" // Тонна
|
TON Measure = "ton" // Тонна
|
||||||
CENTIMETER = "centimeter" // Сантиметр
|
CENTIMETER Measure = "centimeter" // Сантиметр
|
||||||
DECIMETER = "decimeter" // Дециметр
|
DECIMETER Measure = "decimeter" // Дециметр
|
||||||
METER = "meter" // Метр
|
METER Measure = "meter" // Метр
|
||||||
SQUARE_CENTIMETER = "square_centimeter" // Квадратный сантиметр
|
SQUARE_CENTIMETER Measure = "square_centimeter" // Квадратный сантиметр
|
||||||
SQUARE_DECIMETER = "square_decimeter" // Квадратный дециметр
|
SQUARE_DECIMETER Measure = "square_decimeter" // Квадратный дециметр
|
||||||
SQUARE_METER = "square_meter" // Квадратный метр
|
SQUARE_METER Measure = "square_meter" // Квадратный метр
|
||||||
MILLILITER = "milliliter" // Миллилитр
|
MILLILITER Measure = "milliliter" // Миллилитр
|
||||||
LITER = "liter" // Литр
|
LITER Measure = "liter" // Литр
|
||||||
CUBIC_METER = "cubic_meter" // Кубический метр
|
CUBIC_METER Measure = "cubic_meter" // Кубический метр
|
||||||
KILOWATT_HOUR = "kilowatt_hour" // Килловат-час
|
KILOWATT_HOUR Measure = "kilowatt_hour" // Килловат-час
|
||||||
GIGACALORIE = "gigacalorie" // Гигакалория
|
GIGACALORIE Measure = "gigacalorie" // Гигакалория
|
||||||
DAY = "day" // Сутки
|
DAY Measure = "day" // Сутки
|
||||||
HOUR = "hour" // Час
|
HOUR Measure = "hour" // Час
|
||||||
MINUTE = "minute" // Минута
|
MINUTE Measure = "minute" // Минута
|
||||||
SECOND = "second" // Секунда
|
SECOND Measure = "second" // Секунда
|
||||||
KILOBYTE = "kilobyte" // Килобайт
|
KILOBYTE Measure = "kilobyte" // Килобайт
|
||||||
MEGABYTE = "megabyte" // Мегабайт
|
MEGABYTE Measure = "megabyte" // Мегабайт
|
||||||
GIGABYTE = "gigabyte" // Гигабайт
|
GIGABYTE Measure = "gigabyte" // Гигабайт
|
||||||
TERABYTE = "terabyte" // Терабайт
|
TERABYTE Measure = "terabyte" // Терабайт
|
||||||
ANOTHER = "another" // Другое
|
ANOTHER Measure = "another" // Другое
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,11 +3,11 @@ package PaymentMode
|
||||||
type PaymentMode string
|
type PaymentMode string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FULL_PREPAYMENT = "full_prepayment" // Полная предоплата
|
FULL_PREPAYMENT PaymentMode = "full_prepayment" // Полная предоплата
|
||||||
PARTIAL_PREPAYMENT = "partial_prepayment" // Частичная предоплата
|
PARTIAL_PREPAYMENT PaymentMode = "partial_prepayment" // Частичная предоплата
|
||||||
ADVANCE = "advance" // Аванс
|
ADVANCE PaymentMode = "advance" // Аванс
|
||||||
FULL_PAYMENT = "full_payment" // Полный расчет
|
FULL_PAYMENT PaymentMode = "full_payment" // Полный расчет
|
||||||
PARTIAL_PAYMENT = "partial_payment" // Частичный расчет и кредит
|
PARTIAL_PAYMENT PaymentMode = "partial_payment" // Частичный расчет и кредит
|
||||||
CREDIT = "credit" // Кредит
|
CREDIT PaymentMode = "credit" // Кредит
|
||||||
CREDIT_PAYMENT = "credit_payment" // Выплата по кредиту
|
CREDIT_PAYMENT PaymentMode = "credit_payment" // Выплата по кредиту
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,23 +3,23 @@ package PaymentSubject
|
||||||
type PaymentSubject string
|
type PaymentSubject string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
COMMODITY = "commodity" //Товар Товар
|
COMMODITY PaymentSubject = "commodity" //Товар Товар
|
||||||
EXCISE = "excise" //Подакцизный товар
|
EXCISE PaymentSubject = "excise" //Подакцизный товар
|
||||||
JOB = "job" //Работа
|
JOB PaymentSubject = "job" //Работа
|
||||||
SERVICE = "service" //Услуга Услуга
|
SERVICE PaymentSubject = "service" //Услуга Услуга
|
||||||
PAYMENT = "payment" //Платеж Платеж
|
PAYMENT PaymentSubject = "payment" //Платеж Платеж
|
||||||
CASINO = "casino" // Платеж казино
|
CASINO PaymentSubject = "casino" // Платеж казино
|
||||||
GAMBLING_BET = "gambling_bet" //Ставка в азартной игре
|
GAMBLING_BET PaymentSubject = "gambling_bet" //Ставка в азартной игре
|
||||||
GAMBLING_PRIZE = "gambling_prize" // Выигрыш азартной игры
|
GAMBLING_PRIZE PaymentSubject = "gambling_prize" // Выигрыш азартной игры
|
||||||
LOTTERY = "lottery" // Лотерейный билет
|
LOTTERY PaymentSubject = "lottery" // Лотерейный билет
|
||||||
LOTTERY_PRIZE = "lottery_prize" // Выигрыш в лотерею
|
LOTTERY_PRIZE PaymentSubject = "lottery_prize" // Выигрыш в лотерею
|
||||||
INTELLECTUAL_ACTIVITY = "intellectual_activity" //Результаты интеллектуальной деятельности
|
INTELLECTUAL_ACTIVITY PaymentSubject = "intellectual_activity" //Результаты интеллектуальной деятельности
|
||||||
AGENT_COMMISSION = "agent_commission" //Агентское вознаграждение
|
AGENT_COMMISSION PaymentSubject = "agent_commission" //Агентское вознаграждение
|
||||||
PROPERTY_RIGHT = "property_right" //Имущественное право
|
PROPERTY_RIGHT PaymentSubject = "property_right" //Имущественное право
|
||||||
NON_OPERATING_GAIN = "non_operating_gain" //Внереализационный доход
|
NON_OPERATING_GAIN PaymentSubject = "non_operating_gain" //Внереализационный доход
|
||||||
INSURANCE_PREMIUM = "insurance_premium" //Страховой сбор
|
INSURANCE_PREMIUM PaymentSubject = "insurance_premium" //Страховой сбор
|
||||||
SALES_TAX = "sales_tax" //Торговый сбор
|
SALES_TAX PaymentSubject = "sales_tax" //Торговый сбор
|
||||||
RESORT_FEE = "resort_fee" // Курортный сбор
|
RESORT_FEE PaymentSubject = "resort_fee" // Курортный сбор
|
||||||
COMPOSITE = "composite" // Несколько вариантов
|
COMPOSITE PaymentSubject = "composite" // Несколько вариантов
|
||||||
ANOTHER = "another" // Другое
|
ANOTHER PaymentSubject = "another" // Другое
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,8 +3,8 @@ package Settlements
|
||||||
type Settlements string
|
type Settlements string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CASHLESS = "cashless" // Безналичный расчет
|
CASHLESS Settlements = "cashless" // Безналичный расчет
|
||||||
PREPAYMENT = "prepayment" // Предоплата (аванс)
|
PREPAYMENT Settlements = "prepayment" // Предоплата (аванс)
|
||||||
POSTPAYMENT = "postpayment" // Постоплата (кредит)
|
POSTPAYMENT Settlements = "postpayment" // Постоплата (кредит)
|
||||||
CONSIDERATION = "consideration" // Встречное предоставление
|
CONSIDERATION Settlements = "consideration" // Встречное предоставление
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@ package TaxSystemCode
|
||||||
type TaxSystemCode int
|
type TaxSystemCode int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
GENERAL = iota + 1
|
GENERAL TaxSystemCode = iota + 1
|
||||||
USN_INCOME
|
USN_INCOME
|
||||||
USN_INCOME_MINUS_EXPENCES
|
USN_INCOME_MINUS_EXPENCES
|
||||||
ENVD
|
ENVD
|
||||||
|
|
|
@ -80,7 +80,7 @@ func basicAuth(username, password string) string {
|
||||||
return base64.StdEncoding.EncodeToString([]byte(auth))
|
return base64.StdEncoding.EncodeToString([]byte(auth))
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreatePayment(orderId int, sum float64, fullName string, email string, phone string, items []KassaReceiptItems) (map[string]interface{}, error) {
|
func CreatePayment(orderId int, sum float64, fullName string, email string, phone string, items []KassaReceiptItems) (*KassaResult, error) {
|
||||||
req := KassaPaymentReq{
|
req := KassaPaymentReq{
|
||||||
Amount: KassaAmount{Value: fmt.Sprintf("%f", sum), Currency: "RUB"},
|
Amount: KassaAmount{Value: fmt.Sprintf("%f", sum), Currency: "RUB"},
|
||||||
Description: fmt.Sprintf("Заказ №%d", orderId),
|
Description: fmt.Sprintf("Заказ №%d", orderId),
|
||||||
|
@ -111,7 +111,7 @@ func CreatePayment(orderId int, sum float64, fullName string, email string, phon
|
||||||
|
|
||||||
response, err := client.Do(request)
|
response, err := client.Do(request)
|
||||||
|
|
||||||
result := map[string]interface{}{}
|
result := new(KassaResult)
|
||||||
json.NewDecoder(response.Body).Decode(&result)
|
json.NewDecoder(response.Body).Decode(&result)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,7 +3,9 @@ package endpoints
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"relynolli-server/models"
|
"relynolli-server/models"
|
||||||
|
"relynolli-server/services"
|
||||||
"relynolli-server/status"
|
"relynolli-server/status"
|
||||||
"relynolli-server/storage"
|
"relynolli-server/storage"
|
||||||
"time"
|
"time"
|
||||||
|
@ -58,31 +60,51 @@ func (h handlers) GetTotal(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h handlers) MakeOrder(c *gin.Context) {
|
func (h handlers) MakeOrder(c *gin.Context) {
|
||||||
|
ctx := context.Background()
|
||||||
// VALIDATION
|
// VALIDATION
|
||||||
validate := validator.New(validator.WithRequiredStructEnabled())
|
validate := validator.New(validator.WithRequiredStructEnabled())
|
||||||
req := makeOrderRequest{}
|
req := makeOrderRequest{}
|
||||||
err := c.ShouldBindJSON(&req)
|
err := c.ShouldBindJSON(&req)
|
||||||
|
meta := models.Meta{
|
||||||
|
RequestStarted: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
resp := models.Response{
|
||||||
|
Status: status.STATUS_OK,
|
||||||
|
Meta: &meta,
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//c.JSON(400, models.Response{Status: http.StatusBadRequest, Info: fmt.Sprintf("ERROR: %s", err.Error())})
|
meta.RequestFinished = time.Now().Unix()
|
||||||
|
resp.Info = fmt.Sprintf("ERROR: %s", err.Error())
|
||||||
|
resp.Status = status.STATUS_BAD_REQUEST
|
||||||
|
c.JSON(400, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
validationErr := validate.Struct(req)
|
validationErr := validate.Struct(req)
|
||||||
|
|
||||||
if validationErr != nil {
|
if validationErr != nil {
|
||||||
//responseErr := validationErr.(validator.ValidationErrors)[0]
|
responseErr := validationErr.(validator.ValidationErrors)[0]
|
||||||
//c.JSON(http.StatusBadRequest, models.Response{Status: http.StatusBadRequest, Info: fmt.Sprintf("Validation Error: Field %s should be %s", responseErr.Field(), responseErr.Tag())})
|
meta.RequestFinished = time.Now().Unix()
|
||||||
|
resp.Info = fmt.Sprintf("Error: %s", responseErr.Error())
|
||||||
|
resp.Status = status.STATUS_BAD_REQUEST
|
||||||
|
c.JSON(http.StatusBadRequest, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//kassaResult, serviceErr := services.MakeOrder(req.FuserId, req.Email, req.FullName, req.PhoneNumber)
|
kassaResult, serviceErr := services.MakeOrder(ctx, req.FuserId, req.Email, req.FullName, req.PhoneNumber)
|
||||||
|
|
||||||
//if serviceErr != nil {
|
if serviceErr != nil {
|
||||||
// c.JSON(http.StatusInternalServerError, models.Response{Status: http.StatusInternalServerError, Info: fmt.Sprintf("Error: %s", serviceErr.Error())})
|
meta.RequestFinished = time.Now().Unix()
|
||||||
// return
|
resp.Info = fmt.Sprintf("Error: %s", serviceErr.Error())
|
||||||
//}
|
resp.Status = status.STATUS_SERVER_ERROR
|
||||||
|
c.JSON(http.StatusInternalServerError, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//c.JSON(http.StatusOK, kassaResult)
|
resp.Data = kassaResult
|
||||||
|
meta.RequestFinished = time.Now().Unix()
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Handlers interface {
|
type Handlers interface {
|
||||||
|
|
|
@ -1,131 +1,122 @@
|
||||||
package services
|
package services
|
||||||
|
|
||||||
//func GetTotal(fuserId int) float64 {
|
import (
|
||||||
// rdb := internal.InitRedis()
|
"context"
|
||||||
// keys, _ := rdb.Keys(context.Background(), fmt.Sprintf("api.api_cart.%d.*", fuserId)).Result()
|
"fmt"
|
||||||
|
"relynolli-server/external/bitrix"
|
||||||
|
"relynolli-server/external/kassa"
|
||||||
|
"relynolli-server/external/kassa/Measure"
|
||||||
|
"relynolli-server/external/kassa/PaymentMode"
|
||||||
|
"relynolli-server/external/kassa/PaymentSubject"
|
||||||
|
"relynolli-server/external/kassa/VatCodes"
|
||||||
|
"relynolli-server/internal"
|
||||||
|
"relynolli-server/storage"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func addProductsToOrder(ctx context.Context, storage storage.StorageCart, api bitrix.Bitrix, fuserId, orderId int) error {
|
||||||
|
// //Получаем данные из корзины
|
||||||
|
//
|
||||||
|
items, err := storage.GetCartItems(ctx, int64(fuserId))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, product := range *items {
|
||||||
|
err = api.AddProductToOrder(orderId, int(product.ProductId), product.Product.Price.BASE, int(product.Quantity))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// result := []models.CatalogWithQuantityWeb{}
|
|
||||||
//
|
func MakeOrder(ctx context.Context, fuserId int, email string, fullName string, phone string) (*kassa.KassaResult, error) {
|
||||||
// for _, key := range keys {
|
//
|
||||||
// str, _ := rdb.Get(context.Background(), key).Result()
|
// Инициализируем api
|
||||||
// item := models.CatalogWithQuantityWeb{}
|
s := storage.NewStorageCart()
|
||||||
//
|
|
||||||
// json.Unmarshal([]byte(str), &item)
|
api := bitrix.Initialize()
|
||||||
// result = append(result, item)
|
|
||||||
// }
|
// 1. Создаем анонимного пользователя
|
||||||
//
|
|
||||||
// sum := float64(0)
|
userId, _ := api.CreateAnonymousUser()
|
||||||
//
|
|
||||||
// for _, catalogItem := range result {
|
// 2. Создаем заказ
|
||||||
// sum = sum + catalogItem.Price["BASE"].(float64)*float64(catalogItem.Quantity)
|
orderId, _ := api.CreateOrder(userId)
|
||||||
// }
|
|
||||||
//
|
// --- обновляем контакт пользователя
|
||||||
// return sum
|
order, orderErr := api.GetOrderInfo(orderId)
|
||||||
//}
|
|
||||||
//
|
if orderErr != nil {
|
||||||
//type addProductsToOrderReq struct {
|
return nil, orderErr
|
||||||
// ProductId int `db:"product_id"`
|
}
|
||||||
// PriceTypeId int `db:"price_type_id"`
|
|
||||||
// Quantity int `db:"quantity"`
|
clientId, _ := strconv.Atoi(order.Clients[0].EntityId)
|
||||||
// Price float64 `db:"price"`
|
err := api.UpdateContact(clientId, email, fullName, phone)
|
||||||
//}
|
if err != nil {
|
||||||
//
|
return nil, err
|
||||||
//func addProductsToOrder(api bitrix.Bitrix, fuserId int, orderId int) error {
|
}
|
||||||
// //Получаем данные из корзины
|
|
||||||
//
|
// 3. Добавляем элементы в корзину
|
||||||
// cartItems := GetCartItems(fuserId)
|
addProductErr := addProductsToOrder(ctx, s, api, fuserId, orderId)
|
||||||
//
|
if addProductErr != nil {
|
||||||
// rdb := internal.InitRedis()
|
return nil, addProductErr
|
||||||
// rdb.Keys(context.Background(), "")
|
}
|
||||||
//
|
|
||||||
// for _, product := range cartItems {
|
// 4. Получаем обновленный ресурс заказа
|
||||||
// err := api.AddProductToOrder(orderId, product.Id, product.Price["BASE"].(float64), product.Quantity)
|
order, _ = api.GetOrderInfo(orderId)
|
||||||
// if err != nil {
|
|
||||||
// return err
|
// 5. Добавляем способ оплаты товара
|
||||||
// }
|
createPaymentError := api.CreatePayment(orderId, order.Price)
|
||||||
// }
|
|
||||||
// return nil
|
if createPaymentError != nil {
|
||||||
//
|
return nil, createPaymentError
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//func MakeOrder(fuserId int, email string, fullName string, phone string) (map[string]interface{}, error) {
|
// 6. Получаем ресурс оплаты и url для нее
|
||||||
//
|
paymentData, _ := kassa.CreatePayment(orderId, order.Price, fullName, email, phone, getItemsForPayment(order))
|
||||||
// // Инициализируем api
|
|
||||||
//
|
db := internal.InitDatabase().GetInstance()
|
||||||
// api := bitrix.Initialize()
|
|
||||||
//
|
db.NewRaw(`
|
||||||
// // 1. Создаем анонимного пользователя
|
insert into api_youkassa_payment (payment_id, order_id, link, status)
|
||||||
//
|
values (?, ?, ?,? );`,
|
||||||
// userId, _ := api.CreateAnonymousUser()
|
paymentData.Id,
|
||||||
//
|
orderId,
|
||||||
// // 2. Создаем заказ
|
paymentData.Confirmation.ConfirmationUrl,
|
||||||
// orderId, _ := api.CreateOrder(userId)
|
paymentData.Status).Exec(ctx)
|
||||||
//
|
|
||||||
// // --- обновляем контакт пользователя
|
if err != nil {
|
||||||
// order, orderErr := api.GetOrderInfo(orderId)
|
return nil, err
|
||||||
// if orderErr != nil {
|
}
|
||||||
// return nil, orderErr
|
|
||||||
// }
|
return paymentData, nil
|
||||||
// clientId, _ := strconv.Atoi(order.Clients[0].EntityId)
|
}
|
||||||
// api.UpdateContact(clientId, email, fullName, phone)
|
|
||||||
//
|
func getItemsForPayment(order *bitrix.OrderResource) []kassa.KassaReceiptItems {
|
||||||
// // 3. Добавляем элементы в корзину
|
result := []kassa.KassaReceiptItems{}
|
||||||
// addProductErr := addProductsToOrder(api, fuserId, orderId)
|
|
||||||
// if addProductErr != nil {
|
for _, basketItem := range order.BasketItems {
|
||||||
// return nil, addProductErr
|
quantity, _ := strconv.Atoi(strings.Split(basketItem.Quantity, ".")[0])
|
||||||
// }
|
item := kassa.KassaReceiptItems{
|
||||||
//
|
Description: basketItem.Name,
|
||||||
// // 4. Получаем обновленный ресурс заказа
|
Amount: kassa.KassaAmount{
|
||||||
// order, _ = api.GetOrderInfo(orderId)
|
Value: fmt.Sprintf("%f", basketItem.Price),
|
||||||
//
|
Currency: "RUB",
|
||||||
// // 5. Добавляем способ оплаты товара
|
},
|
||||||
// createPaymentError := api.CreatePayment(orderId, order.Price)
|
VatCode: VatCodes.NDS_20,
|
||||||
//
|
Quantity: fmt.Sprintf("%d", quantity),
|
||||||
// if createPaymentError != nil {
|
Measure: Measure.PIECE,
|
||||||
// return nil, createPaymentError
|
PaymentSubject: PaymentSubject.COMMODITY,
|
||||||
// }
|
PaymentMode: PaymentMode.FULL_PAYMENT,
|
||||||
//
|
}
|
||||||
// // 6. Получаем ресурс оплаты и url для нее
|
result = append(result, item)
|
||||||
// paymentData, _ := kassa.CreatePayment(orderId, order.Price, fullName, email, phone, getItemsForPayment(order))
|
}
|
||||||
//
|
|
||||||
// insPaymentDataStmt := fmt.Sprintf(`
|
return result
|
||||||
// insert into api_youkassa_payment (payment_id, order_id, link, status)
|
}
|
||||||
// values ('%s',
|
|
||||||
// '%s',
|
|
||||||
// '%s',
|
|
||||||
// '%s');
|
|
||||||
// `, paymentData["id"].(string),
|
|
||||||
// orderId,
|
|
||||||
// paymentData["confirmation"].(map[string]interface{})["confirmation_url"].(string),
|
|
||||||
// paymentData["status"].(string),
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
// db := internal.InitDatabase()
|
|
||||||
//
|
|
||||||
// db.Execute(insPaymentDataStmt)
|
|
||||||
//
|
|
||||||
// return paymentData, nil
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func getItemsForPayment(order *bitrix.OrderResource) []kassa.KassaReceiptItems {
|
|
||||||
// result := []kassa.KassaReceiptItems{}
|
|
||||||
//
|
|
||||||
// for _, basketItem := range order.BasketItems {
|
|
||||||
// quantity, _ := strconv.Atoi(strings.Split(basketItem.Quantity, ".")[0])
|
|
||||||
// item := kassa.KassaReceiptItems{
|
|
||||||
// Description: basketItem.Name,
|
|
||||||
// Amount: kassa.KassaAmount{
|
|
||||||
// Value: fmt.Sprintf("%f", basketItem.Price),
|
|
||||||
// Currency: "RUB",
|
|
||||||
// },
|
|
||||||
// VatCode: VatCodes.NDS_20,
|
|
||||||
// Quantity: fmt.Sprintf("%d", quantity),
|
|
||||||
// Measure: Measure.PIECE,
|
|
||||||
// PaymentSubject: PaymentSubject.COMMODITY,
|
|
||||||
// PaymentMode: PaymentMode.FULL_PAYMENT,
|
|
||||||
// }
|
|
||||||
// result = append(result, item)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return result
|
|
||||||
//}
|
|
||||||
|
|
Loading…
Reference in New Issue