New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zignpay

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zignpay

A package to manage mobile payments using the MTN MoMo and Orange Money APIs

  • 0.1.0
  • Source
  • PyPI
  • Socket score

Maintainers
1

ZIGNPAY

[![build-status-image]][build-status] [![coverage-status-image]][codecov] [![pypi-version]][pypi]

Make mobile payment easy

Overview

A package to manage mobile payments using the MTN MoMo and Orange Money APIs

Some reasons you might want to use REST framework:

  • Add a payment method to your website or application
  • Create a mobile payment app
  • Customization and extensibility
  • Support for multiple operators

Steps summary

  • Sign up for an account
  • Get a product subscription key
  • Installation
  • Create an API user and API key
  • Initialize the collection class
  • Make a payment request

Getting Started

Sign up for an account

Head over to https://momodeveloper.mtn.com/ and create your account. Once created, verify your account and sign in to the developer dashboard.

Get a product subscription key

The momo developer API is segmented into different products. Like; Collections, Remittances, Disbursement, and a collections widget. Find and Subscribe to the product that your application will be using. For the case of this tutorial, we shall subscribe to the collections product. It enables us to make a remote collection of fees and bills. Once subscribed, you shall be able to get a primary subscription key and a secondary subscription key in your developer dashboard.

Installation

Requirements

  • Python 3.10+
  pip install zignpay

Create an API user

  import os
  from zignpay.momo import MomoApiProvisioning, MomoCollection


  """
    Here we will subscribe to the product collection.
  """  
  subscription_key = os.environ('subscription_key') # Put the subscription key that you copied

  """
    Keep in mind that your subscription key in development is different in production,
    To go into production you must click on Go Live in your Dashboard
  """

The MOMO API relies heavily on unique identifying identifiers called UUIDs. Each API user you create will have a unique UUID, zignpay will generate this automatically for you.

  ...
  momo = MomoApiProvisioning({
    "subscription_key" : subscription_key, 
    "environment" : "DEV" # Define DEV if you are in development and PROD if you are in production
  })

  api_user = momo.create_api_user() # This returns the unique reference (UUID) of the created API user

  if api_user: #Check if the query returns an object
    api_key = momo.create_api_key() # Then generate the API key
    """
      You can save these two values ​​in a secure database, they will be necessary later.
    """

Initialize the collection class

  ...
  collection = MomoCollection({
    "api_user_id" : api_user, # The user reference created above
    "api_key" : api_key, # The api key created above
    "subscription_key" : subscription_key, # The subscription key for the collection product
    "environment" : "DEV",
    "country_code" : "CM", # our Country Codes Alpha-2
  })

You will find your Country codes here.

Make a payment request

  ...
  requestToPay = collection.request_to_pay({
    "amount": 15, # Payment request amount
    "from": "2376xxxxxxxx", # Example of Cameroonian number
    "reference_id": "123456789", 
    "description": "Requested to pay" # Put your own description
  })

Example query result

  {
    'financialTransactionId': '490639485', 
    'externalId': '123456789', 
    'amount': '15', 
    'currency': 'EUR', 
    'payer': {
      'partyIdType': 'MSISDN', 
      'partyId': '2376xxxxxxxx'
      }, 
    'payerMessage': 'Requested to pay', 
    'payeeNote': 'Thank you for your payment', 
    'status': 'SUCCESSFUL'
  }

We are currently working on improving this documentation

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc