-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
829f1f4
commit d7f0aeb
Showing
6 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
## Document | ||
|
||
### Create a Document | ||
|
||
```rb | ||
Razorpay::Document.create({ | ||
"file": File.new("/Users/your_name/Downloads/sample_uploaded.jpeg"), | ||
"purpose": "dispute_evidence" | ||
}); | ||
``` | ||
|
||
**Parameters:** | ||
|
||
| Name | Type | Description | | ||
|---------|-----------|-----------------------------------------------------------------| | ||
| file* | string | The URL generated once the business proof document is uploaded. | | ||
| purpose | string | Possible value is `dispute_evidence` | | ||
|
||
**Response:** | ||
```json | ||
{ | ||
"id": "doc_EsyWjHrfzb59Re", | ||
"entity": "document", | ||
"purpose": "dispute_evidence", | ||
"name": "doc_19_12_2020.jpg", | ||
"mime_type": "image/png", | ||
"size": 2863, | ||
"created_at": 1590604200 | ||
} | ||
``` | ||
------------------------------------------------------------------------------------------------------- | ||
|
||
### Fetch Document Information | ||
|
||
```rb | ||
documentId = "doc_NiyXWXXXXXXXXX" | ||
|
||
Razorpay::Document.fetch(documentId) | ||
``` | ||
|
||
**Parameters:** | ||
|
||
| Name | Type | Description | | ||
|-------------|-----------|--------------------------------------------------| | ||
| documentId | string | The unique identifier of the document. | | ||
|
||
**Response:** | ||
```json | ||
{ | ||
"entity": "document", | ||
"id": "doc_00000000000000", | ||
"purpose": "dispute_evidence", | ||
"created_at": 1701701378, | ||
"mime_type": "application/pdf", | ||
"display_name": "ppm_00000000000000", | ||
"size": 404678, | ||
"url": "" | ||
} | ||
``` | ||
------------------------------------------------------------------------------------------------------- | ||
|
||
**PN: * indicates mandatory fields** | ||
<br> | ||
<br> | ||
**For reference click [here](https://razorpay.com/docs/api/documents)** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'razorpay/request' | ||
require 'razorpay/entity' | ||
|
||
module Razorpay | ||
# Document API allows you to create and fetch document on Razorpay | ||
class Document < Entity | ||
def self.request | ||
Razorpay::Request.new('documents') | ||
end | ||
|
||
def self.create(options) | ||
request.create options | ||
end | ||
|
||
def self.fetch(id) | ||
request.fetch id | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"error": { | ||
"code": "BAD_REQUEST_ERROR", | ||
"description": "Invalid file id provided or merchant is unauthorized to access the fileId(s) provided", | ||
"source": "NA", | ||
"step": "NA", | ||
"reason": "NA", | ||
"metadata": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"entity": "document", | ||
"id": "doc_O4KANwWi2kHGiV", | ||
"purpose": "dispute_evidence", | ||
"created_at": 1714368859, | ||
"mime_type": "image/jpeg", | ||
"display_name": "Screenshot 2022-09-12 at 5.48.23 PM", | ||
"size": 334201 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'test_helper' | ||
|
||
module Razorpay | ||
# Tests for Razorpay::Document | ||
class RazorpayDocumentTest < Minitest::Test | ||
def setup | ||
@document_id = 'doc_O4KCaSbX4BjA6I' | ||
# Any request that ends with document/document_id | ||
stub_get(%r{documents/#{@document_id}$}, 'fake_document') | ||
end | ||
|
||
def test_document_should_be_defined | ||
refute_nil Razorpay::Document | ||
end | ||
|
||
def test_document_should_be_defined_exception | ||
para_attr = {} | ||
stub_get(%r{documents/#{@document_id}$}, 'document_error') | ||
assert_raises(Razorpay::Error) do | ||
document = Razorpay::Document.fetch(@document_id) | ||
if document.error | ||
raise Razorpay::Error.new, document.error['code'] | ||
end | ||
end | ||
end | ||
end | ||
end |