Serializers
The django_midtrans.serializers module provides Django REST Framework serializers for all API endpoints.
Payment Serializers
PaymentSerializer
Full payment detail serializer. Used for single payment responses.
Model: MidtransPayment
Field |
Type |
Notes |
|---|---|---|
|
|
Read-only. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bank transfer VA number. |
|
|
Mandiri bill key. |
|
|
Mandiri biller code. |
|
|
Convenience store code. |
|
|
3DS redirect URL. |
|
|
GoPay/ShopeePay deeplink. |
|
|
QRIS QR data. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Computed: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Nested |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
All fields are read-only.
PaymentListSerializer
Compact payment list serializer. Used for list endpoints.
Field |
Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PaymentItemSerializer
Model: MidtransPaymentItem
Field |
Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Input Serializers
ChargeSerializer
Input serializer for creating a payment charge.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
One of the |
|
|
Yes |
Amount in IDR (min: 1). |
|
|
No |
Max 50 chars. Auto-generated if omitted. |
|
|
Conditional |
Required for |
|
|
Conditional |
Required for |
|
|
No |
For GoPay/ShopeePay. |
|
|
Conditional |
Required for |
|
|
No |
Default: |
|
|
No |
Nested |
|
|
No |
Nested |
|
|
No |
Nested |
|
|
No |
Override webhook URL. |
|
|
No |
Arbitrary metadata. |
|
|
No |
Max 3 items, each max 255 chars. |
Validation Rules:
token_idis required whenpayment_typeiscredit_card.bankis required whenpayment_typeisbank_transfer.storeis required whenpayment_typeiscstore.If
item_detailsis provided, the sum ofprice × quantitymust equalgross_amount.
CustomerDetailInputSerializer
Field |
Type |
Required |
Default |
|---|---|---|---|
|
|
No |
|
|
|
No |
|
|
|
No |
|
|
|
No |
|
ItemDetailInputSerializer
Field |
Type |
Required |
Default |
|---|---|---|---|
|
|
No |
|
|
|
Yes |
— |
|
|
Yes |
— |
|
|
No |
|
|
|
No |
|
|
|
No |
|
|
|
No |
|
|
|
No |
|
CustomExpiryInputSerializer
Field |
Type |
Required |
Default |
|---|---|---|---|
|
|
Yes |
— |
|
|
No |
|
Options for unit: second, minute, hour, day.
Refund Serializers
RefundSerializer
Read-only serializer for refund records.
Field |
Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RefundInputSerializer
Field |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
|
Yes |
— |
Must not exceed |
|
|
No |
|
— |
|
|
No |
|
Use direct (online) refund. |
Notification Serializers
NotificationSerializer
Read-only serializer for notification records.
Field |
Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Invoice Serializers
InvoiceSerializer
Full invoice serializer with nested items.
Field |
Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CreateInvoiceSerializer
Field |
Type |
Required |
|---|---|---|
|
|
Yes |
|
|
Yes |
|
|
No |
|
|
No |
|
|
Yes |
|
|
Yes (min 1) |
|
|
No |
|
|
No |
|
|
No |
|
|
No |
VoidInvoiceSerializer
Field |
Type |
Required |
Default |
|---|---|---|---|
|
|
No |
|
Subscription Serializers
SubscriptionSerializer
Full subscription serializer. All fields are read-only.
Field |
Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CreateSubscriptionSerializer
Field |
Type |
Required |
Default |
|---|---|---|---|
|
|
Yes |
— |
|
|
Yes |
— |
|
|
Yes |
— |
|
|
Conditional |
|
|
|
Conditional |
|
|
|
No |
|
|
|
No |
|
|
|
No |
|
|
|
No |
— |
|
|
No |
|
|
|
No |
|
|
|
No |
|
|
|
No |
— |
|
|
No |
— |
Validation:
tokenis required whenpayment_typeiscredit_card.gopay_account_idis required whenpayment_typeisgopay.