package domain import ( "errors" "time" ) var ( ErrInsufficientBalance = errors.New("insufficient balance") ErrInvalidWithdrawalAmount = errors.New("invalid withdrawal amount") ErrWithdrawalNotFound = errors.New("withdrawal not found") ErrPaymentNotFound = errors.New("payment not found") ErrPaymentAlreadyExists = errors.New("payment with this reference already exists") ErrInvalidPaymentAmount = errors.New("invalid payment amount") ) type PaymentStatus string type WithdrawalStatus string const ( WithdrawalStatusSuccessful WithdrawalStatus = "success" WithdrawalStatusPending WithdrawalStatus = "pending" WithdrawalStatusProcessing WithdrawalStatus = "processing" WithdrawalStatusCompleted WithdrawalStatus = "completed" WithdrawalStatusFailed WithdrawalStatus = "failed" ) const ( PaymentStatusSuccessful PaymentStatus = "success" PaymentStatusPending PaymentStatus = "pending" PaymentStatusCompleted PaymentStatus = "completed" PaymentStatusFailed PaymentStatus = "failed" ) type ChapaDepositRequest struct { Amount Currency `json:"amount"` Currency string `json:"currency"` Email string `json:"email"` FirstName string `json:"first_name"` LastName string `json:"last_name"` TxRef string `json:"tx_ref"` CallbackURL string `json:"callback_url"` ReturnURL string `json:"return_url"` } type ChapaDepositRequestPayload struct { Amount float64 `json:"amount" validate:"required,gt=0"` } type ChapaWebhookPayload struct { TxRef string `json:"tx_ref"` Amount Currency `json:"amount"` Currency string `json:"currency"` Status PaymentStatus `json:"status"` } // PaymentResponse contains the response from payment initialization type ChapaDepositResponse struct { CheckoutURL string Reference string } // PaymentVerification contains payment verification details type ChapaDepositVerification struct { Status PaymentStatus Amount Currency Currency string } type ChapaVerificationResponse struct { Status string `json:"status"` Amount float64 `json:"amount"` Currency string `json:"currency"` TxRef string `json:"tx_ref"` } // type Bank struct { // ID int `json:"id"` // Slug string `json:"slug"` // Swift string `json:"swift"` // Name string `json:"name"` // AcctLength int `json:"acct_length"` // CountryID int `json:"country_id"` // IsMobileMoney int `json:"is_mobilemoney"` // nullable // IsActive int `json:"is_active"` // IsRTGS int `json:"is_rtgs"` // Active int `json:"active"` // Is24Hrs int `json:"is_24hrs"` // nullable // CreatedAt time.Time `json:"created_at"` // UpdatedAt time.Time `json:"updated_at"` // Currency string `json:"currency"` // BankLogo string `json:"bank_logo"` // URL or base64 // } type BankResponse struct { Message string `json:"message"` Status string `json:"status"` Data []BankData `json:"data"` } type BankData struct { ID int `json:"id"` Slug string `json:"slug"` Swift string `json:"swift"` Name string `json:"name"` AcctLength int `json:"acct_length"` CountryID int `json:"country_id"` IsMobileMoney int `json:"is_mobilemoney"` // nullable IsActive int `json:"is_active"` IsRTGS int `json:"is_rtgs"` Active int `json:"active"` Is24Hrs int `json:"is_24hrs"` // nullable CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Currency string `json:"currency"` } type ChapaWithdrawal struct { ID string UserID int64 Amount Currency AccountNumber string BankCode string Status WithdrawalStatus Reference string CreatedAt time.Time UpdatedAt time.Time } type ChapaWithdrawalRequest struct { AccountName string `json:"account_name"` AccountNumber string `json:"account_number"` Amount string `json:"amount"` // string because Chapa API uses string for monetary values Currency string `json:"currency"` Reference string `json:"reference"` BankCode int `json:"bank_code"` } // type ChapaWithdrawalRequest struct { // AccountName string `json:"account_name"` // AccountNumber string `json:"account_number"` // Amount Currency `json:"amount"` // Currency string `json:"currency"` // BeneficiaryName string `json:"beneficiary_name"` // BankCode string `json:"bank_code"` // PhoneNumber string `json:"phone_number"` // } type ChapaWithdrawalResponse struct { Message string `json:"message"` Status string `json:"status"` Data string `json:"data"` // Accepts string instead of struct } type ChapaTransactionType struct { Type string `json:"type"` } type ChapaWebHookTransfer struct { AccountName string `json:"account_name"` AccountNumber string `json:"account_number"` BankId string `json:"bank_id"` BankName string `json:"bank_name"` Currency string `json:"currency"` Amount string `json:"amount"` Type string `json:"type"` Status string `json:"status"` Reference string `json:"reference"` TxRef string `json:"tx_ref"` ChapaReference string `json:"chapa_reference"` CreatedAt time.Time `json:"created_at"` } type ChapaWebHookPayment struct { Event string `json:"event"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Email string `json:"email"` Mobile interface{} `json:"mobile"` Currency string `json:"currency"` Amount string `json:"amount"` Charge string `json:"charge"` Status string `json:"status"` Mode string `json:"mode"` Reference string `json:"reference"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Type string `json:"type"` TxRef string `json:"tx_ref"` PaymentMethod string `json:"payment_method"` Customization struct { Title interface{} `json:"title"` Description interface{} `json:"description"` Logo interface{} `json:"logo"` } `json:"customization"` Meta string `json:"meta"` }