Skip to content

Conversation

jawad-khan
Copy link

This PR introduces Django REST Framework (DRF) support for the DummyProvider in django-payments. It adds a DRF Serializer that mirrors the existing DummyForm, enabling API-based validation/usage rather than just form/template-based flows.

@WhyNotHugo
Copy link
Member

WhyNotHugo commented Sep 22, 2025 via email

@jawad-khan
Copy link
Author

Hi, thanks a lot for your feedback! 🙏

You raise a very valid concern — the frontend needs to know which fields to send when using the REST API. To handle this, one option could be:

Expose a metadata endpoint for each provider that returns field names, types, required/optional status, and available choices.

For example: GET /api/payments/dummy/metadata/ → { "fields": ["status", "fraud_status", "gateway_response", "verification_result"], "choices": {...}, "required": {...} }

Alternatively, we could document how clients can introspect provider serializer fields to discover what’s required.

Or even enhance the serializer to expose a helper for dynamic form generation on the frontend.

This PR was meant as a draft, mainly to get your initial nod before going further. If you think this approach makes sense, I’ll update the PR with:

proper test cases,

the discovery mechanism (metadata endpoint or whichever option you prefer),

and a more complete implementation.

@WhyNotHugo
Copy link
Member

WhyNotHugo commented Sep 22, 2025 via email

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
@jawad-khan
Copy link
Author

Hi @WhyNotHugo, I have added metadata api as you asked. Also improved overall structure of the code. What do you think about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants