Modules collectives.models.payment
Modules collectives.models.payment
#
Module defining payment-related models
- class collectives.models.payment.ItemPrice(**kwargs)#
Database model describing prices for a payment item E.g. ‘Youth ‘, ‘Early bird’, …
- Todo
Add constraint on license type
- Todo
Add constraint on date range
- active_use_count()#
Number of currently active or payment pending registrations (i.e, registrations holding a slot or event leaders) that are using this price
- Returns
number of payments associated with this price and an active registration
- Return type
int
- amount#
Charged amount in euros
- Type
decimal.Decimal
- copy(time_shift=datetime.timedelta(0), old_event_id=None, new_event_id=None)#
Copy this price.
- Returns
Copied
collectives.models.payments.PaymentItem
- Returns
Copied
collectives.models.payments.ItemPrice
- enabled#
Whether this price is enabled. Ideally, prices should be disabled rather than fully deleted once at least one person has used the
- Type
bool
- end_date#
Date at which this price will stop to be available
- Type
datetime.date
- has_available_use()#
Returns whether there are remaining uses for this price :return: True if max_uses is 0 or larger than
active_use_count()
:rtype: bool
- id#
Database primary key
- Type
int
- is_available_at_date(date)#
Returns whether this price is available at a given time
- Parameters
date (
datetime.Date
) – The date at which to do the check- Returns
True if the date is between start and end date or those dates are not defined
- Return type
bool
- is_available_to_user(user: collectives.models.user.User) bool #
Returns whether this price is available to an user at any point in time
- Parameters
user – The candidate user
- Returns
True if the user license belongs to the associated user group
- item_id#
Primary key of the item to which this price is associated
- Type
int
- max_uses#
Max number of times this price can be used. If the number is NULL, then the number of times is unlimited
- Type
string
- payments#
List of payments associated to this payment option.
- Type
- start_date#
Date at which this price will start to be available
- Type
datetime.date
- title#
Subtitle for this price
- Type
string
- total_use_count()#
Total number of times this price has been used, even if the corresponding registration is no longer active
- Returns
total number of payments associated with this price
- Return type
int
- update_time#
Time at which the price was last updated
- Type
datetime.datetime
- property user_group#
Overload user_group property access to automatically perform migration :return:
sqlalchemy.orm.relationship
- user_group_id#
User Group id, of whoch user is required to be a member to get the price.
- class collectives.models.payment.Payment(registration=None, item_price=None, buyer=None)#
Datable model describing the details of a payment
- amount_charged#
Amount in euros to be paid by the user. Stored locally as the payment item price might have been updated while the payment is being processed.
- Type
decimal.Decimal
- amount_paid#
Amount in euros paid by the user if the payment has been approved. For validation purposes
- Type
decimal.Decimal
- buyer_id#
Primary key of the user making this payment Should be similar to registration.user_id, but copied here in case registration is deleted
- Type
int
- creation_time#
Timestamp at which the payment was created
- Type
datetime.datetime
- finalization_time#
Timestamp at which the payment was finalized (approved/cancelled)
- Type
datetime.datetime
- has_receipt()#
- Returns
whether this payment has an associated receipt (i.e. if it is an approved online payment)
- Return type
bool
- has_refund_receipt()#
- Returns
whether this payment has an associated refund receipt (i.e. if it is a refunded online payment)
- Return type
bool
- id#
Database primary key
- Type
int
- is_approved()#
- Returns
whether this payment has been accepted
- Return type
bool
- is_offline()#
- Returns
whether this is an offline payment (Check, Card, etc)
- Return type
bool
- is_unsettled()#
- Returns
whether this payment is not finalized yet. Applies mostly to Online payments
- Return type
bool
- item_price_id#
Primary key of the item price this payment is associated to
- Type
int
- payment_item_id#
Primary key of the item this payment is associated to. Should be similar to item_price.payment_item_id, but makes it easier to list all payments for a given item.
- Type
int
- payment_type#
Payment type (online, cash, …)
- processor_order_ref#
Human-readable order identifier for the payment processor.
- Type
str
- processor_token#
Unique identifier of this payment for the payment processor.
- Type
str
- processor_url#
Url that the buyer should be redirected to to make the payment
- Type
str
- raw_metadata#
- Raw metadata concerning this payment as returned by the payment processor,
or payment details if it had been made by cash/check To be refined.
- Type
str
- refund_metadata#
Raw metadata concerning this payment refund transaction.
- Type
str
- refund_time#
Timestamp at which the payment was refunded
- Type
datetime.datetime
- registration_id#
Primary key of the registration this payment is associated to
- Type
int
- reporter_id#
Primary key of the user reporting this payment For online payments this should be similar to buyer, for manual payments this would be the id of the leader/admin who reported the payment
- Type
int
- status#
Current status of the payment
- terms_version#
Version of the payment terms and condition at the time of payment
- Type
string
- class collectives.models.payment.PaymentItem(**kwargs)#
Database model describing a paid item for a given event E.g. ‘Pass’, ‘Pass + transport’, …
- active_prices()#
- Returns
All active prices associated to this item
- Return type
- available_prices_to_user(user)#
Returns all prices that are available to a given user at any point in time
- Parameters
user (
collectives.models.user.User
) – The candidate user- Returns
List of available prices
- Return type
- available_prices_to_user_at_date(user, date)#
Returns all prices that are available to a given user at a given date
- Parameters
user (
collectives.models.user.User
) – The candidate userdate (
datetime.date
) – The considered date
- Returns
List of available prices
- Return type
- cheapest_price_for_user_at_date(user, date)#
Returns the cheapest price available to a given user at a given date
- Parameters
user (
collectives.models.user.User
) – The candidate userdate (
datetime.date
) – The considered date
- Returns
List of available prices
- Return type
- cheapest_price_for_user_now(user)#
Returns the cheapest price available to a given user at the current time
- Parameters
user (
collectives.models.user.User
) – The candidate user- Returns
List of available prices
- Return type
- copy(time_shift=datetime.timedelta(0), old_event_id=None, new_event_id=None)#
Copy current payment item.
Copy also price but not payments.
- Parameters
time_shift (
datetime.timedelta
) – Optionnal shift of copied item prices dates- Returns
Copied
collectives.models.payments.PaymentItem
- event_id#
Primary key of the event to which this payment option is associated
- Type
int
- id#
Database primary key
- Type
int
- payments#
List of payments associated to this payment item.
- Type
- prices#
List of prices associated to this payment item.
- Type
- title#
Display title for this payment option
- Type
string
- class collectives.models.payment.PaymentStatus(value)#
Enum describing the current state of the payment at a high level
- Approved = 1#
Payment has been approved
- Cancelled = 2#
Payment has been cancelled by the user
- Expired = 4#
Payment has expired due to timeout
- Initiated = 0#
Payment has been initiated, waiting for a response from the processor
- Refunded = 5#
Payment has been refunded to the user
- Refused = 3#
Payment has been refused by the processor
- classmethod display_names()#
- Returns
a dict defining display names for all enum values
- Return type
dict
- class collectives.models.payment.PaymentType(value)#
Enum describing the type of payment
- Card = 3#
Payment has been using a debit or credi card
- Cash = 2#
Payment has been made by cash
- Check = 1#
Payment has been made by check
- Online = 0#
Payment has been made through the online payment processor
- Transfer = 4#
Payment has been using a bank transfer
- classmethod display_names()#
- Returns
a dict defining display names for all enum values
- Return type
dict