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),
|
||||
*walletSvc,
|
||||
user.UserStore(store),
|
||||
cfg,
|
||||
chapaClient,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: auth.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: bet.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: branch.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: cashier.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: company.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: copyfrom.go
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
|
||||
package dbgen
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: events.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: leagues.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
|
||||
package dbgen
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: monitor.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: notification.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: odds.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: otp.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: referal.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: result.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: settings.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: ticket.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: transactions.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: transfer.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: user.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: virtual_games.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: wallet.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ func convertCreateTransfer(transfer domain.CreateTransfer) dbgen.CreateTransferP
|
|||
Int64: transfer.CashierID.Value,
|
||||
Valid: transfer.CashierID.Valid,
|
||||
},
|
||||
ReferenceNumber: pgtype.Text{String: string(transfer.ReferenceNumber), Valid: true},
|
||||
|
||||
PaymentMethod: pgtype.Text{String: string(transfer.PaymentMethod), Valid: true},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ func (r *VirtualGameRepo) CreateVirtualGameHistory(ctx context.Context, his *dom
|
|||
params := dbgen.CreateVirtualGameHistoryParams{
|
||||
SessionID: pgtype.Text{String: his.SessionID, Valid: true},
|
||||
UserID: his.UserID,
|
||||
WalletID: pgtype.Int8{Int64: *his.WalletID, Valid: true},
|
||||
// WalletID: pgtype.Int8{Int64: *his.WalletID, Valid: true},
|
||||
TransactionType: his.TransactionType,
|
||||
Amount: his.Amount,
|
||||
Currency: his.Currency,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
|
@ -30,9 +31,9 @@ func NewClient(baseURL, secretKey string) *Client {
|
|||
|
||||
func (c *Client) InitializePayment(ctx context.Context, req domain.ChapaDepositRequest) (domain.ChapaDepositResponse, error) {
|
||||
payload := map[string]interface{}{
|
||||
"amount": req.Amount,
|
||||
"amount": fmt.Sprintf("%.2f", float64(req.Amount)/100),
|
||||
"currency": req.Currency,
|
||||
"email": req.Email,
|
||||
// "email": req.Email,
|
||||
"first_name": req.FirstName,
|
||||
"last_name": req.LastName,
|
||||
"tx_ref": req.TxRef,
|
||||
|
|
@ -40,6 +41,8 @@ func (c *Client) InitializePayment(ctx context.Context, req domain.ChapaDepositR
|
|||
"return_url": req.ReturnURL,
|
||||
}
|
||||
|
||||
fmt.Printf("\n\nChapa Payload: %+v\n\n", payload)
|
||||
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
fmt.Printf("\n\nBase URL is: %+v\n\n", c.baseURL)
|
||||
|
||||
httpReq.Header.Set("Authorization", "Bearer "+c.secretKey)
|
||||
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()
|
||||
|
||||
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 {
|
||||
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{
|
||||
CheckoutURL: response.Data.CheckoutURL,
|
||||
// Reference: req.TxRef,
|
||||
Reference: req.TxRef,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ func NewService(
|
|||
transferStore wallet.TransferStore,
|
||||
walletStore wallet.Service,
|
||||
userStore user.UserStore,
|
||||
cfg *config.Config,
|
||||
chapaClient *Client,
|
||||
|
||||
) *Service {
|
||||
|
|
@ -38,6 +39,7 @@ func NewService(
|
|||
transferStore: transferStore,
|
||||
walletStore: walletStore,
|
||||
userStore: userStore,
|
||||
cfg: cfg,
|
||||
chapaClient: chapaClient,
|
||||
}
|
||||
}
|
||||
|
|
@ -102,8 +104,8 @@ func (s *Service) InitiateDeposit(ctx context.Context, userID int64, amount doma
|
|||
FirstName: user.FirstName,
|
||||
LastName: user.LastName,
|
||||
TxRef: reference,
|
||||
CallbackURL: "https://fortunebet.com/api/v1/payments/callback",
|
||||
ReturnURL: "https://fortunebet.com/api/v1/payment-success",
|
||||
CallbackURL: s.cfg.CHAPA_CALLBACK_URL,
|
||||
ReturnURL: s.cfg.CHAPA_RETURN_URL,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -220,6 +222,9 @@ func (s *Service) ManualVerifTransaction(ctx context.Context, txRef string) (*do
|
|||
}, 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
|
||||
if !transfer.SenderWalletID.Valid {
|
||||
return nil, fmt.Errorf("sender wallet id is invalid: %v \n", transfer.SenderWalletID)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ func (h *Handler) InitiateDeposit(c *fiber.Ctx) error {
|
|||
if !ok {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
|
||||
Error: "invalid user ID",
|
||||
Message: "User ID is required to initiate a deposit",
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ func (h *Handler) InitiateDeposit(c *fiber.Ctx) error {
|
|||
fmt.Sprintln("We first first are here init Chapa payment")
|
||||
return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
|
||||
Error: err.Error(),
|
||||
Message: "Failed to parse request body",
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -45,12 +47,15 @@ func (h *Handler) InitiateDeposit(c *fiber.Ctx) error {
|
|||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
||||
Error: err.Error(),
|
||||
Message: checkoutURL,
|
||||
Message: "Failed to initiate Chapa deposit",
|
||||
})
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).JSON(domain.ChapaDepositResponse{
|
||||
CheckoutURL: checkoutURL,
|
||||
return c.Status(fiber.StatusOK).JSON(domain.Response{
|
||||
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))
|
||||
|
||||
// Recommendation Routes
|
||||
group.Get("/virtual-games/recommendations/:userID", h.GetRecommendations)
|
||||
// group.Get("/virtual-games/recommendations/:userID", h.GetRecommendations)
|
||||
|
||||
// Transactions /transactions
|
||||
a.fiber.Post("/transaction", a.authMiddleware, h.CreateTransaction)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user