This library is the abstraction of Xfers API for access from applications written with Python.
Please check Xfers API Reference.
Python 3.7 or later
To use the package, run pip install xfers-sdk
from landx_xfers_sdk import Xfers
xfers = Xfers(api_key="test-key123", secret_key="12345678")
# Then access each class from x attribute
balance = xfers.Balance
balance.get()
balance = xfers.Balance
balance.get()
Usage example:
from landx_xfers_sdk import Xfers
xfers = Xfers(api_key="test-key123", secret_key="12345678", production=False)
# Then access each class from x attribute
balance = xfers.Balance
print(balance.get())
Reference: https://docs.xfers.com/reference/account-balance
bank = xfers.Bank
bank.account_validation(account_no="123456", bank_short_code="BNI")
Reference: https://docs.xfers.com/reference/bank-account-validation
bank = xfers.Bank
bank.list()
Reference: https://docs.xfers.com/reference/list-disbursement-banks
There are 2 main ways to accept payments with Xfers.
- One time payment
Use
xfers.Payment
instance - Persistent payment method linked to one of your customers
Use
xfers.PaymentMethod
instance
Reference: https://docs.xfers.com/docs/accepting-payments
payment = xfers.Payment
payment.create(
type="virtual_bank_account",
amount=10000,
expired_at=datetime.now() + timedelta(days=1), # One Day
reference_id="va_12345678",
bank_short_code="SAHABAT_SAMPOERNA",
display_name="Your preferred name",
description="Payment Description"
# suffix_no="12345678"
)
API Reference: https://docs.xfers.com/reference/create-payment
payment_method = xfers.PaymentMethod
payment_method.create(
type="virtual_bank_accounts",
reference_id="12345678",
bank_short_code="SAHABAT_SAMPOERNA",
display_name="Your preferred name",
# suffix_no="12345678"
)
API Reference: https://docs.xfers.com/reference/create-payment-method
payment = xfers.Payment
payment.create(
type="qris",
amount=10000,
expired_at=datetime.now() + timedelta(days=1), # One Day
reference_id="qris_12345678",
display_name="Your preferred name",
description="Payment Description"
)
API Reference: https://docs.xfers.com/reference/create-payment
payment_method = xfers.PaymentMethod
payment_method.create(
type="qris",
reference_id="12345678",
display_name="Your preferred name"
)
API Reference: https://docs.xfers.com/reference/create-payment-method
payment = xfers.Payment
payment.create(
type="retail_outlet",
amount=10000,
expired_at=datetime.now() + timedelta(days=1), # One Day
reference_id="qris_12345678",
retail_outlet_name="ALFAMART",
display_name="Your preferred name",
description="Payment Description"
)
Available Outlets: https://docs.xfers.com/docs/retail-store#available-outlets
API Reference: https://docs.xfers.com/reference/create-payment
payment = xfers.Payment
payment.create(
type="e-wallet",
amount=10000,
expired_at=datetime.now() + timedelta(days=1), # One Day
reference_id="qris_12345678",
provider_code="SHOPEEPAY",
after_settlement_return_url="https://pay.examplessee.co.id/return-pay-here?0340450",
display_name="Your preferred name",
description="Payment Description"
)
List of E-Wallet: https://docs.xfers.com/docs/e-wallet#list-of-e-wallet
API Reference: https://docs.xfers.com/reference/create-payment
Retrieves a Payment object that was previously requested.
payment = xfers.Payment
payment.get(payment_id="va_1234567")
API Reference: https://docs.xfers.com/reference/retrieve-payment
type = The type of payment method. Currently support "virtual_bank_accounts" and "qris".
payment_method = xfers.PaymentMethod
payment_method.get(type="virtual_bank_accounts", payment_id="va_1234567")
API Reference: https://docs.xfers.com/reference/retrieve-payment-method
Simulates a payment received from the customer for a given payment. Status will be changed to 'paid'.
payment_method = xfers.PaymentMethod
payment_method.receive_payment(
payment_method_id="va_123456789",
amount=90000
)
Simulates a payment received from the customer for a given payment. Status will be changed to 'paid'.
payment = xfers.Payment
payment.receive_payment(
payment_method_id="va_123456789",
)
Simulates a payment received from the customer for a given payment. Status will be changed to 'paid'.
payment = xfers.Payment
payment.receive_payment(
payment_method_id="va_123456789",
)
Cancel a payment when it is still in pending state. Status will be changed to 'cancelled'. (This is only available for One-off Virtual Account at the moment.)
payment = xfers.Payment
payment.cancel(
payment_method_id="va_123456789",
)
Simulates funds for a payment being made available for transfer or withdrawal. Status will be changed to 'completed'.
payment = xfers.Payment
payment.settle(
payment_method_id="va_123456789",
)
Creates a Disbursement object that will send funds from your Xfers account to an intended recipient.
xfers.Disbursements.create(amount="10000",
reference_id="123",
bank_shortcode="BCA",
bank_account_no="0123123123",
bank_account_holder_name="john doe")
Retrieves a Disbursement object that was previously requested.
xfers.Disbursements.get(disbursement_id="id")
Returns a list of Disbursements.
xfers.Disbursements.list(created_after="2022-04-15")