From 768535b5403f5317d6644dfb2cf04534f39bb22b Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Wed, 28 Aug 2024 14:54:39 +0300 Subject: [PATCH] Quit with the transaction confirmation --- internal/handlers/ussd/menuhandler.go | 21 +++++++++++++++++++ services/registration/transaction_initiated | 1 - .../registration/transaction_initiated.vis | 3 --- .../registration/transaction_initiated_swa | 1 - 4 files changed, 21 insertions(+), 5 deletions(-) delete mode 100644 services/registration/transaction_initiated delete mode 100644 services/registration/transaction_initiated_swa diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index 894d0f1..81ac382 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -706,9 +706,30 @@ func (h *Handlers) QuitWithBalance(ctx context.Context, sym string, input []byte func (h *Handlers) InitiateTransaction(ctx context.Context, sym string, input []byte) (resource.Result, error) { res := resource.Result{} + accountData, err := h.accountFileHandler.ReadAccountData() + if err != nil { + return res, err + } + // TODO // Use the amount, recipient and sender to call the API and initialize the transaction + switch codeFromCtx(ctx) { + case "swa": + res.Content = fmt.Sprintf("Ombi lako limetumwa. %s atapokea %s kutoka kwa %s.", accountData["Recipient"], accountData["Amount"], accountData["PublicKey"]) + default: + res.Content = fmt.Sprintf("Your request has been sent. %s will receive %s from %s.", accountData["Recipient"], accountData["Amount"], accountData["PublicKey"]) + } + + // reset the transaction + accountData["Recipient"] = "" + accountData["Amount"] = "" + + err = h.accountFileHandler.WriteAccountData(accountData) + if err != nil { + return res, err + } + res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED) return res, nil } diff --git a/services/registration/transaction_initiated b/services/registration/transaction_initiated deleted file mode 100644 index 2909071..0000000 --- a/services/registration/transaction_initiated +++ /dev/null @@ -1 +0,0 @@ -Your request has been sent. {{.get_recipient}} will receive {{.get_amount}} from {{.get_sender}}. \ No newline at end of file diff --git a/services/registration/transaction_initiated.vis b/services/registration/transaction_initiated.vis index c51a441..b1042f5 100644 --- a/services/registration/transaction_initiated.vis +++ b/services/registration/transaction_initiated.vis @@ -6,7 +6,4 @@ MAP get_recipient RELOAD get_sender MAP get_sender LOAD initiate_transaction 0 -RELOAD transaction_reset -MOUT quit 9 HALT -INCMP quit 9 diff --git a/services/registration/transaction_initiated_swa b/services/registration/transaction_initiated_swa deleted file mode 100644 index fb6125a..0000000 --- a/services/registration/transaction_initiated_swa +++ /dev/null @@ -1 +0,0 @@ -Ombi lako limetumwa. {{.get_recipient}} atapokea {{.get_amount}} kutoka kwa {{.get_sender}}. \ No newline at end of file