Skip to content

Commit

Permalink
add doc for generic (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitdas13 authored Dec 14, 2023
1 parent d23dce0 commit 0b17117
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 3 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.0] - 2023-12-14
feat: Added generic access point

## [1.2.0] - 2023-07-20

### Added
feat: Added new API endpoints

- Added account onboarding API Create, Fetch, Edit, Delete
- Added account on boarding API Create, Fetch, Edit, Delete
- Added stakeholders API Create, Fetch, All, Edit
- Added product configuration API RequestProductConfiguration, Fetch, Edit, FetchTnc
- Added webhooks API Create, Fetch, All, Edit, Delete
Expand All @@ -20,7 +23,7 @@ feat: Added new API endpoints

### Added
- Added Third party validation & Otp API for Payment (CreateUpi, ValidateVpa, OtpGenerate, OtpSubmit, OtpResend)
- Update Documention
- Update Documentation

## [1.0.0] - 2022-04-29

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Note: All methods below return a `map[string]interface{}` and `error`. All metho
- [Register NACH and Charge First Payment Together](documents/registerNach.md)
- [Token](documents/token.md)
- [Webhook](documents/webhook.md)
- [Generic](documents/generic.md)

## License

Expand Down
152 changes: 152 additions & 0 deletions documents/generic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
## Generic Access Point


```go
client := razorpay.NewClient("key", "secret")
```

### Method Signature
```go
body, err := client.Entity.Do(url, method, data, headers)
```

**Parameters:**

| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| url* | string | The endpoint to which the request will be made. This should include the version information (e.g., "v1/contacts" or "v2/accounts") |
| method* | string | The HTTP method for the request (e.g., 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'). |
| data | object | The data to be sent with the request.|
| headers | object | The headers to be included in the request. |

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

### Create a contacts using POST

```go

data := map[string]interface{}{
"name": "Gaurav Kumar",
"email": "[email protected]",
"contact": "9123456789",
"type": "employee",
"reference_id":"Acme Contact ID 12345",
"notes": map[string]interface{}{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf.",
},
}

body, err := client.Entity.Do("v1/contacts", http.MethodPost, data, nil)
```

**Response:**

```json
{
"id": "cont_00000000000001",
"entity": "contact",
"name": "Gaurav Kumar",
"contact": "9123456789",
"email": "[email protected]",
"type": "employee",
"reference_id": "Acme Contact ID 12345",
"batch_id": null,
"active": true,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1545320320
}
```

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

### Fetch an order using GET

```go

body, err := client.Entity.Do("v1/orders/order_00000000000001", http.MethodGet, nil, nil)
```

**Response:**

```json
{
"amount": 307,
"amount_due": 0,
"amount_paid": 307,
"attempts": 1,
"created_at": 1695625101,
"currency": "INR",
"entity": "order",
"id": "order_00000000000001",
"notes": [],
"offer_id": null,
"receipt": "851617",
"status": "paid"
}
```

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

### Fetch payments of a linked account using headers

```go
headers := map[string]string{
"X-Razorpay-Account": "acc_00000000000001",
}

body, _ := client.Entity.Do("v1/payments/pay_00000000000001", http.MethodGet, nil, headers)
```

**Response:**

```json
{
"entity": "collection",
"count": 2,
"items": [
{
"id": "pay_00000000000001",
"entity": "payment",
"amount": 10000,
"currency": "INR",
"status": "captured",
"order_id": "order_00000000000001",
"invoice_id": null,
"international": false,
"method": "netbanking",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": "#JJCqaOhFihfkVE",
"card_id": null,
"bank": "YESB",
"wallet": null,
"vpa": null,
"email": "[email protected]",
"contact": "9999999999",
"notes": [],
"fee": 236,
"tax": 36,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"bank_transaction_id": "2118867"
},
"created_at": 1649932775
}
]
}
```

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

**PN: * indicates mandatory fields**
<br>
<br>
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ package razorpay
const SDKName = "razorpay-go"

//SDKVersion ...
const SDKVersion = "1.2.0"
const SDKVersion = "1.3.0"

0 comments on commit 0b17117

Please sign in to comment.