Manage baskets, payments, and invoices with the Order Service. This service provides comprehensive functionality for handling order-related operations and payment processing: manage shopping baskets, process payments and invoices, handle payment callbacks, track order status and product variations, and manage payable and unpaid invoices.
| Method | Description | Parameters |
|---|---|---|
get_baskets() |
Get active baskets | refresh |
get_product_variation_status() |
Get product variation status | product_id |
create_invoice_payment() |
Create payment for invoice | invoice_id, request |
get_payable_invoices() |
Get payable invoices | page, per_page |
get_unpaid_invoices() |
Get unpaid invoices | invoice_id, status, page, per_page, sort |
get_payment_callback() |
Get payment callback | payment_id, request |
create_payment_callback() |
Create payment callback | payment_id, request |
from basalam_sdk import BasalamClient, PersonalToken
from basalam_sdk.order.models import (
CreatePaymentRequestModel, PaymentCallbackRequestModel, PaymentVerifyRequestModel,
UnpaidInvoiceStatusEnum, OrderEnum
)
auth = PersonalToken(
token="your_access_token",
refresh_token="your_refresh_token"
)
client = BasalamClient(auth=auth)async def get_baskets_example():
baskets = await client.get_baskets(
refresh=True
)
print(f"Basket ID: {baskets.id}")
print(f"Item count: {baskets.item_count}")
print(f"Error count: {baskets.error_count}")
if baskets.vendors:
for vendor in baskets.vendors:
print(f"Vendor: {vendor.title} - Items: {len(vendor.items) if vendor.items else 0}")
return basketsasync def get_product_variation_status_example():
status = await client.get_product_variation_status(
product_id=123
)
print(f"Product variation status: {status}")
return statusasync def create_invoice_payment_example():
payment = await client.create_invoice_payment(
invoice_id=456,
request=CreatePaymentRequestModel(
pay_drivers={
"gateway": {"amount": 50000},
"credit": {"amount": 25000},
"salampay": {"amount": 0},
"other": {"amount": 0}
},
callback="https://example.com/callback",
option_code="OPTION123",
national_id="1234567890"
)
)
print(f"Payment created: {payment}")
return paymentasync def get_payable_invoices_example():
invoices = await client.get_payable_invoices(
page=1,
per_page=10
)
print(f"Payable invoices: {invoices}")
return invoicesasync def get_unpaid_invoices_example():
invoices = await client.get_unpaid_invoices(
invoice_id=123,
status=UnpaidInvoiceStatusEnum.UNPAID,
page=1,
per_page=20,
sort=OrderEnum.DESC
)
print(f"Unpaid invoices: {invoices}")
return invoicesasync def get_payment_callback_example():
callback = await client.get_payment_callback(
payment_id=789,
request=PaymentCallbackRequestModel(
status="success",
transaction_id="txn_123456",
description="Payment completed successfully"
)
)
print(f"Payment callback: {callback}")
return callbackasync def create_payment_callback_example():
callback = await client.create_payment_callback(
payment_id=789,
request=PaymentVerifyRequestModel(
payment_id="pay_123456",
transaction_id="txn_123456",
description="Payment verification completed"
)
)
print(f"Payment callback created: {callback}")
return callbackAvailable payment methods include:
credit_card- Credit card paymentsdebit_card- Debit card paymentsbank_transfer- Bank transferdigital_wallet- Digital wallet paymentscash_on_delivery- Cash on delivery
Common payment statuses:
pending- Payment is pendingsuccess- Payment completed successfullyfailed- Payment failedcancelled- Payment was cancelledrefunded- Payment was refunded
- Upload Service - File upload and management
- Search Service - Search for products and entities
- Order Processing Service - Process orders and parcels