Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "MSISDN invalid" error #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/main/java/org/paymentsds/mpesa/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ public Builder amount(double amount) {
}

public Builder from(String from) {
this.from = from;
if (from.length() == 9) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the string's length sounds a bit hacky. Maybe we should check if the string starts with "258" instead?

this.from = 258 + from;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this field is a String, let's use a String literal here

Suggested change
this.from = 258 + from;
this.from = "258" + from;

} else {
this.from = from;
}
return this;
}

Expand All @@ -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 {
Comment on lines +94 to +96
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 2 comments I left above also apply here.

this.to = to;
}
return this;
}

Expand Down