popok external token fix + game list endpoint + recommedation fix
This commit is contained in:
parent
354890ece1
commit
0ef3a25ee7
|
|
@ -137,6 +137,7 @@ func main() {
|
||||||
wallet.TransferStore(store),
|
wallet.TransferStore(store),
|
||||||
*walletSvc,
|
*walletSvc,
|
||||||
user.UserStore(store),
|
user.UserStore(store),
|
||||||
|
cfg,
|
||||||
chapaClient,
|
chapaClient,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: auth.sql
|
// source: auth.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: bet.sql
|
// source: bet.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: branch.sql
|
// source: branch.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: cashier.sql
|
// source: cashier.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: company.sql
|
// source: company.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: copyfrom.go
|
// source: copyfrom.go
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: events.sql
|
// source: events.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: leagues.sql
|
// source: leagues.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: monitor.sql
|
// source: monitor.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: notification.sql
|
// source: notification.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: odds.sql
|
// source: odds.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: otp.sql
|
// source: otp.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: referal.sql
|
// source: referal.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: result.sql
|
// source: result.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: settings.sql
|
// source: settings.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: ticket.sql
|
// source: ticket.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: transactions.sql
|
// source: transactions.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: transfer.sql
|
// source: transfer.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: user.sql
|
// source: user.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: virtual_games.sql
|
// source: virtual_games.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Code generated by sqlc. DO NOT EDIT.
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// sqlc v1.28.0
|
// sqlc v1.29.0
|
||||||
// source: wallet.sql
|
// source: wallet.sql
|
||||||
|
|
||||||
package dbgen
|
package dbgen
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ func convertCreateTransfer(transfer domain.CreateTransfer) dbgen.CreateTransferP
|
||||||
Int64: transfer.CashierID.Value,
|
Int64: transfer.CashierID.Value,
|
||||||
Valid: transfer.CashierID.Valid,
|
Valid: transfer.CashierID.Valid,
|
||||||
},
|
},
|
||||||
|
ReferenceNumber: pgtype.Text{String: string(transfer.ReferenceNumber), Valid: true},
|
||||||
|
|
||||||
PaymentMethod: pgtype.Text{String: string(transfer.PaymentMethod), Valid: true},
|
PaymentMethod: pgtype.Text{String: string(transfer.PaymentMethod), Valid: true},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,9 +96,9 @@ func (r *VirtualGameRepo) CreateVirtualGameTransaction(ctx context.Context, tx *
|
||||||
|
|
||||||
func (r *VirtualGameRepo) CreateVirtualGameHistory(ctx context.Context, his *domain.VirtualGameHistory) error {
|
func (r *VirtualGameRepo) CreateVirtualGameHistory(ctx context.Context, his *domain.VirtualGameHistory) error {
|
||||||
params := dbgen.CreateVirtualGameHistoryParams{
|
params := dbgen.CreateVirtualGameHistoryParams{
|
||||||
SessionID: pgtype.Text{String: his.SessionID, Valid: true},
|
SessionID: pgtype.Text{String: his.SessionID, Valid: true},
|
||||||
UserID: his.UserID,
|
UserID: his.UserID,
|
||||||
WalletID: pgtype.Int8{Int64: *his.WalletID, Valid: true},
|
// WalletID: pgtype.Int8{Int64: *his.WalletID, Valid: true},
|
||||||
TransactionType: his.TransactionType,
|
TransactionType: his.TransactionType,
|
||||||
Amount: his.Amount,
|
Amount: his.Amount,
|
||||||
Currency: his.Currency,
|
Currency: his.Currency,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -30,9 +31,9 @@ func NewClient(baseURL, secretKey string) *Client {
|
||||||
|
|
||||||
func (c *Client) InitializePayment(ctx context.Context, req domain.ChapaDepositRequest) (domain.ChapaDepositResponse, error) {
|
func (c *Client) InitializePayment(ctx context.Context, req domain.ChapaDepositRequest) (domain.ChapaDepositResponse, error) {
|
||||||
payload := map[string]interface{}{
|
payload := map[string]interface{}{
|
||||||
"amount": req.Amount,
|
"amount": fmt.Sprintf("%.2f", float64(req.Amount)/100),
|
||||||
"currency": req.Currency,
|
"currency": req.Currency,
|
||||||
"email": req.Email,
|
// "email": req.Email,
|
||||||
"first_name": req.FirstName,
|
"first_name": req.FirstName,
|
||||||
"last_name": req.LastName,
|
"last_name": req.LastName,
|
||||||
"tx_ref": req.TxRef,
|
"tx_ref": req.TxRef,
|
||||||
|
|
@ -40,6 +41,8 @@ func (c *Client) InitializePayment(ctx context.Context, req domain.ChapaDepositR
|
||||||
"return_url": req.ReturnURL,
|
"return_url": req.ReturnURL,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("\n\nChapa Payload: %+v\n\n", payload)
|
||||||
|
|
||||||
payloadBytes, err := json.Marshal(payload)
|
payloadBytes, err := json.Marshal(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return domain.ChapaDepositResponse{}, fmt.Errorf("failed to marshal payload: %w", err)
|
return domain.ChapaDepositResponse{}, fmt.Errorf("failed to marshal payload: %w", err)
|
||||||
|
|
@ -50,6 +53,8 @@ func (c *Client) InitializePayment(ctx context.Context, req domain.ChapaDepositR
|
||||||
return domain.ChapaDepositResponse{}, fmt.Errorf("failed to create request: %w", err)
|
return domain.ChapaDepositResponse{}, fmt.Errorf("failed to create request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("\n\nBase URL is: %+v\n\n", c.baseURL)
|
||||||
|
|
||||||
httpReq.Header.Set("Authorization", "Bearer "+c.secretKey)
|
httpReq.Header.Set("Authorization", "Bearer "+c.secretKey)
|
||||||
httpReq.Header.Set("Content-Type", "application/json")
|
httpReq.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
|
|
@ -59,6 +64,11 @@ func (c *Client) InitializePayment(ctx context.Context, req domain.ChapaDepositR
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
body, _ := io.ReadAll(resp.Body) // <-- Add this
|
||||||
|
return domain.ChapaDepositResponse{}, fmt.Errorf("unexpected status code: %d - %s", resp.StatusCode, string(body)) // <-- Log it
|
||||||
|
}
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return domain.ChapaDepositResponse{}, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
|
return domain.ChapaDepositResponse{}, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +87,7 @@ func (c *Client) InitializePayment(ctx context.Context, req domain.ChapaDepositR
|
||||||
|
|
||||||
return domain.ChapaDepositResponse{
|
return domain.ChapaDepositResponse{
|
||||||
CheckoutURL: response.Data.CheckoutURL,
|
CheckoutURL: response.Data.CheckoutURL,
|
||||||
// Reference: req.TxRef,
|
Reference: req.TxRef,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ func NewService(
|
||||||
transferStore wallet.TransferStore,
|
transferStore wallet.TransferStore,
|
||||||
walletStore wallet.Service,
|
walletStore wallet.Service,
|
||||||
userStore user.UserStore,
|
userStore user.UserStore,
|
||||||
|
cfg *config.Config,
|
||||||
chapaClient *Client,
|
chapaClient *Client,
|
||||||
|
|
||||||
) *Service {
|
) *Service {
|
||||||
|
|
@ -38,6 +39,7 @@ func NewService(
|
||||||
transferStore: transferStore,
|
transferStore: transferStore,
|
||||||
walletStore: walletStore,
|
walletStore: walletStore,
|
||||||
userStore: userStore,
|
userStore: userStore,
|
||||||
|
cfg: cfg,
|
||||||
chapaClient: chapaClient,
|
chapaClient: chapaClient,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -102,8 +104,8 @@ func (s *Service) InitiateDeposit(ctx context.Context, userID int64, amount doma
|
||||||
FirstName: user.FirstName,
|
FirstName: user.FirstName,
|
||||||
LastName: user.LastName,
|
LastName: user.LastName,
|
||||||
TxRef: reference,
|
TxRef: reference,
|
||||||
CallbackURL: "https://fortunebet.com/api/v1/payments/callback",
|
CallbackURL: s.cfg.CHAPA_CALLBACK_URL,
|
||||||
ReturnURL: "https://fortunebet.com/api/v1/payment-success",
|
ReturnURL: s.cfg.CHAPA_RETURN_URL,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -220,6 +222,9 @@ func (s *Service) ManualVerifTransaction(ctx context.Context, txRef string) (*do
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("\n\nSender wallet ID is:%v\n\n", transfer.SenderWalletID.Value)
|
||||||
|
fmt.Printf("\n\nTransfer is:%v\n\n", transfer)
|
||||||
|
|
||||||
// just making sure that the sender id is valid
|
// just making sure that the sender id is valid
|
||||||
if !transfer.SenderWalletID.Valid {
|
if !transfer.SenderWalletID.Valid {
|
||||||
return nil, fmt.Errorf("sender wallet id is invalid: %v \n", transfer.SenderWalletID)
|
return nil, fmt.Errorf("sender wallet id is invalid: %v \n", transfer.SenderWalletID)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ func (h *Handler) InitiateDeposit(c *fiber.Ctx) error {
|
||||||
userID, ok := c.Locals("user_id").(int64)
|
userID, ok := c.Locals("user_id").(int64)
|
||||||
if !ok {
|
if !ok {
|
||||||
return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
|
||||||
Error: "invalid user ID",
|
Error: "invalid user ID",
|
||||||
|
Message: "User ID is required to initiate a deposit",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,7 +34,8 @@ func (h *Handler) InitiateDeposit(c *fiber.Ctx) error {
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
fmt.Sprintln("We first first are here init Chapa payment")
|
fmt.Sprintln("We first first are here init Chapa payment")
|
||||||
return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
|
Message: "Failed to parse request body",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,12 +47,15 @@ func (h *Handler) InitiateDeposit(c *fiber.Ctx) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
Message: checkoutURL,
|
Message: "Failed to initiate Chapa deposit",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Status(fiber.StatusOK).JSON(domain.ChapaDepositResponse{
|
return c.Status(fiber.StatusOK).JSON(domain.Response{
|
||||||
CheckoutURL: checkoutURL,
|
Message: "Chapa deposit process initiated successfully",
|
||||||
|
Data: checkoutURL,
|
||||||
|
StatusCode: 200,
|
||||||
|
Success: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ func (a *App) initAppRoutes() {
|
||||||
group.Get("/logs", a.authMiddleware, a.SuperAdminOnly, handlers.GetLogsHandler(ctx))
|
group.Get("/logs", a.authMiddleware, a.SuperAdminOnly, handlers.GetLogsHandler(ctx))
|
||||||
|
|
||||||
// Recommendation Routes
|
// Recommendation Routes
|
||||||
group.Get("/virtual-games/recommendations/:userID", h.GetRecommendations)
|
// group.Get("/virtual-games/recommendations/:userID", h.GetRecommendations)
|
||||||
|
|
||||||
// Transactions /transactions
|
// Transactions /transactions
|
||||||
a.fiber.Post("/transaction", a.authMiddleware, h.CreateTransaction)
|
a.fiber.Post("/transaction", a.authMiddleware, h.CreateTransaction)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user