We currently have a feature for generating sample data, which includes batch insertion of payments and refunds. The feature inserts payments and refunds in batches using the BatchSampleDataInterface trait. We need to extend this functionality to support batch insertion and deletion of disputes as well.
Steps to Implement Batch Support for Disputes
Extend the BatchSampleDataInterface Trait
We need to extend the existing BatchSampleDataInterface to include methods for batch insertion and deletion of disputes. These methods will be similar to the ones already implemented for PaymentIntent, PaymentAttempt, and Refund.
New Methods for Disputes:insert_disputes_batch_for_sample_data: This method will handle batch insertion of disputes.
delete_disputes_for_sample_data: This method will handle (batch) deletion of disputes.
Possible Implementation
Add Functions for Dispute Insert and Delete in BatchSampleDataInterface
File: crates/router/src/db/user/sample_data.rs
Extend the existing BatchSampleDataInterface to include the methods for inserting and deleting disputes.
Complete these interface functions for Store, Mock Db and Kafka like we did for other functions.
Write Batch Insert and Delete Queries for Disputes
Define the queries (using diesel) to handle batch insertion and deletion of disputes, similar to how they are handled for payments and refunds.
To test we can hard code some dummy dispute and try inserting using the function we made in core. We can check Db and see the logs for the query that is getting printed.
Steps for Testing Dispute Batch Insertion and Deletion
To verify the batch insertion and deletion of disputes using the functions implemented in the BatchSampleDataInterface, we can perform a simple test by hardcoding some dummy dispute data.
Once we have the dummy dispute data, we can use the generate_sample_data_for_user method from the core function to insert the disputes into the database. This should invoke the appropriate batch insertion logic. (Or we can make an api to test the behaviour when the function is invoked)
Curl to invoke this core function:
This will give us JWT Token that we can use to hit the sample_data api
Curl to delete sample data (The core function for sample dispute delete can be used to our advantage):
- We can check Database Logs and Printed Queries whether the appropriate queries are getting printed
- We can also manually check DB
Note: Omit the Code for Testing part in the PR raised, have only Insert and Delete logic related to the DB, include the relevant logs and screenshots after test.
The Sample disputes generation part, we will be handling in the separate PR. (#6117 )
### Have you spent some time checking if this feature request has been raised before?
- [X] I checked and didn't find a similar issue
### Have you read the Contributing Guidelines?
- [X] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)
### Are you willing to submit a PR?
None
Feature Description
The issue is sub part of issue: #5991
We currently have a feature for generating sample data, which includes batch insertion of payments and refunds. The feature inserts payments and refunds in batches using the BatchSampleDataInterface trait. We need to extend this functionality to support batch insertion and deletion of disputes as well.
Steps to Implement Batch Support for Disputes
Extend the BatchSampleDataInterface Trait We need to extend the existing BatchSampleDataInterface to include methods for batch insertion and deletion of disputes. These methods will be similar to the ones already implemented for PaymentIntent, PaymentAttempt, and Refund.
New Methods for Disputes:
insert_disputes_batch_for_sample_data
: This method will handle batch insertion of disputes.delete_disputes_for_sample_data
: This method will handle (batch) deletion of disputes.Possible Implementation
Add Functions for Dispute Insert and Delete in
BatchSampleDataInterface
crates/router/src/db/user/sample_data.rs
Complete these interface functions for Store, Mock Db and Kafka like we did for other functions.
Write Batch Insert and Delete Queries for Disputes
crates/diesel_model/src/query/user/sample_data.rs
To test we can hard code some dummy dispute and try inserting using the function we made in core. We can check Db and see the logs for the query that is getting printed.
Steps for Testing Dispute Batch Insertion and Deletion
generate_sample_data_for_user
method from the core function to insert the disputes into the database. This should invoke the appropriate batch insertion logic. (Or we can make an api to test the behaviour when the function is invoked) Curl to invoke this core function:}'
curl --location 'http://localhost:8080/user/signup' \ --header 'Content-Type: application/json' \ --data-raw '{ "email": "JohnTest@test.com", "password": "Test@321" }'
curl --location 'http://localhost:8080/user/2fa/terminate?skip_two_factor_auth=true' \ --header 'Authorization: Bearer Intermediatetoken'
curl --location --request DELETE 'http://localhost:8080/user/sample_data' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer JWT' \ --data '{
}'