Skip to content

Repository files navigation

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
fromcredo.banks_and_currenciesimportBanksCurrenciesbanks_and_currs=BanksCurrencies(public_key='your-public-key', secret_key='your-secret-key')
# gets list of all banksstatus, 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
fromcredo.customersimportCustomerscustomers=Customers(public_key='your-public-key', secret_key='your-secret-key')
# Adds a customerstatus, 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 integrationstatus, customer=customers.fetch_all()
# fetches the customer with the id passedstatus, customer=customers.fetch(141)
# fetches all transactions for a customer whose ID is passedstatus, customer=customers.fetch_transactions(141)
# blacklists the customer whose id is passedstatus, customer=customers.blacklist(141)

Direct Charge

methods

  • charge_card
  • verify_card
  • three_ds_charge
fromcredo.direct_chargeimportDirectChargedirect_charge=DirectCharge(public_key='your-public-key', secret_key='your-secret-key')
# Charge a card without 3DS verificationstatus, 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
fromcredo.paymentimportPaymentpayment=Payment(public_key='your-public-key', secret_key='your-secret-key')
# to initiate a paymentstatus, 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 paymentstatus, 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
fromcredo.payment_linkimportPaymentLink_link=PaymentLink(public_key='your-public-key', secret_key='your-secret-key')
# create a payment linkpayment_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 slugstatus, link=_link.get_by_slug(link_slug='credo-random-2')
# get a payment lik by passing the idstatus, link=_link.get_by_id(link_id=63)
#get transactions made through payment linksstatus, transactions=_link.get_link_transactions()

Transactions

methods

  • all
  • get_one
  • refund
fromcredo.transactionsimportTransactionstransactions=Transactions(public_key='your-public-key', secret_key='your-secret-key')
# To get a list of all your transactionsstatus, all_transactions=transactions.all()
# To get a transaction by it's idstatus, transaction=transactions.get_one(transaction_id=5)
# refund a transaction by its idstatus, refund=transactions.refund(transaction_id=5)

Subaccounts

methods

  • subaccounts
  • create_subaccount
  • get_subaccount
  • update_subaccount
fromcredo.subaccountsimportSubAccount_subaccounts=SubAccount(public_key='your-public-key', secret_key='your-secret-key')
# get all subaccounts in your integrationstatus, subaccounts=_subaccounts.subaccounts()
# get one subaccount by passing its idstatus, subaccount=_subaccounts.get_subaccount(subaccount_id=59)
# create a new subaccountstatus, 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

About

A python sdk for interacting with the Credo API

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages