From f34c6451cc55c1a89b768b287c5a4fc9277d0020 Mon Sep 17 00:00:00 2001 From: Calleb Joel Miquissene Date: Fri, 25 Dec 2020 04:16:01 +0200 Subject: [PATCH] Fix "MSISDN invalid" error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the values of the arguments `from` and `to` (that must be a Vodacom phone number) are in `841234567` format as described in the documentation, you receive an `MSISDN invalid` error. The values ​​of these properties must start with the country code `258` so that the error mentioned above does not occur. --- src/main/java/org/paymentsds/mpesa/Request.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/paymentsds/mpesa/Request.java b/src/main/java/org/paymentsds/mpesa/Request.java index eab5ff2..12344f1 100644 --- a/src/main/java/org/paymentsds/mpesa/Request.java +++ b/src/main/java/org/paymentsds/mpesa/Request.java @@ -72,7 +72,11 @@ public Builder amount(double amount) { } public Builder from(String from) { - this.from = from; + if (from.length() == 9) { + this.from = 258 + from; + } else { + this.from = from; + } return this; } @@ -87,7 +91,11 @@ public Builder transaction(String transaction) { } public Builder to(String to) { - this.to = to; + if (to.length() == 9) { + this.to = 258 + to; + } else { + this.to = to; + } return this; }