{"id":22576614,"url":"https://github.com/ndolestudio/mtnmomo-go","last_synced_at":"2025-04-10T17:13:45.771Z","repository":{"id":57640499,"uuid":"432656219","full_name":"NdoleStudio/mtnmomo-go","owner":"NdoleStudio","description":"MTN Mobile Money API Client in Go","archived":false,"fork":false,"pushed_at":"2025-01-29T21:23:04.000Z","size":82,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T15:01:35.557Z","etag":null,"topics":["api-client","mtn","mtnmobilemoney","mtnmomo"],"latest_commit_sha":null,"homepage":"https://momodeveloper.mtn.com/api-documentation","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NdoleStudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-28T08:17:22.000Z","updated_at":"2025-01-29T21:23:08.000Z","dependencies_parsed_at":"2023-12-29T17:41:05.536Z","dependency_job_id":"f82ae366-8f78-44f1-845b-efb6511514ac","html_url":"https://github.com/NdoleStudio/mtnmomo-go","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":"NdoleStudio/go-http-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Fmtnmomo-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Fmtnmomo-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Fmtnmomo-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Fmtnmomo-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NdoleStudio","download_url":"https://codeload.github.com/NdoleStudio/mtnmomo-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261913,"owners_count":21074225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","mtn","mtnmobilemoney","mtnmomo"],"created_at":"2024-12-08T04:07:22.073Z","updated_at":"2025-04-10T17:13:45.749Z","avatar_url":"https://github.com/NdoleStudio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mtnmomo-go\n\n[![Build](https://github.com/NdoleStudio/mtnmomo-go/actions/workflows/main.yml/badge.svg)](https://github.com/NdoleStudio/mtnmomo-go/actions/workflows/main.yml)\n[![codecov](https://codecov.io/gh/NdoleStudio/mtnmomo-go/branch/main/graph/badge.svg)](https://codecov.io/gh/NdoleStudio/mtnmomo-go)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/NdoleStudio/mtnmomo-go/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/NdoleStudio/mtnmomo-go/?branch=main)\n[![Go Report Card](https://goreportcard.com/badge/github.com/NdoleStudio/mtnmomo-go)](https://goreportcard.com/report/github.com/NdoleStudio/mtnmomo-go)\n[![GitHub contributors](https://img.shields.io/github/contributors/NdoleStudio/mtnmomo-go)](https://github.com/NdoleStudio/mtnmomo-go/graphs/contributors)\n[![GitHub license](https://img.shields.io/github/license/NdoleStudio/mtnmomo-go?color=brightgreen)](https://github.com/NdoleStudio/mtnmomo-go/blob/master/LICENSE)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/NdoleStudio/mtnmomo-go)](https://pkg.go.dev/github.com/NdoleStudio/mtnmomo-go)\n\n\nThis package provides a generic `go` client template for the MTN Mobile Money API\n\n## Installation\n\n`mtnmomo-go` is compatible with modern Go releases in module mode, with Go installed:\n\n```bash\ngo get github.com/NdoleStudio/mtnmomo-go\n```\n\nAlternatively the same can be achieved if you use `import` in a package:\n\n```go\nimport \"github.com/NdoleStudio/mtnmomo-go\"\n```\n\n\n## Implemented\n\n- [API User](#api-user)\n  - `POST {baseURL}/apiuser`: Create API User\n  - `POST {baseURL}/apiuser/{APIUser}/apikey`: Create API Key\n  - `GET {baseURL}/apiuser/{APIUser}`: Get API user information\n- [Collection](#collection)\n  - `POST {baseURL}/collection/token/`: Create access token\n  - `POST {baseURL}/collection/v1_0/requesttopay`: Request a payment from a consumer\n  - `GET {baseURL}/collection/v1_0/requesttopay/{referenceId}`: Get the status of a request to pay\n  - `GET {baseURL}/collection/v1_0/account/balance`: Get the balance of the account\n- **Disbursements**\n  - `POST {baseURL}/disbursement/token/`: Create access token\n  - `POST {baseURL}/disbursement/v1_0/transfer`: Transfer money to a customer's account.\n  - `GET {baseURL}/disbursement/v1_0/transfer/{referenceId}`: Get the status of a transfer.\n  - `GET {baseURL}/disbursement/v1_0/account/balance`: Get the balance of the disbursement account\n\n## Usage\n\n### Initializing the Client\n\nAn instance of the client can be created using `New()`.\n\n```go\npackage main\n\nimport (\n    \"github.com/NdoleStudio/mtnmomo-go\"\n)\n\nfunc main()  {\n    client := mtnmomo.New(\n        mtnmomo.WithBaseURL(\"https://sandbox.momodeveloper.mtn.com/v1_0\"),\n        mtnmomo.WithSubscriptionKey(\"\"/* Subscription key */),\n    )\n}\n```\n\n### Error handling\n\nAll API calls return an `error` as the last return object. All successful calls will return a `nil` error.\n\n```go\napiUser, response, err := statusClient.APIUser.CreateAPIUser(context.Background())\nif err != nil {\n    //handle error\n}\n```\n\n### API User\n\n#### `POST {baseURL}/apiuser`: Create API User\n\nUsed to create an API user in the sandbox target environment.\n\n```go\nuserID, response, err := client.APIUser.CreateAPIUser(\n\tcontext.Background(),\n\tuuid.NewString(),\n\t\"providerCallbackHost\",\n)\n\nif err != nil {\n    log.Fatal(err)\n}\n\nlog.Println(response.HTTPResponse.StatusCode) // 201\n```\n\n#### `POST {baseURL}/apiuser/{APIUser}/apikey`: Create API Key\n\nUsed to create an API key for an API user in the sandbox target environment.\n\n```go\napiKey, response, err := client.APIUser.CreateAPIKey(context.Background(), \"userID\")\n\nif err != nil {\n    log.Fatal(err)\n}\n\nlog.Println(apiKey) // e.g \"f1db798c98df4bcf83b538175893bbf0\"\n```\n\n#### `GET {baseURL}/apiuser/{APIUser}`: Get API user information\n\nUsed to get API user information.\n\n```go\napiUser, response, err := client.APIUser.CreateAPIKey(context.Background(), \"userID\")\n\nif err != nil {\n    log.Fatal(err)\n}\n\nlog.Println(apiUser.TargetEnvironment) // e.g \"sandbox\"\n```\n\n### Collection\n\n#### `POST {baseURL}/collection/token/`: Create access token\n\nThis operation is used to create an access token which can then be used to authorize and authenticate towards the other end-points of the API.\n\n```go\nauthToken, response, err := client.Collection.Token(context.Background())\nif err != nil {\n\tlog.Fatal(err)\n}\n\nlog.Println(authToken.AccessToken) // e.g eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9....\n```\n\n#### `POST {baseURL}/collection/v1_0/requesttopay`: Request a payment from a consumer\n\nThis operation is used to request a payment from a consumer (Payer). The payer will be asked to authorize the payment. The transaction will be executed once the payer has authorized the payment.\n\n```go\ncallbackURL := \"http://callback-url.com\"\nresponse, err := client.Collection.RequestToPay(\n\tcontext.Background(),\n\treferenceID,\n\t\u0026mtnmomo.RequestToPayParams{\n\t\tAmount:     \"10\",\n\t\tCurrency:   \"EUR\",\n\t\tExternalID: uuid.NewString(),\n\t\tPayer: \u0026mtnmomo.RequestToPayPayer{\n\t\t\tPartyIDType: \"MSISDN\",\n\t\t\tPartyID:     \"673978334\",\n\t\t},\n\t\tPayerMessage: \"Test Payer Message\",\n\t\tPayeeNote:    \"Test Payee Note\",\n\t},\n\t\u0026callbackURL,\n)\n\nif err != nil {\n    log.Fatal(err)\n}\n\nlog.Println(response.HTTPResponse.StatusCode) // e.g 201 (Accepted)\n```\n\n#### `GET {baseURL}/collection/v1_0/requesttopay/{referenceId}`: Get the status of a request to pay\n\nThis operation is used to get the status of a request to pay. X-Reference-Id that was passed in the post is used as reference to the request.\n\n```go\nstatus, _, err := client.Collection.GetRequestToPayStatus(context.Background(), referenceID)\nif err != nil {\n\tlog.Fatal(err)\n}\n\nlog.Println(status.Status) // SUCCESSFUL\n```\n\n#### `GET {baseURL}/collection/v1_0/account/balance`: Get the balance of the account\n\n```go\nbalance, _, err := client.Collection.GetAccountBalance(context.Background())\nif err != nil {\n    log.Fatal(err)\n}\nlog.Println(balance.AvailableBalance) // \"1000\"\n```\n\n## Testing\n\nYou can run the unit tests for this client from the root directory using the command below:\n\n```bash\ngo test -v\n```\n\n### Security\n\nIf you discover any security related issues, please email arnoldewin@gmail.com instead of using the GitHub issues.\n\n## Credits\n\n- [Acho Arnold](https://github.com/achoarnold)\n- [All Contributors](../../contributors)\n- [Go HTTP Client Template](https://github.com/NdoleStudio/go-http-client)\n\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndolestudio%2Fmtnmomo-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndolestudio%2Fmtnmomo-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndolestudio%2Fmtnmomo-go/lists"}