Update Furtuna Payment VA Linkqu
This commit is contained in:
parent
764ea68bf9
commit
9ec777be36
@ -47,7 +47,7 @@ linkqu:
|
||||
signature_key: "LinkQu@2020"
|
||||
username: "LI307GXIN"
|
||||
pin: "2K2NPCBBNNTovgB"
|
||||
callback_url: "https://furtuna-be.app-dev.altru.id/api/linkqu/callback"
|
||||
callback_url: "https://furtuna-be.app-dev.altru.id/api/v1/linkqu/callback"
|
||||
|
||||
brevo:
|
||||
api_key: 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
|
||||
|
||||
71
internal/handlers/http/linqu/order.go
Normal file
71
internal/handlers/http/linqu/order.go
Normal file
@ -0,0 +1,71 @@
|
||||
package mdtrns
|
||||
|
||||
import (
|
||||
"furtuna-be/internal/handlers/request"
|
||||
"furtuna-be/internal/handlers/response"
|
||||
"furtuna-be/internal/services"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
service services.Order
|
||||
}
|
||||
|
||||
func (h *Handler) Route(group *gin.RouterGroup, jwt gin.HandlerFunc) {
|
||||
route := group.Group("/midtrans")
|
||||
|
||||
route.POST("/callback", h.Callback)
|
||||
}
|
||||
|
||||
func NewHandler(service services.Order) *Handler {
|
||||
return &Handler{
|
||||
service: service,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) Callback(c *gin.Context) {
|
||||
var callbackData request.MidtransCallbackRequest
|
||||
if err := c.ShouldBindJSON(&callbackData); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
validStatuses := []string{"settlement", "expire", "deny", "cancel", "capture", "failure"}
|
||||
|
||||
isValidStatus := false
|
||||
for _, status := range validStatuses {
|
||||
if callbackData.TransactionStatus == status {
|
||||
isValidStatus = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !isValidStatus {
|
||||
c.JSON(http.StatusOK, response.BaseResponse{
|
||||
Success: true,
|
||||
Status: http.StatusOK,
|
||||
Message: "",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
err := h.service.ProcessCallback(c, callbackData.ToEntity())
|
||||
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnauthorized, response.BaseResponse{
|
||||
Success: false,
|
||||
Status: http.StatusBadRequest,
|
||||
Message: err.Error(),
|
||||
Data: nil,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, response.BaseResponse{
|
||||
Success: true,
|
||||
Status: http.StatusOK,
|
||||
Message: "order",
|
||||
})
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user