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

Update account #317

Merged
merged 6 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
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.pdf");

Choose a reason for hiding this comment

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

please use relative URL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

placed official doc url

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 @@ -173,4 +173,6 @@ public class Constants {
static final String DOCUMENTS = "/documents";

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

static final String UPLOAD_ACCOUNT_DOCUMENT = "accounts/%s/documents";
}
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.pdf");
rohitcbr marked this conversation as resolved.
Show resolved Hide resolved
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);
}
}
}
Loading