def METHOD_NAME(request, provider):
    if request.method == "POST":
        req_data = json.loads(request.body.decode("UTF-8"))
        ExternalPaymentProvider.FromID(provider).RefreshPaymentStateForExternalIDs(req_data["external_ids"])
    elif request.method == "GET":
        ExternalPaymentProvider.FromID(provider).RefreshPaymentState()
    else:
        return HttpResponse(status=405)
    return HttpResponse()