Compare commits
24 Commits
master
...
mpesa-onra
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b8c5a021b | |||
| 0da64b8565 | |||
| 04293d5476 | |||
| 15bf7dc956 | |||
| 0fd1f43602 | |||
| 8433bda6f6 | |||
| 010696e153 | |||
| a5cdd72480 | |||
| 06d6ab8692 | |||
| 45a6ef4066 | |||
| 7ae4a6fd5d | |||
| 98bc2dbac1 | |||
| a438697e25 | |||
| c610f0c9c1 | |||
| edaf527aa1 | |||
| c4026151c0 | |||
| f2a8dc3a80 | |||
| fe168f8476 | |||
| c8f081c833 | |||
| 08d0043d2c | |||
| 0d9d4c67ce | |||
| 0eec10278a | |||
| f7a2958ba2 | |||
| d16d726ce7 |
@ -29,3 +29,11 @@ DEFAULT_POOL_CONTRACT_ADDRESS=0x48a953cA5cf5298bc6f6Af3C608351f537AAcb9e
|
|||||||
DEFAULT_LIMITER_ADDRESS=
|
DEFAULT_LIMITER_ADDRESS=
|
||||||
DEFAULT_VOUCHER_REGISTRY=
|
DEFAULT_VOUCHER_REGISTRY=
|
||||||
INCLUDE_STABLES_PARAM=false
|
INCLUDE_STABLES_PARAM=false
|
||||||
|
|
||||||
|
#Mpesa address
|
||||||
|
DEFAULT_MPESA_ADDRESS=0x48a953cA5cf5298bc6f6Af3C608351f537AAcb9e
|
||||||
|
MPESA_RATE=129.5
|
||||||
|
MIN_MPESA_SEND_AMOUNT=100
|
||||||
|
MAX_MPESA_SEND_AMOUNT=250000
|
||||||
|
MPESA_SEND_RATE=130.2
|
||||||
|
DEFAULT_MPESA_ASSET=cUSD
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
apiconfig "git.grassecon.net/grassrootseconomics/sarafu-api/config"
|
apiconfig "git.grassecon.net/grassrootseconomics/sarafu-api/config"
|
||||||
@ -87,3 +88,47 @@ func DefaultPoolName() string {
|
|||||||
func DefaultPoolSymbol() string {
|
func DefaultPoolSymbol() string {
|
||||||
return env.GetEnv("DEFAULT_POOL_SYMBOL", "")
|
return env.GetEnv("DEFAULT_POOL_SYMBOL", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DefaultMpesaAddress() string {
|
||||||
|
return env.GetEnv("DEFAULT_MPESA_ADDRESS", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func MpesaRate() float64 {
|
||||||
|
v := env.GetEnv("MPESA_RATE", "129.5")
|
||||||
|
f, err := strconv.ParseFloat(v, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 129.5 // fallback default
|
||||||
|
}
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
func MinMpesaSendAmount() float64 {
|
||||||
|
v := env.GetEnv("MIN_MPESA_SEND_AMOUNT", "100")
|
||||||
|
f, err := strconv.ParseFloat(v, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 100 // fallback
|
||||||
|
}
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
func MaxMpesaSendAmount() float64 {
|
||||||
|
v := env.GetEnv("MAX_MPESA_SEND_AMOUNT", "250000")
|
||||||
|
f, err := strconv.ParseFloat(v, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 250000 // fallback
|
||||||
|
}
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
func MpesaSendRate() float64 {
|
||||||
|
v := env.GetEnv("MPESA_SEND_RATE", "130.2")
|
||||||
|
f, err := strconv.ParseFloat(v, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 130.2 // fallback default
|
||||||
|
}
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultMpesaAsset() string {
|
||||||
|
return env.GetEnv("DEFAULT_MPESA_ASSET", "")
|
||||||
|
}
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.23.4
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66
|
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66
|
||||||
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e
|
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20251127132814-8ceadabbc215
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20251028083421-fe897cca84f2
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20251028083421-fe897cca84f2
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306
|
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694
|
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694
|
||||||
|
|||||||
2
go.sum
2
go.sum
@ -2,6 +2,8 @@ git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66 h1:hmtb2Q3lHxq+S
|
|||||||
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||||
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e h1:DcC9qkNl9ny3hxQmsMK6W81+5R/j4ZwYUbvewMI/rlc=
|
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e h1:DcC9qkNl9ny3hxQmsMK6W81+5R/j4ZwYUbvewMI/rlc=
|
||||||
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||||
|
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20251127132814-8ceadabbc215 h1:cxWmd3WG3iVEqP6qG8ZeQRa7Ujno3rSKz3YXjZnmTEY=
|
||||||
|
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20251127132814-8ceadabbc215/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5 h1:VnRe01kHkZUBK/QjE7iV6gElSqSwQnAkWV3yCHtuYrI=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5 h1:VnRe01kHkZUBK/QjE7iV6gElSqSwQnAkWV3yCHtuYrI=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5/go.mod h1:H97hR+VOnZvR5BiGVb0ScCPwH/IoKBOlKM+yrQNVpq0=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5/go.mod h1:H97hR+VOnZvR5BiGVb0ScCPwH/IoKBOlKM+yrQNVpq0=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623070026-d945964b0b46 h1:0+XkSRe7XSHa9WHXKpGPuC0myDszjchr4syH006lQ28=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623070026-d945964b0b46 h1:0+XkSRe7XSHa9WHXKpGPuC0myDszjchr4syH006lQ28=
|
||||||
|
|||||||
572
handlers/application/mpesa.go
Normal file
572
handlers/application/mpesa.go
Normal file
@ -0,0 +1,572 @@
|
|||||||
|
package application
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"git.defalsify.org/vise.git/resource"
|
||||||
|
"git.grassecon.net/grassrootseconomics/common/hex"
|
||||||
|
"git.grassecon.net/grassrootseconomics/common/phone"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||||
|
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||||
|
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||||
|
"gopkg.in/leonelquinteros/gotext.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetMpesaMaxLimit returns the max FROM token
|
||||||
|
// check if max/tokenDecimals > 0.1 for UX purposes and to prevent swapping of dust values
|
||||||
|
func (h *MenuHandlers) GetMpesaMaxLimit(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
|
var res resource.Result
|
||||||
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
|
if !ok {
|
||||||
|
return res, fmt.Errorf("missing session")
|
||||||
|
}
|
||||||
|
|
||||||
|
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
flag_low_swap_amount, _ := h.flagManager.GetFlag("flag_low_swap_amount")
|
||||||
|
flag_incorrect_pool, _ := h.flagManager.GetFlag("flag_incorrect_pool")
|
||||||
|
|
||||||
|
code := codeFromCtx(ctx)
|
||||||
|
l := gotext.NewLocale(translationDir, code)
|
||||||
|
l.AddDomain("default")
|
||||||
|
|
||||||
|
inputStr := string(input)
|
||||||
|
if inputStr == "0" || inputStr == "9" {
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
userStore := h.userdataStore
|
||||||
|
|
||||||
|
// Fetch session data
|
||||||
|
_, activeBal, _, activeAddress, publicKey, activeDecimal, err := h.getSessionData(ctx, sessionId)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
rate := config.MpesaRate()
|
||||||
|
txType := "swap"
|
||||||
|
mpesaAddress := config.DefaultMpesaAddress()
|
||||||
|
|
||||||
|
// Normalize the mpesa address to fetch the phone number
|
||||||
|
publicKeyNormalized, err := hex.NormalizeHex(mpesaAddress)
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "Failed to normalize alias address", "address", mpesaAddress, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the recipient's phone number from the address
|
||||||
|
recipientPhoneNumber, err := userStore.ReadEntry(ctx, publicKeyNormalized, storedb.DATA_PUBLIC_KEY_REVERSE)
|
||||||
|
if err != nil || len(recipientPhoneNumber) == 0 {
|
||||||
|
logg.WarnCtxf(ctx, "Alias address not registered, switching to normal transaction", "address", mpesaAddress)
|
||||||
|
recipientPhoneNumber = nil
|
||||||
|
}
|
||||||
|
// store it for future reference (TODO)
|
||||||
|
if err := userStore.WriteEntry(ctx, sessionId, storedb.DATA_RECIPIENT_PHONE_NUMBER, recipientPhoneNumber); err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "Failed to write recipient phone number", "value", string(recipientPhoneNumber), "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetch data for verification
|
||||||
|
recipientActiveSym, recipientActiveAddress, recipientActiveDecimal, err := h.getRecipientData(ctx, string(recipientPhoneNumber))
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If RAT is the same as SAT, return early with KSH format
|
||||||
|
if string(activeAddress) == string(recipientActiveAddress) {
|
||||||
|
txType = "normal"
|
||||||
|
// Save the transaction type
|
||||||
|
if err := userStore.WriteEntry(ctx, sessionId, storedb.DATA_SEND_TRANSACTION_TYPE, []byte(txType)); err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "Failed to write transaction type", "type", txType, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
activeFloat, _ := strconv.ParseFloat(string(activeBal), 64)
|
||||||
|
ksh := fmt.Sprintf("%f", activeFloat*rate)
|
||||||
|
|
||||||
|
kshFormatted, _ := store.TruncateDecimalString(ksh, 0)
|
||||||
|
|
||||||
|
res.Content = l.Get(
|
||||||
|
"Enter the amount of Mpesa to get: (Max %s Ksh)\n",
|
||||||
|
kshFormatted,
|
||||||
|
)
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve active pool address
|
||||||
|
activePoolAddress, err := h.resolveActivePoolAddress(ctx, sessionId)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if sender token is swappable
|
||||||
|
canSwap, err := h.accountService.CheckTokenInPool(ctx, string(activePoolAddress), string(activeAddress))
|
||||||
|
if err != nil {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||||
|
logg.ErrorCtxf(ctx, "failed on CheckTokenInPool", "error", err)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if !canSwap.CanSwapFrom { // pool issue (TODO on vis)
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_incorrect_pool)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// retrieve the max credit send amounts
|
||||||
|
_, maxRAT, err := h.calculateSendCreditLimits(ctx, activePoolAddress, activeAddress, recipientActiveAddress, publicKey, activeDecimal, recipientActiveDecimal)
|
||||||
|
if err != nil {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||||
|
logg.ErrorCtxf(ctx, "failed on calculateSendCreditLimits", "error", err)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback if below minimum
|
||||||
|
maxFloat, _ := strconv.ParseFloat(maxRAT, 64)
|
||||||
|
if maxFloat < 0.1 {
|
||||||
|
formatted, _ := store.TruncateDecimalString(maxRAT, 2)
|
||||||
|
res.Content = formatted
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_low_swap_amount)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save max RAT amount to be used in validating the user's input
|
||||||
|
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_SWAP_MAX_AMOUNT, []byte(maxRAT))
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to write swap max amount (maxRAT)", "value", maxRAT, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the transaction type
|
||||||
|
if err := userStore.WriteEntry(ctx, sessionId, storedb.DATA_SEND_TRANSACTION_TYPE, []byte(txType)); err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "Failed to write transaction type", "type", txType, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// save swap related data for the swap preview
|
||||||
|
metadata := &dataserviceapi.TokenHoldings{
|
||||||
|
TokenAddress: string(recipientActiveAddress),
|
||||||
|
TokenSymbol: string(recipientActiveSym),
|
||||||
|
TokenDecimals: string(recipientActiveDecimal),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the active swap_to data
|
||||||
|
if err := store.UpdateSwapToVoucherData(ctx, userStore, sessionId, metadata); err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed on UpdateSwapToVoucherData", "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
maxKsh := maxFloat * rate
|
||||||
|
kshStr := fmt.Sprintf("%f", maxKsh)
|
||||||
|
kshFormatted, _ := store.TruncateDecimalString(kshStr, 0)
|
||||||
|
|
||||||
|
res.Content = l.Get(
|
||||||
|
"Enter the amount of Mpesa to get: (Max %s Ksh)\n",
|
||||||
|
kshFormatted,
|
||||||
|
)
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMpesaPreview displays the get mpesa preview and estimates
|
||||||
|
func (h *MenuHandlers) GetMpesaPreview(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
|
var res resource.Result
|
||||||
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
|
if !ok {
|
||||||
|
return res, fmt.Errorf("missing session")
|
||||||
|
}
|
||||||
|
|
||||||
|
// INPUT IN RAT Ksh
|
||||||
|
inputStr := string(input)
|
||||||
|
if inputStr == "9" {
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
flag_invalid_amount, _ := h.flagManager.GetFlag("flag_invalid_amount")
|
||||||
|
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
|
||||||
|
code := codeFromCtx(ctx)
|
||||||
|
l := gotext.NewLocale(translationDir, code)
|
||||||
|
l.AddDomain("default")
|
||||||
|
|
||||||
|
userStore := h.userdataStore
|
||||||
|
rate := config.MpesaRate()
|
||||||
|
|
||||||
|
// Input in Ksh
|
||||||
|
kshAmount, err := strconv.ParseFloat(inputStr, 64)
|
||||||
|
if err != nil {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
||||||
|
res.Content = inputStr
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// divide by the rate
|
||||||
|
inputAmount := kshAmount / rate
|
||||||
|
|
||||||
|
// store the user's raw input amount in the temporary value
|
||||||
|
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(inputStr))
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to write temporary inputStr entry with", "key", storedb.DATA_TEMPORARY_VALUE, "value", inputStr, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
swapData, err := store.ReadSwapPreviewData(ctx, userStore, sessionId)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionType, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_SEND_TRANSACTION_TYPE)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if string(transactionType) == "normal" {
|
||||||
|
activeBal, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_BAL)
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to read activeBal entry with", "key", storedb.DATA_ACTIVE_BAL, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
balanceValue, err := strconv.ParseFloat(string(activeBal), 64)
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "Failed to convert the activeBal to a float", "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if inputAmount > balanceValue {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
||||||
|
res.Content = inputStr
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format the input amount to 2 decimal places
|
||||||
|
inputAmountStr := fmt.Sprintf("%f", inputAmount)
|
||||||
|
qouteInputAmount, _ := store.TruncateDecimalString(inputAmountStr, 2)
|
||||||
|
|
||||||
|
// store the inputAmountStr as the final amount (that will be sent)
|
||||||
|
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte(inputAmountStr))
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to write send amount value entry with", "key", storedb.DATA_AMOUNT, "value", inputAmountStr, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
res.Content = l.Get(
|
||||||
|
"You are sending %s %s in order to receive %s ksh",
|
||||||
|
qouteInputAmount, swapData.ActiveSwapFromSym, inputStr,
|
||||||
|
)
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// use the stored max RAT
|
||||||
|
maxRATValue, err := strconv.ParseFloat(swapData.ActiveSwapMaxAmount, 64)
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "Failed to convert the swapMaxAmount to a float", "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if inputAmount > maxRATValue {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
||||||
|
res.Content = inputStr
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
formattedAmount := fmt.Sprintf("%f", inputAmount)
|
||||||
|
|
||||||
|
finalAmountStr, err := store.ParseAndScaleAmount(formattedAmount, swapData.ActiveSwapToDecimal)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// call the credit send API to get the reverse quote
|
||||||
|
r, err := h.accountService.GetCreditSendReverseQuote(ctx, swapData.ActivePoolAddress, swapData.ActiveSwapFromAddress, swapData.ActiveSwapToAddress, finalAmountStr)
|
||||||
|
if err != nil {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||||
|
res.Content = l.Get("Your request failed. Please try again later.")
|
||||||
|
logg.ErrorCtxf(ctx, "failed GetCreditSendReverseQuote poolSwap", "error", err)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
sendInputAmount := r.InputAmount // amount of SAT
|
||||||
|
sendOutputAmount := r.OutputAmount // amount of RAT
|
||||||
|
|
||||||
|
// store the sendOutputAmount as the final amount (that will be sent)
|
||||||
|
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte(sendOutputAmount))
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to write output amount value entry with", "key", storedb.DATA_AMOUNT, "value", sendOutputAmount, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// store the sendInputAmount as the swap amount
|
||||||
|
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_SWAP_AMOUNT, []byte(sendInputAmount))
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to write swap amount entry with", "key", storedb.DATA_ACTIVE_SWAP_AMOUNT, "value", sendInputAmount, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// covert for display
|
||||||
|
quoteInputStr := store.ScaleDownBalance(sendInputAmount, swapData.ActiveSwapFromDecimal)
|
||||||
|
// Format the quoteInputStr amount to 2 decimal places
|
||||||
|
qouteInputAmount, _ := store.TruncateDecimalString(quoteInputStr, 2)
|
||||||
|
|
||||||
|
res.Content = l.Get(
|
||||||
|
"You are sending %s %s in order to receive %s ksh",
|
||||||
|
qouteInputAmount, swapData.ActiveSwapFromSym, inputStr,
|
||||||
|
)
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitiateGetMpesa calls the poolSwap, followed by the transfer and returns a confirmation based on the result.
|
||||||
|
func (h *MenuHandlers) InitiateGetMpesa(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
|
var res resource.Result
|
||||||
|
var err error
|
||||||
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
|
if !ok {
|
||||||
|
return res, fmt.Errorf("missing session")
|
||||||
|
}
|
||||||
|
|
||||||
|
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
|
||||||
|
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
|
||||||
|
code := codeFromCtx(ctx)
|
||||||
|
l := gotext.NewLocale(translationDir, code)
|
||||||
|
l.AddDomain("default")
|
||||||
|
|
||||||
|
userStore := h.userdataStore
|
||||||
|
|
||||||
|
mpesaAddress := config.DefaultMpesaAddress()
|
||||||
|
|
||||||
|
swapData, err := store.ReadSwapPreviewData(ctx, userStore, sessionId)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionType, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_SEND_TRANSACTION_TYPE)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if string(transactionType) == "normal" {
|
||||||
|
// Call TokenTransfer for the normal transaction
|
||||||
|
data, err := store.ReadTransactionData(ctx, h.userdataStore, sessionId)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
finalAmountStr, err := store.ParseAndScaleAmount(data.Amount, data.ActiveDecimal)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenTransfer, err := h.accountService.TokenTransfer(ctx, finalAmountStr, data.PublicKey, mpesaAddress, data.ActiveAddress)
|
||||||
|
if err != nil {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||||
|
res.Content = l.Get("Your request failed. Please try again later.")
|
||||||
|
logg.ErrorCtxf(ctx, "failed on TokenTransfer", "error", err)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
logg.InfoCtxf(ctx, "TokenTransfer normal", "trackingId", tokenTransfer.TrackingId)
|
||||||
|
|
||||||
|
res.Content = l.Get("Your request has been sent. You will receive %s ksh", data.TemporaryValue)
|
||||||
|
|
||||||
|
res.FlagReset = append(res.FlagReset, flag_account_authorized)
|
||||||
|
return res, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
swapAmount, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_SWAP_AMOUNT)
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to read swapAmount entry with", "key", storedb.DATA_ACTIVE_SWAP_AMOUNT, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
swapAmountStr := string(swapAmount)
|
||||||
|
|
||||||
|
// Call the poolSwap API
|
||||||
|
poolSwap, err := h.accountService.PoolSwap(ctx, swapAmountStr, swapData.PublicKey, swapData.ActiveSwapFromAddress, swapData.ActivePoolAddress, swapData.ActiveSwapToAddress)
|
||||||
|
if err != nil {
|
||||||
|
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||||
|
res.Content = l.Get("Your request failed. Please try again later.")
|
||||||
|
logg.ErrorCtxf(ctx, "failed on poolSwap", "error", err)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
logg.InfoCtxf(ctx, "poolSwap", "swapTrackingId", poolSwap.TrackingId)
|
||||||
|
|
||||||
|
finalKshStr, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
amount, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_AMOUNT)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initiate a send to mpesa after the swap
|
||||||
|
tokenTransfer, err := h.accountService.TokenTransfer(ctx, string(amount), swapData.PublicKey, mpesaAddress, swapData.ActiveSwapToAddress)
|
||||||
|
if err != nil {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||||
|
res.Content = l.Get("Your request failed. Please try again later.")
|
||||||
|
logg.ErrorCtxf(ctx, "failed on TokenTransfer after swap", "error", err)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
logg.InfoCtxf(ctx, "final TokenTransfer after swap", "trackingId", tokenTransfer.TrackingId)
|
||||||
|
|
||||||
|
res.Content = l.Get("Your request has been sent. You will receive %s ksh", finalKshStr)
|
||||||
|
res.FlagReset = append(res.FlagReset, flag_account_authorized)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMpesaMinLimit returns the min amount from the config
|
||||||
|
func (h *MenuHandlers) SendMpesaMinLimit(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
|
var res resource.Result
|
||||||
|
|
||||||
|
code := codeFromCtx(ctx)
|
||||||
|
l := gotext.NewLocale(translationDir, code)
|
||||||
|
l.AddDomain("default")
|
||||||
|
|
||||||
|
inputStr := string(input)
|
||||||
|
if inputStr == "0" || inputStr == "9" {
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch min amount from config/env
|
||||||
|
min := config.MinMpesaSendAmount()
|
||||||
|
|
||||||
|
// Convert to string
|
||||||
|
ksh := fmt.Sprintf("%f", min)
|
||||||
|
|
||||||
|
// Format (e.g., 100.0 -> 100)
|
||||||
|
kshFormatted, _ := store.TruncateDecimalString(ksh, 0)
|
||||||
|
|
||||||
|
res.Content = l.Get(
|
||||||
|
"Enter the amount of Mpesa to send: (Minimum %s Ksh)\n",
|
||||||
|
kshFormatted,
|
||||||
|
)
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMpesaPreview displays the send mpesa preview and estimates
|
||||||
|
func (h *MenuHandlers) SendMpesaPreview(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
|
var res resource.Result
|
||||||
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
|
if !ok {
|
||||||
|
return res, fmt.Errorf("missing session")
|
||||||
|
}
|
||||||
|
|
||||||
|
// INPUT IN Ksh
|
||||||
|
inputStr := string(input)
|
||||||
|
if inputStr == "0" || inputStr == "9" {
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
flag_invalid_amount, _ := h.flagManager.GetFlag("flag_invalid_amount")
|
||||||
|
|
||||||
|
code := codeFromCtx(ctx)
|
||||||
|
l := gotext.NewLocale(translationDir, code)
|
||||||
|
l.AddDomain("default")
|
||||||
|
|
||||||
|
userStore := h.userdataStore
|
||||||
|
sendRate := config.MpesaSendRate()
|
||||||
|
|
||||||
|
// Input in Ksh
|
||||||
|
kshAmount, err := strconv.ParseFloat(inputStr, 64)
|
||||||
|
if err != nil {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
||||||
|
res.Content = inputStr
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
min := config.MinMpesaSendAmount()
|
||||||
|
max := config.MaxMpesaSendAmount()
|
||||||
|
|
||||||
|
if kshAmount > max || kshAmount < min {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
||||||
|
res.Content = inputStr
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
res.FlagReset = append(res.FlagReset, flag_invalid_amount)
|
||||||
|
|
||||||
|
// store the user's raw input amount
|
||||||
|
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte(inputStr))
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to write amount inputStr entry with", "key", storedb.DATA_AMOUNT, "value", inputStr, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
estimateValue := kshAmount / sendRate
|
||||||
|
estimateStr := fmt.Sprintf("%f", estimateValue)
|
||||||
|
estimateFormatted, _ := store.TruncateDecimalString(estimateStr, 0)
|
||||||
|
|
||||||
|
res.Content = l.Get(
|
||||||
|
"You will get a prompt for your M-Pesa PIN shortly to send %s ksh and receive %s cUSD",
|
||||||
|
inputStr, estimateFormatted,
|
||||||
|
)
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitiateSendMpesa calls the trigger-onram API to initiate the purchase
|
||||||
|
func (h *MenuHandlers) InitiateSendMpesa(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
|
var res resource.Result
|
||||||
|
var err error
|
||||||
|
sessionId, ok := ctx.Value("SessionId").(string)
|
||||||
|
if !ok {
|
||||||
|
return res, fmt.Errorf("missing session")
|
||||||
|
}
|
||||||
|
|
||||||
|
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
|
||||||
|
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
|
||||||
|
code := codeFromCtx(ctx)
|
||||||
|
l := gotext.NewLocale(translationDir, code)
|
||||||
|
l.AddDomain("default")
|
||||||
|
|
||||||
|
userStore := h.userdataStore
|
||||||
|
|
||||||
|
publicKey, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to read publicKey entry", "key", storedb.DATA_PUBLIC_KEY, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
phoneNumber, err := phone.FormatToLocalPhoneNumber(sessionId)
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed on FormatToLocalPhoneNumber", "session-id", sessionId, "error", err)
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||||
|
res.Content = l.Get("Your request failed. Please try again later.")
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultAsset := config.DefaultMpesaAsset()
|
||||||
|
|
||||||
|
amount, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_AMOUNT)
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to read amount entry", "key", storedb.DATA_AMOUNT, "error", err)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the trigger onramp API
|
||||||
|
triggerOnramp, err := h.accountService.MpesaTriggerOnramp(ctx, string(publicKey), phoneNumber, defaultAsset, string(amount))
|
||||||
|
if err != nil {
|
||||||
|
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
||||||
|
res.Content = l.Get("Your request failed. Please try again later.")
|
||||||
|
logg.ErrorCtxf(ctx, "failed on MpesaTriggerOnramp", "error", err)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
logg.InfoCtxf(ctx, "MpesaTriggerOnramp", "transactionCode", triggerOnramp.TransactionCode)
|
||||||
|
|
||||||
|
res.Content = l.Get("Your request has been sent. Thank you for using Sarafu")
|
||||||
|
res.FlagReset = append(res.FlagReset, flag_account_authorized)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
@ -140,6 +140,12 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
|
|||||||
ls.DbRs.AddLocalFunc("transaction_swap_preview", appHandlers.TransactionSwapPreview)
|
ls.DbRs.AddLocalFunc("transaction_swap_preview", appHandlers.TransactionSwapPreview)
|
||||||
ls.DbRs.AddLocalFunc("transaction_initiate_swap", appHandlers.TransactionInitiateSwap)
|
ls.DbRs.AddLocalFunc("transaction_initiate_swap", appHandlers.TransactionInitiateSwap)
|
||||||
ls.DbRs.AddLocalFunc("clear_trans_type_flag", appHandlers.ClearTransactionTypeFlag)
|
ls.DbRs.AddLocalFunc("clear_trans_type_flag", appHandlers.ClearTransactionTypeFlag)
|
||||||
|
ls.DbRs.AddLocalFunc("get_mpesa_max_limit", appHandlers.GetMpesaMaxLimit)
|
||||||
|
ls.DbRs.AddLocalFunc("get_mpesa_preview", appHandlers.GetMpesaPreview)
|
||||||
|
ls.DbRs.AddLocalFunc("initiate_get_mpesa", appHandlers.InitiateGetMpesa)
|
||||||
|
ls.DbRs.AddLocalFunc("send_mpesa_min_limit", appHandlers.SendMpesaMinLimit)
|
||||||
|
ls.DbRs.AddLocalFunc("send_mpesa_preview", appHandlers.SendMpesaPreview)
|
||||||
|
ls.DbRs.AddLocalFunc("initiate_send_mpesa", appHandlers.InitiateSendMpesa)
|
||||||
|
|
||||||
ls.first = appHandlers.Init
|
ls.first = appHandlers.Init
|
||||||
|
|
||||||
|
|||||||
1
services/registration/get_mpesa
Normal file
1
services/registration/get_mpesa
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{.get_mpesa_max_limit}}
|
||||||
9
services/registration/get_mpesa.vis
Normal file
9
services/registration/get_mpesa.vis
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
LOAD get_mpesa_max_limit 0
|
||||||
|
RELOAD get_mpesa_max_limit
|
||||||
|
MAP get_mpesa_max_limit
|
||||||
|
MOUT back 0
|
||||||
|
MOUT quit 9
|
||||||
|
HALT
|
||||||
|
INCMP _ 0
|
||||||
|
INCMP quit 9
|
||||||
|
INCMP get_mpesa_confirmation *
|
||||||
3
services/registration/get_mpesa_confirmation
Normal file
3
services/registration/get_mpesa_confirmation
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{.get_mpesa_preview}}
|
||||||
|
|
||||||
|
Please enter your PIN to confirm. You will get an SMS shortly:
|
||||||
13
services/registration/get_mpesa_confirmation.vis
Normal file
13
services/registration/get_mpesa_confirmation.vis
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
LOAD get_mpesa_preview 0
|
||||||
|
MAP get_mpesa_preview
|
||||||
|
CATCH api_failure flag_api_call_error 1
|
||||||
|
CATCH invalid_credit_send_amount flag_invalid_amount 1
|
||||||
|
MOUT back 0
|
||||||
|
MOUT quit 9
|
||||||
|
HALT
|
||||||
|
LOAD authorize_account 6
|
||||||
|
RELOAD authorize_account
|
||||||
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
|
INCMP _ 0
|
||||||
|
INCMP quit 9
|
||||||
|
INCMP initiate_get_mpesa *
|
||||||
3
services/registration/get_mpesa_confirmation_swa
Normal file
3
services/registration/get_mpesa_confirmation_swa
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{.get_mpesa_preview}}
|
||||||
|
|
||||||
|
Tafadhali weka PIN yako kudhibitisha. Utapokea ujumbe wa SMS:
|
||||||
1
services/registration/get_mpesa_menu
Normal file
1
services/registration/get_mpesa_menu
Normal file
@ -0,0 +1 @@
|
|||||||
|
Get M-Pesa
|
||||||
1
services/registration/get_mpesa_menu_swa
Normal file
1
services/registration/get_mpesa_menu_swa
Normal file
@ -0,0 +1 @@
|
|||||||
|
Pokea M-Pesa
|
||||||
4
services/registration/initiate_get_mpesa.vis
Normal file
4
services/registration/initiate_get_mpesa.vis
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
LOAD reset_incorrect_pin 6
|
||||||
|
CATCH _ flag_account_authorized 0
|
||||||
|
LOAD initiate_get_mpesa 0
|
||||||
|
HALT
|
||||||
4
services/registration/initiate_send_mpesa.vis
Normal file
4
services/registration/initiate_send_mpesa.vis
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
LOAD reset_incorrect_pin 6
|
||||||
|
CATCH _ flag_account_authorized 0
|
||||||
|
LOAD initiate_send_mpesa 0
|
||||||
|
HALT
|
||||||
1
services/registration/invalid_send_mpesa_amount
Normal file
1
services/registration/invalid_send_mpesa_amount
Normal file
@ -0,0 +1 @@
|
|||||||
|
Amount {{.send_mpesa_preview}} is invalid, please try again:
|
||||||
6
services/registration/invalid_send_mpesa_amount.vis
Normal file
6
services/registration/invalid_send_mpesa_amount.vis
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
MAP send_mpesa_preview
|
||||||
|
MOUT retry 1
|
||||||
|
MOUT quit 9
|
||||||
|
HALT
|
||||||
|
INCMP ^ 1
|
||||||
|
INCMP quit 9
|
||||||
1
services/registration/invalid_send_mpesa_amount_swa
Normal file
1
services/registration/invalid_send_mpesa_amount_swa
Normal file
@ -0,0 +1 @@
|
|||||||
|
Kiwango {{.send_mpesa_preview}} sio sahihi, tafadhali weka tena:
|
||||||
@ -54,3 +54,21 @@ msgstr "Kiwango kinachopatikana: %s %s\n(Unaweza kubadilisha hadi %s %s -> %s %s
|
|||||||
|
|
||||||
msgid "%s will receive %s %s"
|
msgid "%s will receive %s %s"
|
||||||
msgstr "%s atapokea %s %s"
|
msgstr "%s atapokea %s %s"
|
||||||
|
|
||||||
|
msgid "Enter the amount of M-Pesa to get: (Max %s Ksh)\n"
|
||||||
|
msgstr "Weka kiasi cha M-Pesa cha kupata: (Kikomo %s Ksh)\n"
|
||||||
|
|
||||||
|
msgid "You are sending %s %s in order to receive %s ksh"
|
||||||
|
msgstr "Unatuma %s %s ili upoke %s ksh"
|
||||||
|
|
||||||
|
msgid "Your request has been sent. You will receive %s ksh"
|
||||||
|
msgstr "Ombi lako limetumwa. Utapokea %s ksh"
|
||||||
|
|
||||||
|
msgid "Enter the amount of M-Pesa to send: (Minimum %s Ksh)\n"
|
||||||
|
msgstr "Weka kiasi cha M-Pesa cha kutuma: (Kima cha chini %s Ksh)\n"
|
||||||
|
|
||||||
|
msgid "You will get a prompt for your M-Pesa PIN shortly to send %s ksh and receive %s cUSD"
|
||||||
|
msgstr "Utapokea kidokezo cha PIN yako ya M-Pesa hivi karibuni kutuma %s ksh na kupokea %s cUSD"
|
||||||
|
|
||||||
|
msgid "Your request has been sent. Thank you for using Sarafu"
|
||||||
|
msgstr "Ombi lako limetumwa. Asante kwa kutumia huduma ya Sarafu"
|
||||||
@ -11,8 +11,9 @@ MOUT credit_send 2
|
|||||||
MOUT swap 3
|
MOUT swap 3
|
||||||
MOUT vouchers 4
|
MOUT vouchers 4
|
||||||
MOUT select_pool 5
|
MOUT select_pool 5
|
||||||
MOUT account 6
|
MOUT mpesa 6
|
||||||
MOUT help 7
|
MOUT account 7
|
||||||
|
MOUT help 8
|
||||||
MOUT quit 9
|
MOUT quit 9
|
||||||
HALT
|
HALT
|
||||||
INCMP send 1
|
INCMP send 1
|
||||||
@ -20,7 +21,8 @@ INCMP credit_send 2
|
|||||||
INCMP swap_to_list 3
|
INCMP swap_to_list 3
|
||||||
INCMP my_vouchers 4
|
INCMP my_vouchers 4
|
||||||
INCMP select_pool 5
|
INCMP select_pool 5
|
||||||
INCMP my_account 6
|
INCMP mpesa 6
|
||||||
INCMP help 7
|
INCMP my_account 7
|
||||||
|
INCMP help 8
|
||||||
INCMP quit 9
|
INCMP quit 9
|
||||||
INCMP . *
|
INCMP . *
|
||||||
|
|||||||
1
services/registration/mpesa
Normal file
1
services/registration/mpesa
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{.check_balance}}
|
||||||
9
services/registration/mpesa.vis
Normal file
9
services/registration/mpesa.vis
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MAP check_balance
|
||||||
|
MOUT get_mpesa 1
|
||||||
|
MOUT send_mpesa 2
|
||||||
|
MOUT quit 9
|
||||||
|
HALT
|
||||||
|
INCMP get_mpesa 1
|
||||||
|
INCMP send_mpesa 2
|
||||||
|
INCMP quit 9
|
||||||
|
INCMP . *
|
||||||
1
services/registration/mpesa_menu
Normal file
1
services/registration/mpesa_menu
Normal file
@ -0,0 +1 @@
|
|||||||
|
M-Pesa
|
||||||
@ -31,7 +31,7 @@ flag,flag_back_set,37,this is set when it is a back navigation
|
|||||||
flag,flag_account_blocked,38,this is set when an account has been blocked after the allowed incorrect PIN attempts have been exceeded
|
flag,flag_account_blocked,38,this is set when an account has been blocked after the allowed incorrect PIN attempts have been exceeded
|
||||||
flag,flag_invalid_pin,39,this is set when the given PIN is invalid(is less than or more than 4 digits)
|
flag,flag_invalid_pin,39,this is set when the given PIN is invalid(is less than or more than 4 digits)
|
||||||
flag,flag_alias_set,40,this is set when an account alias has been assigned to a user
|
flag,flag_alias_set,40,this is set when an account alias has been assigned to a user
|
||||||
flag,flag_account_pin_reset,41,this is set on an account when an admin triggers a PIN reset for themflag,flag_incorrect_pool,39,this is set when the user selects an invalid pool
|
flag,flag_account_pin_reset,41,this is set on an account when an admin triggers a PIN reset for them
|
||||||
flag,flag_incorrect_pool,42,this is set when the user selects an invalid pool
|
flag,flag_incorrect_pool,42,this is set when the user selects an invalid pool
|
||||||
flag,flag_low_swap_amount,43,this is set when the swap max limit is less than 0.1
|
flag,flag_low_swap_amount,43,this is set when the swap max limit is less than 0.1
|
||||||
flag,flag_alias_unavailable,44,this is set when the preferred alias is not available
|
flag,flag_alias_unavailable,44,this is set when the preferred alias is not available
|
||||||
|
|||||||
|
Can't render this file because it has a wrong number of fields in line 34.
|
1
services/registration/send_mpesa
Normal file
1
services/registration/send_mpesa
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{.send_mpesa_min_limit}}
|
||||||
9
services/registration/send_mpesa.vis
Normal file
9
services/registration/send_mpesa.vis
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
LOAD send_mpesa_min_limit 0
|
||||||
|
RELOAD send_mpesa_min_limit
|
||||||
|
MAP send_mpesa_min_limit
|
||||||
|
MOUT back 0
|
||||||
|
MOUT quit 9
|
||||||
|
HALT
|
||||||
|
INCMP _ 0
|
||||||
|
INCMP quit 9
|
||||||
|
INCMP send_mpesa_confirmation *
|
||||||
3
services/registration/send_mpesa_confirmation
Normal file
3
services/registration/send_mpesa_confirmation
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{.send_mpesa_preview}}
|
||||||
|
|
||||||
|
Please enter your account PIN to confirm:
|
||||||
12
services/registration/send_mpesa_confirmation.vis
Normal file
12
services/registration/send_mpesa_confirmation.vis
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
LOAD send_mpesa_preview 0
|
||||||
|
MAP send_mpesa_preview
|
||||||
|
CATCH invalid_send_mpesa_amount flag_invalid_amount 1
|
||||||
|
MOUT back 0
|
||||||
|
MOUT quit 9
|
||||||
|
HALT
|
||||||
|
LOAD authorize_account 6
|
||||||
|
RELOAD authorize_account
|
||||||
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
|
INCMP _ 0
|
||||||
|
INCMP quit 9
|
||||||
|
INCMP initiate_send_mpesa *
|
||||||
3
services/registration/send_mpesa_confirmation_swa
Normal file
3
services/registration/send_mpesa_confirmation_swa
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{.send_mpesa_preview}}
|
||||||
|
|
||||||
|
Tafadhali weka PIN ya akaunti yako kudhibitisha:
|
||||||
1
services/registration/send_mpesa_menu
Normal file
1
services/registration/send_mpesa_menu
Normal file
@ -0,0 +1 @@
|
|||||||
|
Send M-Pesa
|
||||||
Loading…
Reference in New Issue
Block a user