-
Notifications
You must be signed in to change notification settings - Fork 23
Onlineweb apps Payment
Onlinewebs payment system uses Stripes custom checkout system
The main object that contains a generic link to a content object (Event, prokom thingy, etc) This object has 3 types:
- Instant - User have to pay before attending
- Deadline - A deadline is set and users have to pay within the deadline
- Delay - The payment deadline is a custom amount of days after attending.
The link between the payment and a user.
Contains an unique id, the time of purchase and a stripe_id used for refunding.
To allow a payment to have multiple prices, a PaymentPrice object contains a price and a description.
Object used to give users extra time.
Given to attending users when using payment mode 3(Delay).
Given to users bumped from the wait list if the payment.deadline > 2 days.
PamentDelays are deleted when the user pays.
The example code is from events and references to AttendanceEvent should be changed with your own object.
The request.session should have a payment id.
This should be done in the view method that loads the template with the payment button.
The payments should be passed with the context.
try:
payment = Payment.objects.get(content_type=ContentType.objects.get_for_model(AttendanceEvent), object_id=event_id)
request.session['payment_id'] = payment.id
except Payment.DoesNotExist:
events/views.py - details
You need to update the following 4 methods:
Payment
- responsible_mail() - Mail address linked to the people responsible for the payment
- handle_payment()(Optional) - If any additional action needs to be done besides creating a payment object
Refunds (Only needed if you need to support refunds)
- check_refund() - Do necessary checks to see if the user is eligible for a refund.
- handle_refund()(Optional) - If any additional action needs to be done when a user refunds.
This is an example of template code supporting multiple payments
{% for payment_price in payment.prices %}
<p class="status-text payment-price-tag">Prisen er på {{ payment_price.price }} Kr.</p>
<button id="stripeButton{{ payment_price.id }}" class="btn btn-large btn-success payment-button">Betal med kort</button>
{% if payment.prices|length > 1 %}
<p class="help-text row-space">{{payment_price.description}}</p>
{% endif %}
{% endfor %}
{% if payment_delay %}
<p class="help-text row_space">Frist: {{ payment_delay.valid_to }}</p>
<br>
{% elif payment.deadline %}
<p class="help-text row_space">Frist: {{ payment.deadline }}</p>
<br>
{% endif %}
<script src="{{ STATIC_URL }}js/libs/jquery-2.1.3.min.js"></script>
<script src="https://checkout.stripe.com/checkout.js"></script>
<script src="{{ STATIC_URL }}js/payment.js"></script>
templates/events/details.html
Note: You might have to change the jquery version to the newest one in the js/libs folder.
Confirmation mail is sent and the payment_relation object is created automatically on successful payments.
Not needed
Under development
The mommy job runs once a day and sends notifications when it is less than one day left of the delay.
When the delay deadline has passed the user gets a mark and the delay object is set to inactive to prevent further marks from being set.
TBA
Note! check that the mails sent are correct
- Instant payment
- Payment after attendance
- Multiple payments
- Payment with delay
- Refund and unattended
- Unattend_deadline passed
- Attend without payment
- Untatend without payment
- Waitlist bump (Without payment)
- Waitlist bump (with payment, deadline over 2 days in the future)
- Waitlist bump (with payment, deadline less than 2 days in the future) - Should create paymentdelay object.
- Waitlist bump (with payment type 3(delay)) - Creates paymentDelay object with deadline = (now + payment.delay)
-
Not paid less than 3 days left of deadline.
-
Not paid deadline passed.
-
Not paid - Has payment delay
-
PaymentDelay - Notification sent when valid_to <= 1 day
-
PaymentDelay valid_to passed - Mark given - Unatend if unatend_deadline not passed.
-
PaymentDelay valid_to passed - Mark given - if unatend_deadline passed - Block users from future events. (Will not be done yet)