\abdulmueid\mpesa\helpersValidationHelper

Class ValidationHelper

Summary

Methods
Properties
Constants
normalizeMSISDN()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

normalizeMSISDN()

normalizeMSISDN(string  $msisdn) : string

Validates and normalizes the MSISDN to 25884|5xxxxxxx as accepted by the M-Pesa API.

– Restricts MSISDN to only Vodacom Prefixes (84, 85). – Accepts MSISDN in the following formats:

  • (84|85)xxxxxxx
  • 258(84|85)xxxxxxx
  • +258(84|85)xxxxxxx
  • 00258(84|85)xxxxxxx

Parameters

string $msisdn

msisdn which will be validated and normalized afterwards.

Throws

\Exception

Returns

string —

normalized phone number: 258(84|85)xxxxxxx