Skip to main content

CamPay Python SDK

Python SDK for CamPay Payment Gateway

CamPay is a Fintech service of the company TAKWID GROUP which launched its financial services in Cameroon from January 2021.

We provide businesses and institutions with solutions for collecting and transferring money online, via primarily Mobile Money(MTN and Orange).

With CamPay, simplify the purchasing experience for your customers thanks to our mobile money payment solutions, accessible via your website and/or mobile application.

Summary

Getting Started

These instructions will get you started with the CamPay SDK for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

  • Create an account on CamPay platform
  • Register an application under your account.
  • Expand your registered application to get access to your API keys

Installing

     pip install campay

Running the samples

  • Initialize the library with credentials.
        from campay.sdk import Client as CamPayClient
    
        campay = CamPayClient({
            "app_username" : "PASTE YOUR APP_USERNAME HERE",
            "app_password" : "PASTE YOUR APP_PASSWORD HERE",
            "environment" : "DEV" #use "DEV" for demo mode or "PROD" for live mode
        })
    

To collect payments from your client - DIRECTLY

OPTION 1: This option initiates a transaction and waits( or block the running code) for the transaction to complete before returning a response.

      collect = campay.collect({
         "amount": "5", #The amount you want to collect
         "currency": "XAF",
         "from": "2376xxxxxxxx", #Phone number to request amount from. Must include country code
         "description": "some description",
         "external_reference": "", #Reference from the system initiating the transaction.
      })

      print(collect)
      #{"reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a", "external_reference":"12345678", "status": "SUCCESSFUL", "amount": 5, "currency": "XAF", "operator": "MTN", "code": "CP201027T00005", "operator_reference":  "1880106956" }
      

status can be SUCCESSFUL or FAILED

OPTION 2: This option initiates a transaction and immediately returns the initiated transaction reference for you to use to check the status of the transaction.

      collect = campay.initCollect({
         "amount": "5", #The amount you want to collect
         "currency": "XAF",
         "from": "2376xxxxxxxx", #Phone number to request amount from. Must include country code
         "description": "some description",
         "external_reference": "", #Reference from the system initiating the transaction.
      })

      print(collect)
      #{"reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a", "ussd_code": "*126# for MTN or #150*50# for ORANGE", "operator": "mtn or orange" }
      

The default status for initiated transactions is PENDING

To check a transaction status.

You need the initiated transaction reference to use this function.

      campay_status = campay.get_transaction_status({
         "reference": "bcedde9b-62a7-1234-96ac-2e6179552a1a", #The reference returned from campay.initCollect
      })

      print(campay_status)
      #{"reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a", "external_reference":"12345678", "status": "SUCCESSFUL", "amount": 5, "currency": "XAF", "operator": "MTN", "code": "CP201027T00005", "operator_reference":  "1880106956" }
      

status can be PENDING, SUCCESSFUL or FAILED

      payment_link = campay.get_payment_link({
         "amount": "5",
         "currency": "XAF",
         "description": "some description",
         "external_reference": "12345678",
         "from":"2376xxxxxxxx",
         "first_name":"John",
         "last_name":"Doe",
         "email":"",
         "redirect_url": "https://mysite.com/",
         "failure_redirect_url":"https://failed.com/",
         "payment_options":"MOMO,CARD"
      })

      print(payment_link)
      #{"status": "SUCCESSFUL", "link": "https://www.campay.com/pay/with/link/", "reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a"}
      '''
      Redirect your customer to the returned payment link. 
      You can use the "reference" to verify the status of the transaction. If check the transaction status and client has not initiated a transaction on the payment link, you will get a response telling you the transaction is not found.
      '''
      

status can be SUCCESSFUL or FAILED

To disburse

Please enable API withdrawal under app settings before trying this request

     disburse = campay.disburse({
         "amount": "5", #The amount you want to disburse
         "currency": "XAF",
         "to": "2376xxxxxxxx", #Phone number to disburse amount to. Must include country code
         "description": "some description",
         "external_reference": "", #Reference from the system initiating the transaction.
     })

     print(disburse)
     #{"reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a", "external_reference":"12345678", "status": "SUCCESSFUL", "amount": 5, "currency": "XAF", "operator": "MTN", "code": "CP201027T00005", "operator_reference":  "1880106956" }

status can be SUCCESSFUL or FAILED

To Get application balance.

     balance = campay.get_balance()

     print(balance)
     #{"total_balance": 0, "mtn_balance": 0, "orange_balance": 0, "currency": "XAF"}

Deployment

Change the environment of the library introduction to PROD

      from campay.sdk import Client
      campay = Client({
          "app_username" : "PASTE YOUR APP_USERNAME HERE",
          "app_password" : "PASTE YOUR APP_PASSWORD HERE",
          "environment" : "PROD" #use "DEV" for demo mode or "PROD" for live mode
      })

Metadata

Release files for campay 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for campay 1.1.0
File Size Uploaded
campay-1.1.0.tar.gz 19.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for campay 1.1.0
File Interpreter ABI Platform
campay-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.1 kB

Release files / campay-1.1.0.tar.gz

Download URL campay-1.1.0.tar.gz
Size 19.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2020c6d058f9519b8bd32caaa04146b81aa8c450823e680a90015fe6dd8ea0e2
BLAKE2b-256 checksum
How to use checksums
94a726aaa1c608048229c5565c13ff5fb79024a27ae9824ccbf00f575184b692
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / campay-1.1.0-py3-none-any.whl

Download URL campay-1.1.0-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9ff8b03613e92335adc4d992486c12608af7ad423339352da18bf5b42b4022c
BLAKE2b-256 checksum
How to use checksums
d1daf4e2ae33b9c3f282acfda2f23bb1a78ce028d23fa61b7aa69618b4ef5cfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page