Skip to content

Commit

Permalink
Update account (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitdas13 authored Apr 1, 2024
1 parent 6522cdf commit 2598fda
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
57 changes: 57 additions & 0 deletions documents/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,63 @@ Account account = instance.account.fetch(accountId);

-------------------------------------------------------------------------------------------------------

### Upload account documents
```java
String accountId = "acc_M83Uw27KXuC7c8";

JSONObject request = new JSONObject();
request.put("files","/Users/your_name/Downloads/sample_uploaded.jpeg");
request.put("document_type","business_proof_url");

Account account = instance.account.uploadAccountDoc(accountId, request);
```

**Parameters:**

| Name | Type | Description |
|----------------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
| file* | string | The URL generated once the business proof document is uploaded. |
| document_type* | string | The documents valid for the proof type to be shared. Possible values : <br> business_proof_of_identification: `shop_establishment_certificate`, `gst_certificate`, `msme_certificate`, `business_proof_url`, `business_pan_url`, <br><br> additional_documents : `form_12_a_url`, `form_80g_url`, `cancelled_cheque` |

**Response:**
```json
{
"business_proof_of_identification": [
{
"type": "business_proof_url",
"url": "<https://rzp.io/i/bzDKbNg>"
}
]
}
```
-------------------------------------------------------------------------------------------------------

### Fetch account documents
```java
String accountId = "acc_LryDIBIjBDbOWy";

Account account = instance.account.fetchAccountDoc(accountId);
```

**Parameters:**

| Name | Type | Description |
|-------------|-------------|------------------------------------------------------------------------|
| accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |

**Response:**
```json
{
"business_proof_of_identification": [
{
"type": "business_proof_url",
"url": "<https://rzp.io/i/bzDKbNg>"
}
]
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/razorpay/AccountClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ public Account edit(String id, JSONObject request) throws RazorpayException {
public Account delete(String id) throws RazorpayException {
return delete(Constants.VERSION_V2, String.format(Constants.ACCOUNT_DELETE, id), null);
}

public Account uploadAccountDoc(String id, JSONObject request) throws RazorpayException {
return post(Constants.VERSION_V2, String.format(Constants.UPLOAD_ACCOUNT_DOCUMENT, id), request);
}
public Account fetchAccountDoc(String id) throws RazorpayException {
return get(Constants.VERSION_V2, String.format(Constants.UPLOAD_ACCOUNT_DOCUMENT, id), null);
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/razorpay/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ public class Constants {

static final String DOCUMENTS = "/documents";
static final String DOCUMENT_FETCH = "/documents/%s";

static final String UPLOAD_ACCOUNT_DOCUMENT = "accounts/%s/documents";
static final String UPLOAD_STAKEHOLDER_DOCUMENT = "accounts/%s/stakeholders/%s/documents";

static final String VIEW_RTO = "orders/%s/rto_review";
Expand Down
49 changes: 49 additions & 0 deletions src/test/java/com/razorpay/AccountClientTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.razorpay;

import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Test;
import org.mockito.InjectMocks;
Expand Down Expand Up @@ -230,4 +231,52 @@ private String getResponse(String account_id) {
" }\n" +
"}";
}

@Test
public void uploadAccountDoc() throws RazorpayException {
JSONObject request = new JSONObject();
request.put("files","/Users/your_name/Downloads/sample_uploaded.jpeg");
request.put("document_type","business_proof_url");

JSONObject mockedResponseJson = new JSONObject();
mockedResponseJson.put("entity","account");
JSONArray businessArray = new JSONArray();
JSONObject businessObj = new JSONObject();
businessObj.put("type","business_proof_url");
businessObj.put("url","<https://rzp.io/i/bzDKbNg>");
businessArray.put(businessObj);
mockedResponseJson.put("business_proof_of_identification",businessArray);

try {
mockResponseFromExternalClient(mockedResponseJson.toString());
mockResponseHTTPCodeFromExternalClient(200);
Account document = accountClient.uploadAccountDoc(ACCOUNT_ID, request);
assertNotNull(document);
assertEquals(true,document.has("business_proof_of_identification"));
} catch (IOException e) {
assertTrue(false);
}
}

@Test
public void fetchAccountDoc() throws RazorpayException {

JSONObject mockedResponseJson = new JSONObject();
mockedResponseJson.put("entity","account");
JSONArray businessArray = new JSONArray();
JSONObject businessObj = new JSONObject();
businessObj.put("type","business_proof_url");
businessObj.put("url","<https://rzp.io/i/bzDKbNg>");
businessArray.put(businessObj);
mockedResponseJson.put("business_proof_of_identification",businessArray);
try {
mockResponseFromExternalClient(mockedResponseJson.toString());
mockResponseHTTPCodeFromExternalClient(200);
Account document = accountClient.fetchAccountDoc(ACCOUNT_ID);
assertNotNull(document);
assertEquals(true,document.has("business_proof_of_identification"));
} catch (IOException e) {
assertTrue(false);
}
}
}

0 comments on commit 2598fda

Please sign in to comment.