feat: tenant-scoped routing and portal navigation
This commit is contained in:
@@ -13,7 +13,7 @@ type Transaction struct{}
|
||||
|
||||
// Create Order
|
||||
//
|
||||
// @Router /v1/orders [post]
|
||||
// @Router /t/:tenantCode/v1/orders [post]
|
||||
// @Summary Create Order
|
||||
// @Description Create Order
|
||||
// @Tags Transaction
|
||||
@@ -28,12 +28,13 @@ func (t *Transaction) Create(
|
||||
user *models.User,
|
||||
form *dto.OrderCreateForm,
|
||||
) (*dto.OrderCreateResponse, error) {
|
||||
return services.Order.Create(ctx, user.ID, form)
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Order.Create(ctx, tenantID, user.ID, form)
|
||||
}
|
||||
|
||||
// Pay for order
|
||||
//
|
||||
// @Router /v1/orders/:id<int>/pay [post]
|
||||
// @Router /t/:tenantCode/v1/orders/:id<int>/pay [post]
|
||||
// @Summary Pay for order
|
||||
// @Description Pay for order
|
||||
// @Tags Transaction
|
||||
@@ -51,12 +52,13 @@ func (t *Transaction) Pay(
|
||||
id int64,
|
||||
form *dto.OrderPayForm,
|
||||
) (*dto.OrderPayResponse, error) {
|
||||
return services.Order.Pay(ctx, user.ID, id, form)
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Order.Pay(ctx, tenantID, user.ID, id, form)
|
||||
}
|
||||
|
||||
// Check order payment status
|
||||
//
|
||||
// @Router /v1/orders/:id<int>/status [get]
|
||||
// @Router /t/:tenantCode/v1/orders/:id<int>/status [get]
|
||||
// @Summary Check order status
|
||||
// @Description Check order payment status
|
||||
// @Tags Transaction
|
||||
@@ -66,7 +68,8 @@ func (t *Transaction) Pay(
|
||||
// @Success 200 {object} dto.OrderStatusResponse
|
||||
// @Bind id path
|
||||
func (t *Transaction) Status(ctx fiber.Ctx, id int64) (*dto.OrderStatusResponse, error) {
|
||||
return services.Order.Status(ctx, id)
|
||||
tenantID := getTenantID(ctx)
|
||||
return services.Order.Status(ctx, tenantID, id)
|
||||
}
|
||||
|
||||
type WebhookForm struct {
|
||||
@@ -76,7 +79,7 @@ type WebhookForm struct {
|
||||
|
||||
// Payment Webhook
|
||||
//
|
||||
// @Router /v1/webhook/payment/notify [post]
|
||||
// @Router /t/:tenantCode/v1/webhook/payment/notify [post]
|
||||
// @Summary Payment Webhook
|
||||
// @Description Payment Webhook
|
||||
// @Tags Transaction
|
||||
@@ -86,7 +89,8 @@ type WebhookForm struct {
|
||||
// @Success 200 {string} string "success"
|
||||
// @Bind form body
|
||||
func (t *Transaction) Webhook(ctx fiber.Ctx, form *WebhookForm) (string, error) {
|
||||
err := services.Order.ProcessExternalPayment(ctx, form.OrderID, form.ExternalID)
|
||||
tenantID := getTenantID(ctx)
|
||||
err := services.Order.ProcessExternalPayment(ctx, tenantID, form.OrderID, form.ExternalID)
|
||||
if err != nil {
|
||||
return "fail", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user