payments package

Submodules

payments.admin module

class payments.admin.AddCoinPairView(**kwargs)[source]

Bases: django.views.generic.base.TemplateView

Admin view for easily adding two coins + two pairs in each direction

coin_types()[source]

View function to be called from template, for getting list of coin handler errors

get(request, *args, **kwargs)[source]
post(request, *args, **kwargs)[source]
template_name = 'admin/add_pair.html'
class payments.admin.AddressAccountMapAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('deposit_coin', 'deposit_address', 'destination_coin', 'destination_address')
list_filter = ('deposit_coin', 'destination_coin')
media
search_fields = ('deposit_address', 'destination_address')
class payments.admin.CoinAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

fieldsets = (('Unique Coin Symbol for refrencing from the API', {'fields': ('symbol',), 'description': "<p><strong>Help:</strong> The 'Unique Coin Symbol' is not passed to the handler, and thus doesn't need to match the real token symbol on the network, it just needs to be unique, as it acts as the ID of the coin when making API calls.</p></p><br/><hr/>"}), ("Native Token Symbol (must match the real symbol on it's network)", {'fields': ('symbol_id',), 'description': "<p>The 'Native Coin Symbol' is passed to the coin handler and does not have to be unique, but it MUST match the real symbol used by the token, otherwise the coin handler will be unable to send/receive the token.<br/><strong>If you leave this field blank when creating the coin, it will default to the Unique Coin Symbol.</strong></p><br/><hr/>"}), ('Display name, Coin Type (handler), Enable/Disable coin', {'fields': ('display_name', 'coin_type', 'enabled'), 'description': "<p><strong>Help:</strong> The 'Display Name' is returned in API calls, and shown in the admin panel.</p> <p>The 'Coin Type' must be set correctly, it determines which network this coin is on, so that the correct <strong>Coin Handler</strong> will be used for the coin.</p><p>The 'Enabled' option decides whether or not this coin is in use. If you uncheck this, no conversions will take place for this coin, and it will not be returned on the API.</p><hr/>"}), ('Our account/address, and whether we can issue this coin', {'fields': ('our_account', 'can_issue'), 'description': "<p><strong>Help:</strong> The 'Our Account (or address)' is passed to the coin handler and may not always need to be specified. For account based networks such as Steem, this setting generally MUST be filled in. <br/> The 'Can Issue' option determines whether the system should attempt to issue a token if our balance is too low to fulfill a conversion. If you are not the issuer of a token, keep this un-ticked.</p><hr/>"}), ('(Advanced) Coin Handler Settings', {'classes': ('collapse',), 'fields': ('setting_host', 'setting_port', 'setting_user', 'setting_pass', 'setting_json'), 'description': '<p><strong>Help:</strong> The \'Handler Settings\' are all optional. Most coins will work just fine without changing any of these options. <br/>The host/port/user/pass settings are designed for selecting a certain RPC node, however these may not always be respected by every handler.<br/> The \'Custom JSON\' field allows for additional settings specific to the coin handler, and you must enter valid JSON in this field, for example:</p> <code>{"contract": "eosio.token"}</code><br/><br/><hr/>'}), ('Low Funds Email Alert Settings', {'classes': ('collapse',), 'fields': ('notify_low_funds', 'funds_low', 'last_notified'), 'description': "<p><strong>Help:</strong> You generally only need to touch the checkbox 'Send an email notification', as the 'Deposits currently stuck' and 'Last Email Notification' are automatically managed by the system.</p><hr/>"}))
get_fieldsets(request, obj=None)[source]

Hook for specifying fieldsets.

list_display = ('__str__', 'symbol', 'coin_type', 'enabled', 'our_account', 'can_issue')
list_filter = ('coin_type',)
media
ordering = ('symbol',)
class payments.admin.CoinHealthView(**kwargs)[source]

Bases: django.views.generic.base.TemplateView

Admin view for viewing health/status information of all coins in the system.

Loads the coin handler manager for each coin, and uses the health() function to grab status info for the coin.

Uses caching API to avoid constant RPC queries, and displays results as a standard admin view.

get(request, *args, **kwargs)[source]
get_fails()[source]

View function to be called from template, for getting list of coin handler errors

handler_dic()[source]

View function to be called from template. Loads and queries coin handlers for health, with caching.

template_name = 'admin/coin_health.html'
class payments.admin.CoinPairAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('__str__', 'from_coin', 'to_coin', 'exchange_rate')
media
ordering = ('from_coin', 'to_coin')
class payments.admin.ConversionAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('from_coin', 'from_address', 'from_amount', 'to_coin', 'to_address', 'to_amount', 'tx_fee', 'ex_fee', 'created_at')
list_filter = ('from_coin', 'to_coin')
media
ordering = ('-created_at',)
search_fields = ('id', 'from_address', 'to_address', 'to_memo', 'to_txid')
class payments.admin.CustomAdmin(name='admin')[source]

Bases: django.contrib.admin.sites.AdminSite

To allow for custom admin views, we override AdminSite, so we can add custom URLs, among other things.

get_urls()[source]
class payments.admin.DepositAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

actions = [<function confirm_refund_deposit>]
list_display = ('txid', 'status', 'coin', 'amount', 'address', 'from_account', 'to_account', 'tx_timestamp')
list_filter = ('status', 'coin')
media
ordering = ('-tx_timestamp',)
search_fields = ('id', 'txid', 'address', 'from_account', 'to_account', 'memo', 'refund_address')
class payments.admin.KeyPairAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

list_display = ('network', 'public_key', 'account', 'key_type')
media
ordering = ('network', 'account')
payments.admin.clear_cache(request)[source]

Allow admins to clear the Django cache system

payments.admin.confirm_refund_deposit(modeladmin, request, queryset: django.db.models.query.QuerySet)[source]

Confirmation page for the “Refund Deposits to Sender” page. :param modeladmin: :param request: :param queryset: :return:

payments.admin.path(route, view, kwargs=None, name=None, *, Pattern=<class 'django.urls.resolvers.RoutePattern'>)
payments.admin.refund_deposits(request)[source]

payments.apps module

class payments.apps.PaymentsConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

name = 'payments'

payments.models module

This file contains Models, classes which define database tables, and how they relate to each other.

Models are used for both querying the database, as well as inserting new rows and updating existing ones.

Models may also contain properties and functions to help make them easier to use.

Note: The coin_type choices tuple, COIN_TYPES is located in settings.py, and may be dynamically altered by Coin Handlers. It does not enforce an enum on columns using it for choices , it’s simply used for a dropdown list in the admin panel.

Copyright:

+===================================================+
|                 © 2019 Privex Inc.                |
|               https://www.privex.io               |
+===================================================+
|                                                   |
|        CryptoToken Converter                      |
|                                                   |
|        Core Developer(s):                         |
|                                                   |
|          (+)  Chris (@someguy123) [Privex]        |
|                                                   |
+===================================================+
class payments.models.AddressAccountMap(*args, **kwargs)[source]

Bases: django.db.models.base.Model

This database model maps normal Bitcoin-like addresses to a destination token, and their token account/address.

This is because deposits of coins such as Bitcoin/Litecoin do not contain any form of “memo”, so they must be manually mapped onto a destination.

This model may be used for handling deposits for both memo-based (Bitshares-like) and address-based (Bitcoin-like) deposits, as there is both a memo and address (or account) field for deposits + destination coin

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

conversions
deposit_address

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

deposit_coin

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

deposit_coin_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

deposit_memo

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

destination_address

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

destination_coin

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

destination_coin_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

destination_memo

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
class payments.models.Coin(*args, **kwargs)[source]

Bases: django.db.models.base.Model

The operator of the service should define all coins and tokens they would like to support using the Django Admin. The symbol is used as the primary key, so it must be unique. It will automatically be made uppercase. Native Coin Symbol (e.g. BTC)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

can_issue

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

coin_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

conversions_from

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

conversions_to

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

deposit_converts

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

deposit_maps

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

deposits

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

dest_maps

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

display_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

enabled

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

funds_low

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_notified

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

notify_low_funds

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
our_account

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

pairs
pairs_from

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

pairs_to

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

save(*args, **kwargs)[source]

To avoid inconsistency, the symbol is automatically made uppercase

setting_host

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

setting_json

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

setting_pass

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

setting_port

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

setting_user

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

settings

Small helper property for quickly accessing the setting_xxxx fields, while also decoding the custom json field into a dictionary/list

Returns:dict(host:str, port:str, user:str, password:str, json:dict/list)
should_notify_low

Should we notify the admins that this coin’s wallet balance is too low?

Used to rate limit “???coin wallet balance is too low” emails sent to admins.

Usage:

>>> from django.core.mail import mail_admins
>>> c = Coin.objects.get(symbol='BTC')
>>> if c.should_notify_low:
>>>    mail_admins('BTC hot wallet is low!', 'The hot wallet is low. Please refill.')
Return bool:True if we should notify the admins
Return bool:False if we should skip this email notification for now, or notifications are disabled.
symbol

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

symbol_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class payments.models.CoinPair(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A coin pair defines an allowed conversion direction between two coins For example LTC (Litecoin) -> LTCP (Pegged Litecoin)

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

exchange_rate

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

from_coin

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

from_coin_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

from_coin_symbol
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
to_coin

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

to_coin_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_coin_symbol
class payments.models.Conversion(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Once a models.Deposit has been scanned, assuming it has a valid address or account/memo, the destination cryptocurrency/token will be sent to the user.

Successful conversion attempts are logged here, allowing for reference of where the coins came from, where they went, and what fees were taken.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

deposit

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

deposit_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ex_fee

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

from_address

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

from_amount
from_coin

The coin that we were sent

from_coin_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

from_coin_symbol
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
to_address

Where was it sent to?

to_amount

The amount of to_coin that was sent, stored as a high precision Decimal

to_coin

The destination token/crypto this token will be converted to

to_coin_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_coin_symbol
to_memo

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_txid

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tx_fee

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

updated_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class payments.models.CryptoKeyPair(*args, **kwargs)[source]

Bases: django.db.models.base.Model

This model allows for storing key pairs (generally for cryptocurrency addresses/accounts) safely in the database.

The private key is automatically encrypted with AES-128 upon saving, ensuring it cannot be read from the admin panel, any API leaks, or third party applications reading from the database.

For this model to function correctly, you must set ENCRYPT_KEY in .env by generating an encryption key using ./manage.py generate_key

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

account

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

balance

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

key_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

network

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
private_key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

public_key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

save(*args, **kwargs)[source]

To ensure that private keys can only be entered / updated from the admin panel and not viewed, we encrypt them with AES-128 when saving.

To avoid encrypting an already encrypted key, we only encrypt the key if we’re sure it’s not encrypted already.

Raises:
  • EncryptionError – Something went wrong while encrypting the key
  • EncryptKeyMissing – The key settings.ENCRYPT_KEY is not set or is not a valid encryption key.
used

For disposable addresses, e.g. Bitcoin addresses, this field tracks whether it has been used for a deposit.

class payments.models.Deposit(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A log of incoming token/crypto deposits, which will later be converted into crypto.

The primary key of a Deposit is the auto-generated id field - an auto incrementing integer.

There is a composite unique constraint on (txid, coin, vout), ensuring duplicate transactions do not get stored.

Deposits start out in state new , as they are processed by the conversion system they progress into either:

‘err’ - An error occurred while converting / importing
During the import/conversion there was a serious error that could not be recovered from This should be investigated by a developer.
‘inv’ - Invalid source/destination, user did not follow instructions correctly
The coins were sent to a non-registered address, or a memo we don’t know how to process. An admin should attempt to refund these coins to the sender.
‘refund’ - The coins sent in this Deppsit were refunded
Info about the refund should be in the refund_* fields
‘mapped’ - Deposit passed initial sanity checks, and we know the destination coin, address/account and memo.
Most deposits should only stay in this state for a few seconds, before they’re converted. If a deposit stays in this state for more than a few minutes, it generally means something is wrong with the Coin Handler, preventing it from sending the coins, e.g. low balance.
‘conv’ - Successfully Converted
The deposited coins were successfully converted into their destination coin, and there should be a related models.Conversion containing the conversion details.
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

STATUSES = (('err', 'Error Processing Transaction'), ('inv', 'Transaction is invalid'), ('refund', 'Coins were returned to user'), ('new', 'New (awaiting processing)'), ('mapped', 'Destination data found. Awaiting conversion.'), ('conv', 'Successfully converted'))
address

If the deposit is from a classic Bitcoin-like cryptocurrency with addresses, then you should enter the address where the coins were deposited into, in this field.

amount

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

coin

The symbol of the cryptocurrency or token that was deposited, in uppercase. e.g. LTC, LTCP, BTCP, STEEMP

coin_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

coin_symbol
conversion

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

convert_dest_address

The destination address. Set after a deposit has been analyzed, and we know what coin it will be converted to.

convert_dest_memo

The destination memo. Set after a deposit has been analyzed, and we know what coin it will be converted to.

convert_to

The destination coin. Set after a deposit has been analyzed, and we know what coin it will be converted to

convert_to_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

error_reason

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

from_account

If account-based coin, contains the name of the account that sent the coins

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
get_status_display(*, field=<django.db.models.fields.CharField: status>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_convert_attempt

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

memo

If the coin supports memos, and they’re required to identify a deposit, use this field.

objects = <django.db.models.manager.Manager object>
processed_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

refund_address

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

refund_amount

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

refund_coin

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

refund_memo

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

refund_txid

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

refunded_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

status

The current status of this deposit, see STATUSES

to_account

If account-based coin, contains the name of the account that the coins were deposited into

tx_timestamp

The date/time the transaction actually occurred on the chain

txid

The transaction ID where the coins were received.

updated_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

vout

If a transaction contains multiple deposits, for example, a Bitcoin transaction that contains several outputs (vout’s) for our addresses, then each vout must have an consistent output number, i.e. one that will not change each time the blockchain transaction is compared against the database.

payments.serializers module

class payments.serializers.CoinPairSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Bases: rest_framework.serializers.HyperlinkedModelSerializer

class Meta[source]

Bases: object

fields = ('id', 'from_coin', 'from_coin_symbol', 'to_coin', 'to_coin_symbol', 'exchange_rate', '__str__')
model

alias of payments.models.CoinPair

class payments.serializers.CoinSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Bases: rest_framework.serializers.HyperlinkedModelSerializer

class Meta[source]

Bases: object

fields = ('symbol', 'display_name', 'our_account', 'can_issue', 'coin_type', 'symbol_id')
model

alias of payments.models.Coin

class payments.serializers.ConversionSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Bases: rest_framework.serializers.HyperlinkedModelSerializer

class Meta[source]

Bases: object

exclude = ()
model

alias of payments.models.Conversion

class payments.serializers.DepositSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Bases: rest_framework.serializers.HyperlinkedModelSerializer

class Meta[source]

Bases: object

fields = ('id', 'txid', 'coin', 'coin_symbol', 'vout', 'status', 'tx_timestamp', 'address', 'from_account', 'to_account', 'amount', 'memo', 'created_at', 'conversion', 'processed_at', 'convert_to')
model

alias of payments.models.Deposit

payments.tests module

payments.views module

class payments.views.CoinAPI(**kwargs)[source]

Bases: rest_framework.viewsets.ReadOnlyModelViewSet

filterset_fields = ('symbol', 'symbol_id', 'our_account', 'coin_type', 'can_issue')
lookup_value_regex = '[^/]+'
queryset
serializer_class

alias of payments.serializers.CoinSerializer

class payments.views.CoinPairAPI(**kwargs)[source]

Bases: rest_framework.viewsets.ReadOnlyModelViewSet

filterset_fields = ('from_coin', 'to_coin')
lookup_value_regex = '[^/]+'
queryset
serializer_class

alias of payments.serializers.CoinPairSerializer

class payments.views.ConversionAPI(**kwargs)[source]

Bases: rest_framework.viewsets.ReadOnlyModelViewSet

filterset_fields = ('from_coin', 'to_coin', 'from_address', 'to_address', 'deposit__from_account', 'deposit__to_account', 'deposit__memo')
pagination_class

alias of CustomPaginator

queryset
serializer_class

alias of payments.serializers.ConversionSerializer

class payments.views.ConvertAPI(**kwargs)[source]

Bases: rest_framework.views.APIView

Required form / JSON fields:

  • from_coin - The API coin symbol to convert from (send this coin)
  • to_coin - The API coin symbol to convert into (we send you this coin)
  • destination - The account / address to send to

Optional:

  • dest_memo - For coins that support memos, you can specify a custom memo to use when sending.

Example (application/json)

{"from_coin": "BTC", "to_coin": "BTCP", "destination": "someguy123"}

Example (application/x-www-form-urlencoded):

from_coin=BTC&to_coin=BTCP&destination=someguy123
authentication_classes = (<class 'payments.views.DRFNoCSRF'>,)
post(request: rest_framework.request.Request)[source]
class payments.views.ConvertView(**kwargs)[source]

Bases: django.views.generic.base.TemplateView

template_name = 'convert.html'
class payments.views.CustomPaginator[source]

Bases: rest_framework.pagination.LimitOffsetPagination

default_limit = 100
max_limit = 1000
class payments.views.DRFNoCSRF[source]

Bases: rest_framework.authentication.SessionAuthentication

enforce_csrf(request)[source]

Enforce CSRF validation for session based authentication.

class payments.views.DepositAPI(**kwargs)[source]

Bases: rest_framework.viewsets.ReadOnlyModelViewSet

filterset_fields = ('address', 'from_account', 'to_account', 'txid', 'memo', 'conversion__to_address', 'conversion__to_memo', 'conversion__to_txid', 'status', 'coin')
order_by = 'created'
pagination_class

alias of CustomPaginator

queryset
serializer_class

alias of payments.serializers.DepositSerializer

class payments.views.IndexView(**kwargs)[source]

Bases: django.views.generic.base.TemplateView

template_name = 'base.html'
payments.views.api_root(self, request, *args, **kwargs)[source]
payments.views.r_err(msg, status=500)[source]

Module contents