Skip to main content

A Python Wrapper for the Credo API

Project description

credo-python

A python sdk for interacting with the Credo API


Installation

To Install run

pip install credo-python

Usage


Banks and Currencies

methods

  • get_banks
  • get_currencies
from credo.banks_and_currencies import BanksCurrencies
banks_and_currs = BanksCurrencies(public_key='your-public-key', secret_key='your-secret-key')
# gets list of all banks
status, banks = banks_and_currs.get_banks()
# print(banks)
# [
#     {
#         "id": 1,
#         "code": "044",
#         "countryUuid": "nig45FDD-Jtr7-ygy7Df",
#         "name": "Access Bank"
#     },
#     {
#         "id": 18,
#         "code": "032",
#         "countryUuid": "nig45FDD-Jtr7-ygy7Df",
#         "name": "Union Bank of Nigeria"
#     }
# ]
status, currencies = banks_and_currs.get_currencies()
# print(currencies)
# [
#   {'id': 1, 'code': 'USD', 'isDefault': 0, 'name': 'United States Dollars', 'symbol': '$'}, {'id': 2, 'code': 'NGN', 'isDefault': 1, 'name': 'Nigerian Naira', 'symbol': '?'})

Customers

methods

  • add
  • update
  • fetch
  • fetch_all
  • blacklist
  • fetch_transactions
from credo.customers import Customers
customers  = Customers(public_key='your-public-key', secret_key='your-secret-key')
# Adds a customer
status, customer = customers.add(full_name='Random Name', email='rando.nam@gmail.com',
                                             phone_number='23480123456789',
                                             billing_address1='random ', billing_address2='random', district='random',
                                             state='random',facebook_username=None,
                                             instagram_username=None,
                                             twitter_username=None)
# fetches all customers in your integration
status, customer = customers.fetch_all()

# fetches the customer with the id passed
status, customer = customers.fetch(141)

# fetches all transactions for a customer whose ID is passed
status, customer = customers.fetch_transactions(141)

# blacklists the customer whose id is passed
status, customer = customers.blacklist(141)

Direct Charge

methods

  • charge_card
  • verify_card
  • three_ds_charge
from credo.direct_charge import DirectCharge

direct_charge = DirectCharge(public_key='your-public-key', secret_key='your-secret-key')

# Charge a card without 3DS verification
status, charge_card = direct_charge.charge_card(amount=2000, currency='NGN', card_number='5204730000001003',
                                                        expiry_month="12", expiry_year="25", security_code="123",
                                                        trans_ref="iy67f64hvc61", customer_email='random@mil.com',
                                                        customer_phone="23480123456789", customer_name='Random',
                                                        payment_slug="0H0UOEsawNjkIxgsporr")

Standard Payment

methods

  • initiate_payment
  • verify_payment
from credo.payment import Payment

payment = Payment(public_key='your-public-key', secret_key='your-secret-key')

# to initiate a payment
status, new_payment = payment.initiate_payment(amount=3000, currency='NGN', customer_name='Random',
                                                         customer_email='random@gmail.com',
                                                         customer_phone='23480123456789',
                                                         trans_ref='iy67f64hvc62', payment_options='CARD,BANK',
                                                         redirect_url='https://github.com/BdVade/credo-python')
# to verify a payment

status, verify_payment = payment.verify_payment(transaction_reference='iy67f64hvc62')

Payment Link

methods

  • create_payment_link
  • get_payment_link_by_id
  • update_payment_link
  • get_payment_link_by_slug
  • post_payment_link_transaction
  • get_payment_link_transactions
  • get_payment_link_transaction_by_id
  • get_customers
from credo.payment_link import PaymentLink

_link = PaymentLink(public_key='your-public-key', secret_key='your-secret-key')

# create a payment link
payment_link = _link.create_payment_link(name="Random", description="Random stuff", type_id=1,
                                         redirect_url='https://github.com/BdVade/credo-python',
                                         amount=3000, success_message="Thank you",
                                         phone_number='23480123456789', currencies="NGN",
                                         custom_fields=['Favourite food', 'Age'])

# get a payment link by passing the payment slug
status, link = _link.get_by_slug(link_slug='credo-random-2')

# get a payment lik by passing the id
status, link = _link.get_by_id(link_id=63)

#get transactions made through payment links
status, transactions = _link.get_link_transactions()

Transactions

methods

  • all
  • get_one
  • refund
from credo.transactions import Transactions


transactions = Transactions(public_key='your-public-key', secret_key='your-secret-key')

# To get a list of all your transactions
status, all_transactions = transactions.all()

# To get a transaction by it's id
status, transaction = transactions.get_one(transaction_id=5)

# refund a transaction by its id

status, refund = transactions.refund(transaction_id=5)

Subaccounts

methods

  • subaccounts
  • create_subaccount
  • get_subaccount
  • update_subaccount
from credo.subaccounts import SubAccount

_subaccounts = SubAccount(public_key='your-public-key', secret_key='your-secret-key')

# get all subaccounts in your integration
status, subaccounts = _subaccounts.subaccounts()

# get one subaccount by passing its id

status, subaccount = _subaccounts.get_subaccount(subaccount_id=59)

# create a new subaccount

status, subaccount = _subaccounts.create_subaccount(account_name='Funds', account_number='0129322920',
                                                             personal_account_name='Funds Money', verified=True,
                                                             split_percentage=20, bank_id=6, currency_id=2)

# update a sub account 

status, subaccount = _subaccounts.update_subaccount(account_name='Fund', account_number='0129322920',
                                                             personal_account_name='Funds Money', verified=True,
                                                             split_percentage=20, bank_id=6, currency_id=2,
                                                             subaccount_id=59)

For more Information visit the Credo API documentation

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

credo-python-1.0.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

credo_python-1.0.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file credo-python-1.0.1.tar.gz.

File metadata

  • Download URL: credo-python-1.0.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.9

File hashes

Hashes for credo-python-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f9f75f4c067491c582cbd8e4cbf39b3148aabf71094472e499e1afebb98ac5a6
MD5 b16aef31861798959f9ed5ef9bd97756
BLAKE2b-256 9a539d6f3770505c466f9036b1b6dc94bfe938fb42ba987bb47e4901cfbd9dec

See more details on using hashes here.

File details

Details for the file credo_python-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: credo_python-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.9

File hashes

Hashes for credo_python-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 841d96f9a48e866acc8593d442124b42e921cf6586c746e35e67cd19fc18afbf
MD5 f097eaf1d71f2fdbf0a1b079ebb0fd39
BLAKE2b-256 136dc9253473f04ea4c42ed0ed9ef29fe9f434a430f6e450682bbee9051b138c

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