Saleor: Disable payment for refunded/canceled orders

Created on 29 Apr 2019  路  9Comments  路  Source: mirumee/saleor

What I'm trying to achieve

:raising_hand_man: Disable payment for refunded/canceled orders. I know that #3636 have asked for this, but it has no data about this issue so here we go.

Steps to reproduce the problem

  1. Make an order and pay it.
  2. Refund the order in the dashboard.
  3. Go to account in customer profile and pay the order again! :smile_cat:
  4. Go to dashboard and refund again... Ups! You Can't! :tipping_hand_woman:

What I expected to happen

When the order is refunded/canceled, customers should not be able to pay for it again.

Screenshots

But they can! :smile_cat:
image

bug payments

All 9 comments

@maarcingebala seems like a bug to me. Your thoughts?

IMHO, even the partially refunded order shouldn't be paid again.

Right, it looks like a bug. If an order is refunded, partially refunded or canceled customers shouldn't be able to pay. We have to also make sure that they can retry payment if they placed an order, tried to pay but the payment has failed. We should also provide test cases for these scenarios.

I will take a look whenever I have some free time for it.

For now, I've unassigned you @NyanKiyoshi, anyone who we'll have time to tackle it will be able to take it.

I had worked on it a week ago during my free time, but I got stuck, so I did not go further and then forgot about this issue.

My problem was that I鈥檓 not sure how Saleor should behave when an order is whether partially or fully refunded. Should we flag the order as closed? Thus, make it inactive. Then no payment or change would be possible.

The other thing I thought about was that we might ask the staff user to choose if to close a refunded order.

Then, another thing to be careful about, is if we closed an order when partially refunded, the staff user should still be able to refund again a new amount.

@NyanKiyoshi Maybe we could just disable payment for refunded order in storefront 1.0 first as a starter?

@jxltom it must disable from the core!

@jxltom
@maarcingebala
@NyanKiyoshi
i changed the check_order_status function.

def check_order_status(func):
    """Check if order meets preconditions of payment process.

    Order can not have draft status or be fully paid. Billing address
    must be provided.
    If not, redirect to order details page.
    """
    # pylint: disable=cyclic-import
    from .models import Order

    @wraps(func)
    def decorator(*args, **kwargs):
        token = kwargs.pop("token")
        order = get_object_or_404(Order.objects.confirmed(), token=token)
        if not order.billing_address or order.is_fully_paid() or not order.status == 'cancelled' :
            return redirect("order:details", token=order.token)
        kwargs["order"] = order
        return func(*args, **kwargs)

    return decorator

and in the front i changed order details .
{% if not order.is_partly_paid and not order.status == 'canceled' %}
and problem is solved:)
if there is a mistake with my code or any problem .
please some one tell me:)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

damianarechar picture damianarechar  路  3Comments

purnendushukla picture purnendushukla  路  4Comments

NumanIjaz picture NumanIjaz  路  3Comments

8BitAce picture 8BitAce  路  4Comments

gComet picture gComet  路  3Comments