Python Xendit Client API
Xendit REST API Client for Python
Documentation
Install
Install xenditclient with pip by the following command:
pip install xenditclient
Usage
Configure the XenditClient with the secret key that you can obtained on your Xendit Dashboard Account.
from xenditclient import XenditClient
client = XenditClient(api_key='<your-secret-key>')
Get Balance
res_dict = client.balance.get_balance('CASH')
print(res_dict)
# {
# 'balance': 1000137690
# }
EWallets
Create Payment
params = {
'ewallet_type':'OVO',
'external_id':'21345',
'amount':10000,
'phone':'081234567890'
}
res_dict = client.ewallet.create(params)
print(res_dict)
# {
# "business_id": "12345678",
# "external_id": "21345",
# "amount": "10000",
# "phone": "081234567890",
# "ewallet_type": "OVO",
# "status": "PENDING",
# "created": "2020-04-04T00:00:00.000Z",
# }
Get Payment Status
res_dict = client.ewallet.get_payment_status(external_id='21345', payment_method='OVO')
print(res_dict)
# {
# "amount": "10000",
# "business_id": "12345678",
# "ewallet_type": "OVO",
# "external_id": "21345",
# "status": "COMPLETED",
# "transaction_date": "2020-04-04T11:48:47.903Z"
# }
QR Codes (QRIS)
Get QRCode client
qrcode = client.qrcodes
# or
from xenditclient.qrcodes import QRCodesClient
qrcode = QRCodesClient(client)
Create QRCode for payment
data = qrcode.create("DYNAMIC", "DS-INV-01", "https://dwisulfahnur.com/api/xendit/callback", 10200)
print(data)
# {
# "id": "qr_a706814a-d18b-4109-9b71-7a76f9855e123",
# "external_id": "DS-INV-01",
# "amount": 10200,
# "qr_string": "00022312321226660014ID.LINKAJA.WWW0118912312300241148000215200423041141230303UME51450015ID.OR.GPNQR.WWW0215000111111111110303UME520454995802ID5920Placeholder merchant6007Jakarta6106123456623801152QiFZi5qT12307152QiFZi5qThdA4M753033605405102006304D9CM",
# "callback_url": "https://dwisulfahnur.com/api/xendit/callback",
# "type": "DYNAMIC",
# "status": "ACTIVE",
# "created": "2020-07-27T07:44:31.420Z",
# "updated": "2020-07-27T07:44:31.420Z"
# }
Get QRCode detail payment
data = qrcode.get_payment_detail("DS-INV-01")
print(data)
# {
# "id": "qr_a706814a-d18b-4109-9b71-7a76f9855e123",
# "external_id": "DS-INV-01",
# "amount": 10200,
# "qr_string": "00022312321226660014ID.LINKAJA.WWW0118912312300241148000215200423041141230303UME51450015ID.OR.GPNQR.WWW0215000111111111110303UME520454995802ID5920Placeholder merchant6007Jakarta6106123456623801152QiFZi5qT12307152QiFZi5qThdA4M753033605405102006304D9CM",
# "callback_url": "https://dwisulfahnur.com/api/xendit/callback",
# "type": "DYNAMIC",
# "status": "ACTIVE",
# "created": "2020-07-27T07:44:31.420Z",
# "updated": "2020-07-27T07:44:31.420Z"
# }
Virtual Account
Get Virtual Account Client
va_client = client.virtual_account
# or
from xenditclient.virtual_accounts import VirtualAccountClient
qrcode = VirtualAccountClient(client)
Get Virtual Account Banks
data = va_client.get_va_banks()
print(data)
# [
# {'name': 'Bank Mandiri', 'code': 'MANDIRI'},
# {'name': 'Bank Negara Indonesia', 'code': 'BNI'},
# {'name': 'Bank Rakyat Indonesia', 'code': 'BRI'},
# {'name': 'Bank Permata', 'code': 'PERMATA'},
# {'name': 'Bank Central Asia', 'code': 'BCA'}
# ]
Create Virtual Account Payment
from xenditclient import virtual_accounts
data = va_client.create(
external_id="DS-INV-01",
bank_code=virtual_accounts.BNI,
name="Dwi Sulfahnur",
)
"""
You can add the following additional options
for the Virtual Account as arguments:
- virtual_account_number: str // Optional
- suggested_amount: int // Optional
- is_closed: bool // Optional
- expected_amount: int // Optional
- expiration_date: UTC datetime // Optional
- is_single_use: bool // Optional
- description: str // Optional
"""
print(data)
# {
# "is_closed": true,
# "status": "PENDING",
# "currency": "IDR",
# "owner_id": "5efab44e31890e1415bb70e9",
# "external_id": "ZICARE-01",
# "bank_code": "MANDIRI",
# "merchant_code": "88908",
# "name": "Dwi Sulfahnur",
# "account_number": "889089999000001",
# "suggested_amount": 15500,
# "expected_amount": 15500,
# "is_single_use": true,
# "expiration_date": "2051-07-27T17:00:00.000Z",
# "id": "5f1fd5470af2e8475877ba21"
# }
Get Virtual Account Payment Detail
data = va_client.get_payment_detail("5f1fd5470af2e8475877ba21")
print(data)
# {
# "is_closed": true,
# "status": "PENDING",
# "currency": "IDR",
# "owner_id": "5efab44e31890e1415bb70e9",
# "external_id": "ZICARE-01",
# "bank_code": "MANDIRI",
# "merchant_code": "88908",
# "name": "Dwi Sulfahnur",
# "account_number": "889089999000001",
# "suggested_amount": 15500,
# "expected_amount": 15500,
# "is_single_use": true,
# "expiration_date": "2051-07-27T17:00:00.000Z",
# "id": "5f1fd5470af2e8475877ba21"
# }
Update Virtual Account Payment Detail
from datetime import datetime
data = va_client.update_payment_detail(
payment_id="5f1fd5470af2e8475877ba21",
suggested_amount=20000,
expected_amount=20000,
expiration_date=datetime(2020, 12, 31, 00, 00, 00).isoformat(),
is_single_use=True,
description="Subscription Payment",
)
print(data)
# {
# "is_closed": true,
# "status": "PENDING",
# "currency": "IDR",
# "owner_id": "5efab44e31890e1415bb70e9",
# "external_id": "ZICARE-01",
# "bank_code": "MANDIRI",
# "merchant_code": "88908",
# "name": "Dwi Sulfahnur",
# "account_number": "889089999000001",
# "suggested_amount": 20000,
# "expected_amount": 20000,
# "is_single_use": true,
# "expiration_date": "2020-12-31T17:00:00.000Z",
# "id": "5f1fd5470af2e8475877ba21",
# "description": "Subscription Payment",
# }
Legal
Disclaimer: This library is not affliated with Xendit. This is an independent and unofficial Library.
Metadata
Release files for xenditclient 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xenditclient-0.0.5.tar.gz | 9.8 kB | Without provenance | Details for xenditclient-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xenditclient-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for xenditclient-0.0.5-py3-none-any.whl |
Total release size: 22.2 kB
Release files / xenditclient-0.0.5.tar.gz
| Download URL | xenditclient-0.0.5.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd058520d7b00378db6d6587c497e4da70cbc146509c577bb79e21c708060355
|
|
BLAKE2b-256 checksum How to use checksums |
a04192714f61202ef64dab3cbbe06590f0ce8b5cbeddaf6bda74e81571008436
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5
|
Release files / xenditclient-0.0.5-py3-none-any.whl
| Download URL | xenditclient-0.0.5-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
02852364fcbfc02be42ba3e11acde4722de28958db469c13de3670c7c8c555da
|
|
BLAKE2b-256 checksum How to use checksums |
280d201d764b84860fcb5b11cdc87b86466d7fdbe556ca9595c58f55246d8c6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5
|
Security for xenditclient 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.