Skip to main content

Payment Gateway

Project description

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

To collect payments from your client - using PAYMENT LINKS

      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
      })

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

campay-1.1.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

campay-1.1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file campay-1.1.0.tar.gz.

File metadata

  • Download URL: campay-1.1.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for campay-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2020c6d058f9519b8bd32caaa04146b81aa8c450823e680a90015fe6dd8ea0e2
MD5 79538af0b652603566a8bdc594c24f84
BLAKE2b-256 94a726aaa1c608048229c5565c13ff5fb79024a27ae9824ccbf00f575184b692

See more details on using hashes here.

File details

Details for the file campay-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: campay-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for campay-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9ff8b03613e92335adc4d992486c12608af7ad423339352da18bf5b42b4022c
MD5 4bc3e8076d718b2568e9250e4886aa1a
BLAKE2b-256 d1daf4e2ae33b9c3f282acfda2f23bb1a78ce028d23fa61b7aa69618b4ef5cfe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page