I'm trying to truncate Django-Oscar's checkout flow. Assuming we start in basket/cart, the default flow looks like this:
- User clicks on "Proceed to checkout" button
- PaymentMethodView is called
- 'payment-details' page loads
- User clicks on "Continue"
- Oscar's 'preview' loads. User clicks on "Place order" and purchases the item
- User is sent to Oscar's 'thank-you' page and receives an email confirmation
I want this instead:
- "Proceed to checkout" button is replaced with PayPal Checkout Express client-side checkout.js button
- User clicks on PayPal button and pays
- User is sent to Oscar's 'thank-you' page and receives an email confirmation
The problem is this: the PayPal button works and payments come through successfully every time but, Oscar alternately sends the user to the 'payment-details' page and the 'thank-you' page after payment. To be clear:
- User buys an item, and is sent to 'thank-you' page and gets an email
- User buys another item, is sent to 'payment-details' page and does not get an email, and Oscar does not register the purchase even though the payment comes through
- User buys a third item and experiences Oscar's response in step 1
- User buys a fourth item and experiences Oscar's response in step 2
- And so ad infinitum
All urls, views, and models, worked perfectly up to this point. The only thing I'd done at this point was replace the "Proceed to checkout" button with PayPal's button.
I then removed the PayPal button, and restored the "Proceed to checkout" button, but with one edit. The button looks like this: <a href="{% url 'checkout:index' %}" class="...">{% trans "Proceed to checkout" %}</a>
.
I replaced 'checkout:index'
with 'checkout:preview'
to see if I could skip the 'payment-details' page. The alternating situation continued. Oscar sent users to the 'preview' page first, and on the next turn it sent users to the 'payment-details' page.
I also tried overriding PaymentMethodView:
from oscar.apps.checkout.views import PaymentMethodView as BasePaymentMethodView
from django.shortcuts import redirect
class PaymentMethodView(BasePaymentMethodView):
def get_success_response(self):
return redirect('thank-you')
The alternating between the 'payment-details' and 'thank-you' pages remained.
I'm out of ideas. What could have have gone wrong?