33 lines
710 B
Go
33 lines
710 B
Go
package services
|
|
|
|
import (
|
|
"fmt"
|
|
"relynolli-server/external/bitrix"
|
|
"relynolli-server/internal"
|
|
)
|
|
|
|
func YookassaValidate(paymentId string, status string) {
|
|
stmt := fmt.Sprintf(`select t1.order_id as order_id, t2.ID as payment_id from api_youkassa_payment t1 join b_sale_order_payment t2 on t1.order_id = t2.ORDER_ID where t1.payment_id = '%s';`, paymentId)
|
|
db := internal.InitDatabase()
|
|
rows := db.Query(stmt)
|
|
|
|
var (
|
|
orderId int
|
|
paymentIdBitrix int
|
|
)
|
|
|
|
rows.Next()
|
|
rows.Scan(&orderId, &paymentIdBitrix)
|
|
|
|
api := bitrix.Initialize()
|
|
if status == "succeeded" {
|
|
api.ApprovePayment(paymentIdBitrix, 8)
|
|
return
|
|
}
|
|
if status == "canceled" {
|
|
api.CancelOrder(orderId)
|
|
return
|
|
}
|
|
return
|
|
}
|