API

class payments.models.BasePayment(*args, **kwargs)

Represents a single transaction. Each instance has one or more PaymentItem.

property attrs

A JSON-serialised wrapper around extra_data.

This property exposes a a dict or list which is serialised into the extra_data text field. Usage of this wrapper is preferred over accessing the underlying field directly.

You may think of this as a JSONField which is saved to the extra_data column.

capture(amount=None)

Capture a pre-authorized payment.

Note that not all providers support this method.

change_status(status: PaymentStatus | str, message='')

Updates the Payment status and sends the status_changed signal.

created

Creation date and time

currency

Currency code (may be provider-specific)

get_failure_url() str

A URL where users will be redirected after a failed payment.

Subclasses MUST implement this method.

get_success_url() str

A URL where users will be redirected after a successful payment.

Subclasses MUST implement this method.

modified

Date and time of last modification

release()

Release a pre-authorized payment.

Note that not all providers support this method.

save(**kwargs)

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

status

Transaction status

total

Total amount (gross)

transaction_id

Transaction ID (if applicable)

class payments.PurchasedItem(name: str, quantity: int, price: Decimal, currency: str, sku: str, tax_rate: Decimal | None = None)

A single item in a purchase.

currency: str

Alias for field number 3

name: str

Alias for field number 0

price: Decimal

Alias for field number 2

quantity: int

Alias for field number 1

sku: str

Alias for field number 4

tax_rate: Decimal | None

Alias for field number 5