Skip to content

Commit

Permalink
feat: Added Dispute entity (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitdas13 authored May 7, 2024
1 parent 4cd5602 commit f341db4
Show file tree
Hide file tree
Showing 6 changed files with 573 additions and 1 deletion.
241 changes: 241 additions & 0 deletions documents/disputes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
## Disputes

### Fetch All Disputes

```js
var options = {
count: 1
}

instance.disputes.all(options)
```

**Parameters:**

| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| count | integer | number of dispute to fetch (default: 10) |
| skip | integer | number of dispute to be skipped (default: 0) |

**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

```js
var disputeId = "disp_0000000000000";

instance.disputes.fetch(disputeId);
```

**Parameters:**

| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| id* | 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
}
}
```
-------------------------------------------------------------------------------------------------------

### Contest a Dispute

```js

//Use this API sample code for draft

var disputeId = "disp_0000000000000";

instance.disputes.contest(disputeId,{
"billing_proof": [
"doc_EFtmUsbwpXwBG9",
"doc_EFtmUsbwpXwBG8"
],
"action": "submit"
})


//Use this API sample code for submit

instance.disputes.contest(disputeId, {
"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"
})
```

**Response:**
```json

// Draft
{
"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)**
6 changes: 6 additions & 0 deletions lib/razorpay.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import webhooks from './types/webhooks'
import products from './types/products'
import tokens from './types/tokens'
import iins from './types/iins'
import disputes from './types/disputes'

interface IRazorpayConfig {
key_id: string;
Expand Down Expand Up @@ -144,6 +145,11 @@ declare class Razorpay {
* @see https://razorpay.com/docs/api/payments/cards/iin-api/#iin-entity
*/
iins: ReturnType<typeof iins>
/**
* Dispute Entity
* @see https://razorpay.com/docs/api/disputes
*/
disputes: ReturnType<typeof disputes>
}

export = Razorpay
3 changes: 2 additions & 1 deletion lib/razorpay.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class Razorpay {
fundAccount : require('./resources/fundAccount')(this.api),
items : require('./resources/items')(this.api),
cards : require('./resources/cards')(this.api),
webhooks : require('./resources/webhooks')(this.api)
webhooks : require('./resources/webhooks')(this.api),
disputes : require('./resources/disputes')(this.api)
})
}
}
Expand Down
43 changes: 43 additions & 0 deletions lib/resources/disputes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

module.exports = function (api) {

const BASE_URL = "/disputes";

return {

fetch(disputeId, callback) {
return api.get({
url: `${BASE_URL}/${disputeId}`,
}, callback);
},

all(params = {}, callback) {
let { count, skip } = params

count = Number(count) || 10
skip = Number(skip) || 0

return api.get({
url: `${BASE_URL}`,
data: {
count,
skip
}
}, callback)
},

accept(disputeId, callback) {
return api.post({
url: `${BASE_URL}/${disputeId}/accept`,
}, callback);
},

contest(disputeId, param, callback) {
return api.patch({
url: `${BASE_URL}/${disputeId}/contest`,
data: param
}, callback);
}
}
}
Loading

0 comments on commit f341db4

Please sign in to comment.