Package: python-pesa
pypesaPython wrapper onMpesa public APIfor mobile Payment Integration made with care to offer easy and elegant integration made bykalebuImplemented FeaturesThe following are the features that are supported by theMpesapublic API and require thepythonimplementation.Customer to Bussiness (C2B) Single PaymentBussiness to Customer (B2C)Bussiness to Bussiness (B2B)Payment ReversalQuery Transaction statusDirect debit creation and PaymentDocumentationFull documentation can be found onpypesaGetting startedGetting started withpypesais pretty straight forward and can be categorizedinto steps shown below.Sign up for Mpesa Developer portalInstall thepypesapackage usingpipBuild your services withpypesaSigning upTo sign up for Mpesa public API visitMpesa-APIand thenyou can go throughgetting started Mpesa Developer portalbyalphaolomito see how.InstallationTo install thepypesapackage to your machine you can eitherinstall directly from github or use pip to install it.Using github$~gitclonehttps://github.com/Kalebu/pypesa
$~cdpypesa
$pypesa~pythonsetup.pyinstallUsing pippipinstallpython-pesaUsageTo begin using the package is pretty straight forwardYou need to have a json file namedkeys.jsonon your project directly
and then fill put in it your public and api keys in json format shown below{'api_key':'xxx','public_key':'xxxxxxxxxxxxxx'}2.Once done you're ready to go, just make sure you have active internet connectionExample of Usage (Customer to Bussiness Transaction)>>>importpypesa>>>mpesa=pypesa()>>>transaction_query={"input_Amount":"10","input_Country":"TZN","input_Currency":"TZS","input_CustomerMSISDN":"000000000001","input_ServiceProviderCode":"000000","input_ThirdPartyConversationID":'2edf7a0206d848f6b6fedea26accdc3a',"input_TransactionReference":'T23434ZE5',"input_PurchasedItemsDesc":"Python Book"}>>>mpesa.customer_to_bussiness(transaction_query)RequestprocessedsuccessfullyINS-0{'output_ResponseCode':'INS-0','output_ResponseDesc':'Request processed successfully','output_TransactionID':'uGnPxFoXT2W0','output_ConversationID':'1d1e38495dc946729a8cffb136ab8391','output_ThirdPartyConversationID':'2edf7a0206d848f6b6fedea26accdc3a'}Naming the authentication jsonIf you named your authentication json in other name thankeysyou might to
specify it while creating an instance for mpesa just as shown below;>>>importpypesa>>>mpesa=pypesa(auth_path=filename)production environmnentThe package run by default using sandbox environmnent, If you wanna use it to real production
environmnent you can specify it while creating an instance as shown below>>>importpypesa>>>mpesa=pypesa(environmnent="production")To do listAdding a well structured documentationAdding a detailed test case to the implementationFixing rising bugsContributingWanna contribute to Pypesa ? then pleasecontributing.mdto see howGive it a starIf you found this repository useful, give it a star, You can also keep in touch with ontwitter.Bug bounty?If you encounterissuewith the usage of the package, feel free raise anissueso as
we can fix it as soon as possible(ASAP) or just reach me directly through my email isaackeinstein(at)gmail.comCreditAll the credits tokalebuand all the future contributors