Skip to content

IntaSend/intasend-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IntaSend Payment Gateway - Python SDK

Codacy Badge

Official documentation

Python SDK for IntaSend Payment Gateway. IntaSend enables you to easily add payments to your application with a few lines of code.

Follow the instruction below to install and get started.

Visit our sandbox/developers test for your API Keys.

Checkout our API documentation for more details and for payload references.

How to install

pip install intasend-python

Authenticating service

from intasend import APIService

token = "YOUR-API-TOKEN"
publishable_key = "YOUR-PUBLISHABLE-KEY"
service = APIService(token="token",publishable_key=publishable_key)

Examples

# Remember to switch of test when going live by removing the flag or set it to False

service = APIService(token="token",publishable_key=publishable_key, test=True)

# Collect payments
## Generate checkout URL
response = service.collect.checkout(phone_number=2547...,
                                    email="felix@intasend.com", amount=10, currency="KES", comment="Fees")
print(response)

## Get payment status using invoice/tracking id
response = service.collect.status(invoice_id="NR5XKGY")
print(response)

## Trigger M-Pesa STK Push
response = service.collect.mpesa_stk_push(phone_number=2547...,
                                  email="customer@example.com", amount=10, narrative="Fees")
print(response)

# Wallets Management
response = service.wallets.retrieve()
print(response)

response = service.wallets.details(<WALLET-ID>)
print(response)

response = service.wallets.transactions(<WALLET-ID>)
print(response)

response = service.wallets.create(currency="KES", label="API-WALLET", can_disburse=True)
print(response)

# Fund specific wallet
response = service.wallets.fund(
     wallet_id=<WALLET-ID>, phone_number=25472.., email="customer@example.com", amount=10, narrative="Fees", name="Awesome Customer")
print(response)

# Wallet to wallet transfers
response = service.wallets.intra_transfer(<WALLET-ID-1>, <WALLET-ID-2>, 1, "Charge capture")
print(response)

# Retrieve Chargebacks
response = service.chargebacks.retrieve(<CHARGEBACK-ID>)
print(response)

# Send money
transactions = [{'name': 'Awesome Customer 1', 'account': 25472.., 'amount': 10},
                {'name': 'Awesome Customer 2', 'account': 25472.., 'amount': 10000}]
                
response = service.transfer.mpesa(currency='KES', transactions=transactions)
print(response)

status = service.transfer.status(response.get("tracking_id"))
print(f"Status: {status}")

# Buy AIRTIME
transactions = [{'name': 'Joe Doe' ,'account': '25472...'}]
response = service.transfer.airtime(currency='KES', transactions=transactions)
print(response)

About

The official Python SDK for IntaSend Payment Gateway

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages