36 lines
904 B
Go
36 lines
904 B
Go
package v1
|
|
|
|
import (
|
|
"quyun/v2/app/http/v1/dto"
|
|
"quyun/v2/app/services"
|
|
|
|
"github.com/gofiber/fiber/v3"
|
|
)
|
|
|
|
// @provider
|
|
type Transaction struct{}
|
|
|
|
// Create Order
|
|
//
|
|
// @Router /v1/t/:tenantCode/orders [post]
|
|
// @Router /v1/t/:tenantCode/orders/:id<int>/pay [post]
|
|
// @Router /v1/t/:tenantCode/orders/:id<int>/status [get]
|
|
// @Router /v1/t/:tenantCode/webhook/payment/notify [post]
|
|
|
|
// @Summary Payment Webhook
|
|
// @Description Payment Webhook
|
|
// @Tags Transaction
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param form body dto.PaymentWebhookForm true "Webhook Data"
|
|
// @Success 200 {string} string "success"
|
|
// @Bind form body
|
|
func (t *Transaction) Webhook(ctx fiber.Ctx, form *dto.PaymentWebhookForm) (string, error) {
|
|
tenantID := getTenantID(ctx)
|
|
err := services.Order.ProcessExternalPayment(ctx, tenantID, form.OrderID, form.ExternalID)
|
|
if err != nil {
|
|
return "fail", err
|
|
}
|
|
return "success", nil
|
|
}
|