juspay / hyperswitch

An open source payments switch written in Rust to make payments fast, reliable and affordable
https://hyperswitch.io/
Apache License 2.0
11.97k stars 1.25k forks source link

[FEATURE] Extend the BatchSampleDataInterface Trait for Disputes #6111

Open apoorvdixit88 opened 4 days ago

apoorvdixit88 commented 4 days ago

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

Complete these interface functions for Store, Mock Db and Kafka like we did for other functions.

Write Batch Insert and Delete Queries for Disputes

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

}'

The JWT token we can get from signup and then skipping the 2FA:

curl --location 'http://localhost:8080/user/signup' \ --header 'Content-Type: application/json' \ --data-raw '{ "email": "JohnTest@test.com", "password": "Test@321" }'

This will give an intermediate token in response, we need to use this token to skip 2FA

curl --location 'http://localhost:8080/user/2fa/terminate?skip_two_factor_auth=true' \ --header 'Authorization: Bearer Intermediatetoken'

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):

curl --location --request DELETE 'http://localhost:8080/user/sample_data' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer JWT' \ --data '{

}'


- 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
qstommyshu commented 14 hours ago

Hi @apoorvdixit88 , I can help on this.