I would like to implement cash payments, wherein the customer picks up his order in store, and pays the same there. There will also be an option later on for customers to pay cash upon delivery of their orders (note: I understand that there is an oscar cash on delivery app, but I am asking regardless). What is oscar's new recommended way to define cash payment methods in version 2.0?
Previously, (though I can no longer find the documentation), payment methods were defined by expanding a base payment method like so:
# mystore/forked_apps/payment/methods.py
class Base(object):
"""
Payment method base class
"""
code = '__default__'
name = 'Default payment'
description = ''
enabled = False
default = False
class CashOnPickup(Base):
code = 'cash_on_pickup'
name = 'Cash on Pickup'
description = 'Pay when you pick up your items'
enabled = True
default = True
However, the new documentation mentions the use of the SourceType
, Source
, and Transaction
models, and I can no longer find the previous documentation regarding defining methods like above.
As such, what is the recommended manner to define an in-store cash payment method in django-oscar 2.0? Is defining methods in a methods.py file no longer the way to go? Should we subclass SourceType
, Source
, and Transaction
instead? Or, would the way to go be to simply create new database entries for these as demonstrated by the code below?
# https://github.com/django-oscar/django-oscar-datacash/blob/master/sandbox/apps/checkout/views.py
# django-oscar-datacash/sandbox/apps/checkout/views.py
...
from oscar.apps.checkout.views import PaymentDetailsView as OscarPaymentDetailsView
...
from oscar.apps.payment.models import SourceType, Source
...
class PaymentDetailsView(OscarPaymentDetailsView):
...
def handle_payment(self, order_number, total, **kwargs):
...
source_type, _ = SourceType.objects.get_or_create(name='Datacash')
source = Source(source_type=source_type,
currency=settings.DATACASH_CURRENCY,
amount_allocated=total.incl_tax,
reference=datacash_ref)
self.add_payment_source(source)
# Also record payment event
self.add_payment_event('pre-auth', total.incl_tax)
Furthermore, what is the recommended way to fit a cash based payment system using the new models? For example, would SourceType
be "Cash", Source
(or Source reference) would be "CashOnPickup" or "CashOnDelivery"? Lastly, where would the Transaction
model fit in cash payments? Code comments of the AbstractTransaction
class states that transactions have nothing to do with the lines of the order while payment events do
, my understanding of this is that "transactions" are not necessarily transactions where there is a movement of funds, but that non-payment actions like pre-authorization of cards are also counted. But what about cash payments?