Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added dispute #247

Merged
merged 7 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
286 changes: 286 additions & 0 deletions documents/dispute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
## Document

### Fetch All Disputes

```rb
Razorpay::Dispute.all()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we allow any params for pagination ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No params according to this doc https://razorpay.com/docs/api/disputes/fetch-all

```

**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "disp_Esz7KAitoYM7PJ",
"entity": "dispute",
"payment_id": "pay_EsyWjHrfzb59eR",
"amount": 10000,
"currency": "INR",
"amount_deducted": 0,
"reason_code": "pre_arbitration",
"respond_by": 1590604200,
"status": "open",
"phase": "pre_arbitration",
"created_at": 1590059211,
"evidence": {
"amount": 10000,
"summary": null,
"shipping_proof": null,
"billing_proof": null,
"cancellation_proof": null,
"customer_communication": null,
"proof_of_service": null,
"explanation_letter": null,
"refund_confirmation": null,
"access_activity_log": null,
"refund_cancellation_policy": null,
"term_and_conditions": null,
"others": null,
"submitted_at": null
}
}
]
}
```
-------------------------------------------------------------------------------------------------------

### Fetch a Dispute

```rb
disputeId = "disp_0000000000000"

Razorpay::Dispute.fetch(disputeId)
```

**Parameters:**

| Name | Type | Description |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format the table

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

|-------|-----------|--------------------------------------------------|
| disputeId* | string | The unique identifier of the dispute. |

**Response:**
```json
{
"id": "disp_AHfqOvkldwsbqt",
"entity": "dispute",
"payment_id": "pay_EsyWjHrfzb59eR",
"amount": 10000,
"currency": "INR",
"amount_deducted": 0,
"reason_code": "pre_arbitration",
"respond_by": 1590604200,
"status": "open",
"phase": "pre_arbitration",
"created_at": 1590059211,
"evidence": {
"amount": 10000,
"summary": "goods delivered",
"shipping_proof": null,
"billing_proof": null,
"cancellation_proof": null,
"customer_communication": null,
"proof_of_service": null,
"explanation_letter": null,
"refund_confirmation": null,
"access_activity_log": null,
"refund_cancellation_policy": null,
"term_and_conditions": null,
"others": null,
"submitted_at": null
}
}
```
-------------------------------------------------------------------------------------------------------

### Fetch a Dispute
Copy link
Contributor

@bhavyay bhavyay May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update the title for this section ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

### Accept a Dispute


```rb
disputeId = "disp_0000000000000"

Razorpay::Dispute.fetch(disputeId).accept()
```

**Parameters:**

| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| disputeId* | string | The unique identifier of the dispute. |

**Response:**
```json
{
"id": "disp_AHfqOvkldwsbqt",
"entity": "dispute",
"payment_id": "pay_EsyWjHrfzb59eR",
"amount": 10000,
"currency": "INR",
"amount_deducted": 10000,
"reason_code": "pre_arbitration",
"respond_by": 1590604200,
"status": "lost",
"phase": "pre_arbitration",
"created_at": 1590059211,
"evidence": {
"amount": 10000,
"summary": null,
"shipping_proof": null,
"billing_proof": null,
"cancellation_proof": null,
"customer_communication": null,
"proof_of_service": null,
"explanation_letter": null,
"refund_confirmation": null,
"access_activity_log": null,
"refund_cancellation_policy": null,
"term_and_conditions": null,
"others": null,
"submitted_at": null
}
}
```
-------------------------------------------------------------------------------------------------------
### Contest a Dispute

```rb
# Use this API sample code for draft

disputeId = "disp_0000000000000"

Razorpay::Dispute.fetch(disputeId).contest({
"amount": 5000,
"summary": "goods delivered",
"shipping_proof": [
"doc_EFtmUsbwpXwBH9",
"doc_EFtmUsbwpXwBH8"
],
"others": [
{
"type": "receipt_signed_by_customer",
"document_ids": [
"doc_EFtmUsbwpXwBH1",
"doc_EFtmUsbwpXwBH7"
]
}
],
"action": "draft"
})
```

**Parameters:**

| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format the table

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

| disputeId* | string | The unique identifier of the dispute. |
| amount | integer | The amount being contested. If the contest amount is not mentioned, we will assume it to be a full dispute contest. |
| summary | string | The explanation provided by you for contesting the dispute. It can have a maximum length of 1000 characters. |
| shipping_proof | array | List of document ids which serves as proof that the product was shipped to the customer at their provided address. It should show their complete shipping address, if possible. |
| others | array | All keys listed [here](https://razorpay.com/docs/api/disputes/contest) are supported |

```rb
# Use this API sample code for submit

Razorpay::Dispute.fetch(disputeId).contest({
"billing_proof": [
"doc_EFtmUsbwpXwBG9",
"doc_EFtmUsbwpXwBG8"
],
"action": "submit"
})
```

**Response:**
```json
// Draft
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear on why this is added. Can you add more details if this is a specific case of response

Copy link
Contributor Author

@ankitdas13 ankitdas13 May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separated both code snippets submit or draft

### Contest a Dispute (Draft)

### Contest a Dispute (Submit)

{
"id": "disp_AHfqOvkldwsbqt",
"entity": "dispute",
"payment_id": "pay_EsyWjHrfzb59eR",
"amount": 10000,
"currency": "INR",
"amount_deducted": 0,
"reason_code": "chargeback",
"respond_by": 1590604200,
"status": "open",
"phase": "chargeback",
"created_at": 1590059211,
"evidence": {
"amount": 5000,
"summary": "goods delivered",
"shipping_proof": [
"doc_EFtmUsbwpXwBH9",
"doc_EFtmUsbwpXwBH8"
],
"billing_proof": null,
"cancellation_proof": null,
"customer_communication": null,
"proof_of_service": null,
"explanation_letter": null,
"refund_confirmation": null,
"access_activity_log": null,
"refund_cancellation_policy": null,
"term_and_conditions": null,
"others": [
{
"type": "receipt_signed_by_customer",
"document_ids": [
"doc_EFtmUsbwpXwBH1",
"doc_EFtmUsbwpXwBH7"
]
}
],
"submitted_at": null
}
}

//Submit
{
"id": "disp_AHfqOvkldwsbqt",
"entity": "dispute",
"payment_id": "pay_EsyWjHrfzb59eR",
"amount": 10000,
"currency": "INR",
"amount_deducted": 0,
"reason_code": "chargeback",
"respond_by": 1590604200,
"status": "under_review",
"phase": "chargeback",
"created_at": 1590059211,
"evidence": {
"amount": 5000,
"summary": "goods delivered",
"shipping_proof": [
"doc_EFtmUsbwpXwBH9",
"doc_EFtmUsbwpXwBH8"
],
"billing_proof": [
"doc_EFtmUsbwpXwBG9",
"doc_EFtmUsbwpXwBG8"
],
"cancellation_proof": null,
"customer_communication": null,
"proof_of_service": null,
"explanation_letter": null,
"refund_confirmation": null,
"access_activity_log": null,
"refund_cancellation_policy": null,
"term_and_conditions": null,
"others": [
{
"type": "receipt_signed_by_customer",
"document_ids": [
"doc_EFtmUsbwpXwBH1",
"doc_EFtmUsbwpXwBH7"
]
}
],
"submitted_at": 1590603200
}
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/documents)**
1 change: 1 addition & 0 deletions lib/razorpay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
require 'razorpay/product'
require 'razorpay/stakeholder'
require 'razorpay/account'
require 'razorpay/dispute'
require 'razorpay/oauth_token'

# Base Razorpay module
Expand Down
26 changes: 26 additions & 0 deletions lib/razorpay/dispute.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'razorpay/request'
require 'razorpay/entity'

module Razorpay
class Dispute < Entity
def self.request
Razorpay::Request.new('disputes')
end

def self.fetch(id)
request.fetch id
end

def self.all(options = {})
request.all options
end

def accept(options={})
self.class.request.post "#{id}/accept", options
end

def contest(options)
self.class.request.patch "#{id}/contest", options
end
end
end
67 changes: 67 additions & 0 deletions test/fixtures/dispute_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"entity": "collection",
"count": 2,
"items": [
{
"id": "disp_Esz7KAitoYM7PJ",
"entity": "dispute",
"payment_id": "pay_EsyWjHrfzb59eR",
"amount": 10000,
"currency": "INR",
"amount_deducted": 0,
"reason_code": "pre_arbitration",
"respond_by": 1590604200,
"status": "open",
"phase": "pre_arbitration",
"created_at": 1590059211,
"evidence": {
"amount": 10000,
"summary": null,
"shipping_proof": null,
"billing_proof": null,
"cancellation_proof": null,
"customer_communication": null,
"proof_of_service": null,
"explanation_letter": null,
"refund_confirmation": null,
"access_activity_log": null,
"refund_cancellation_policy": null,
"term_and_conditions": null,
"others": null,
"submitted_at": null
}
},
{
"id": "disp_Esyvk3kZj0isXk",
"entity": "dispute",
"payment_id": "pay_EsyWjHrfzb59eR",
"amount": 5000,
"currency": "INR",
"amount_deducted": 0,
"reason_code": "warning_bulletin_or_exception_file",
"respond_by": 1590604200,
"status": "won",
"phase": "chargeback",
"created_at": 1590058554,
"evidence": {
"amount": 5000,
"summary": null,
"shipping_proof": [
"doc_EFtmUsbwpXwBH9",
"doc_EFtmUsbwpXwBH8"
],
"billing_proof": null,
"cancellation_proof": null,
"customer_communication": null,
"proof_of_service": null,
"explanation_letter": null,
"refund_confirmation": null,
"access_activity_log": null,
"refund_cancellation_policy": null,
"term_and_conditions": null,
"others": null,
"submitted_at": 1590604100
}
}
]
}
Loading
Loading