Skip to content

Commit

Permalink
Sdk update with test case and readme doc (#43)
Browse files Browse the repository at this point in the history
* Addon update with test case and readme doc

* Order update with readme doc

* Update paymentlink with test cases

* Change edit method name and doc correction of upi PL

* Few changes in addon readme

* changed order edit method name and doc correction

* Fix comment for update order

* Update subscription with unit test (#47)

* Update subscription with unit test

* Removed CreateRegistrationLink from subscription module

* Update item module with test case (#50)

* Update item module with test case

* Condition for null and empty array response

* Settlement module with test case (#51)

* Settlement module with test case

* Few changes according to review comments

* Fund account module with test case (#55)

* Fund account module with test case

* few changes according to review comments

* update customers with testcase (#44)

* update customers with testcase

* resolved pr comments

* added url escape

* json eol fixed

* fixed eol

* Update qrcode (#48)

* added qrcode with readme

* fix pr corrections

* fixed eol and remove extra space

* fixed eol

Co-authored-by: sonyy-m <[email protected]>

* Updated payment with unit test (#49)

* update payment & added readme

* fixed PR correction

* fixed eol in json

* fixed eol

* fix eol from json files

* added eol in fake_payment

* added eol in fake_payment

* update virtualaccount & readme (#52)

* update virtualaccount & readme

* update virtualaccount & readme

* code cleanup

* fixed eol json

* fixed eol

* readme corrections

Co-authored-by: sonyy-m <[email protected]>

* Update refund & readme (#53)

* add edit refund and readme

* fixed eol

* url escape & readme

* refund.md notes indentation

* update invoice and readme (#54)

* update invoice and readme

* comments correction

* update test function

* Add CreateRegistrationLink to invoice

Co-authored-by: mudududla.sony <[email protected]>
Co-authored-by: sonyy-m <[email protected]>

* Update request.go

* Update settlement.go

* Update virtualAccount.md

* Update readme (#56)

* Added readme documents for each module

* Update readme

* Updated CreateRegistrationLink api

* Update readme.md

* Update card.md

* Update Version (#57)

* Update Version

* Update CHANGELOG.md

Co-authored-by: ankitdas13 <[email protected]>
  • Loading branch information
sonyy-m and ankitdas13 authored Apr 29, 2022
1 parent 980e9c2 commit 937c0c5
Show file tree
Hide file tree
Showing 80 changed files with 11,542 additions and 82 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Changelog
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.0.0] - 2022-04-29

### Added

- QR code end point API
- Settlement end point API
- Fund Account end point API
- Item end point API
- New APIs for Invoices (Edit, Cancel, Issue, Delete, Send/resend)
- New API for Customers (Fetch all customers)
- New APIs for PaymentLinks (Cancel, Update, Send/Resend)
- New APIs for Subscriptions (Update, Pause, Resume, Cancel, Pending update, Delete offer)
- New API for Addons (Fetch all Addons)
- New API for Refund (Update refund)
- New APIs for Payments (Update, Create recurring, Create Json, Payment downtime details, refunds of a payment)
- New APIs for Virtual Account (Add receiver, add an allowed payer account, delete an allowed payer account)
- Updated Testcases
- Updated Readme

### Changed

- Request method of update order from `put` to `patch`
- Request method of update customer from `post` to `put`

## 0.1

### Added

- Initial Release
95 changes: 33 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Golang bindings for interacting with the Razorpay API

This is primarily meant for merchants who wish to perform interactions with the Razorpay API programatically

Read up here for getting started and understanding the payment flow with Razorpay: <https://docs.razorpay.com/docs/getting-started>

## Documentation

Documentation of Razorpay's API and their usage is available at <https://docs.razorpay.com>

## Usage
You need to setup your key and secret using the following:
You can find your API keys at <https://dashboard.razorpay.com/#/app/keys>.
Expand All @@ -19,65 +25,30 @@ client := razorpay.NewClient("<YOUR_API_KEY>", "<YOUR_API_SECRET>")

Note: All methods below return a `map[string]interface{}` and `error`. All methods accept an `extraHeaders` param of type `map[string]string`, allowing you to optinally set extra HTTP headers on the request.

### Payments

- Fetch all payments
```go
body, err := client.Payment.All(nil, nil)
```
- Fetch a particular payment
```go
body, err := client.Payment.Fetch("<payment_id>" , nil, nil)
```
- Capture a payment
```go
body, err := client.Payment.Capture("<payment_id>", <amount>, nil, nil)
```
Note: amount is in paisa
- Refund a payment
```go
body, err := client.Payment.Refund("<payment_id>", <amount_to_be_refunded>, nil, nil)
```

### Refunds
- Fetch all refunds
```go
body, err := client.Refund.All(nil, nil)
```
- Fetch a particular refund
```go
body, err := client.Refund.Fetch("<refund_id>", nil, nil)
```

### Orders
- Create a new order

```go
data := map[string]interface{}{
"amount": 1234,
"currency": "INR",
"receipt": "some_receipt_id",
"payment_capture": 1,
}
body, err := client.Order.Create(data, nil)
```
Note: data is a map and should contain these keys. See the [Orders entity reference](https://razorpay.com/docs/api/orders/#order-entity) for details on these keys.

amount : amount of order (in paisa)
currency : currency of order
receipt : receipt id of order
payment_capture : 1 if capture should be done automatically or else 0
notes(optional) : optional notes for order

- Fetch a particular order
```go
body, err := client.Order.Fetch("<order_id>", nil, nil)
```
- Fetch all orders
```go
body, err := client.Order.All(nil, nil)
```
- Fetch all payments for order
```go
body, err := client.Order.Payments("<order_id>", nil, nil)
```
## Supported Resources

- [Customer](documents/customers.md)
- [Token](documents/token.md)
- [Order](documents/order.md)
- [Payments](documents/payment.md)
- [Settlements](documents/settlement.md)
- [Refunds](documents/refund.md)
- [Invoice](documents/invoice.md)
- [Item](documents/item.md)
- [Plan](documents/plan.md)
- [Subscriptions](documents/subscription.md)
- [Add-on](documents/addon.md)
- [Payment Links](documents/paymentLink.md)
- [Smart Collect](documents/virtualAccount.md)
- [Route](documents/transfer.md)
- [QR Code](documents/qrcode.md)
- [Emandate](documents/emandate.md)
- [Cards](documents/card.md)
- [Paper NACH](documents/papernach.md)
- [UPI](documents/upi.md)
- [Register Emandate and Charge First Payment Together](documents/registerEmandate.md)
- [Register NACH and Charge First Payment Together](documents/registerNach.md)

## License

The Razorpay Go SDK is released under the MIT License. See [LICENSE](LICENSE) file for more details.
12 changes: 12 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ type Client struct {
Token *resources.Token
Transfer *resources.Transfer
VirtualAccount *resources.VirtualAccount
QrCode *resources.QrCode
FundAccount *resources.FundAccount
Settlement *resources.Settlement
Item *resources.Item
}

// NewClient creates and returns a new Razorpay client. key and secret
Expand All @@ -51,6 +55,10 @@ func NewClient(key string, secret string) *Client {
token := resources.Token{Request: Request}
transfer := resources.Transfer{Request: Request}
va := resources.VirtualAccount{Request: Request}
qrCode := resources.QrCode{Request: Request}
fundAccount := resources.FundAccount{Request: Request}
settlement := resources.Settlement{Request: Request}
item := resources.Item{Request: Request}
client := Client{
Addon: &addon,
Card: &card,
Expand All @@ -65,6 +73,10 @@ func NewClient(key string, secret string) *Client {
Token: &token,
Transfer: &transfer,
VirtualAccount: &va,
QrCode: &qrCode,
FundAccount: &fundAccount,
Settlement: &settlement,
Item: &item,
}
return &client
}
Expand Down
8 changes: 8 additions & 0 deletions constants/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ const (
SUBSCRIPTION_URL = "/subscriptions"
//PLAN_URL ... plan api base path
PLAN_URL = "/plans"
//QRCODE_URL ... qrcode api base path
QRCODE_URL = "/payments/qr_codes"
//FUND_ACCOUNT_URL ... fund account api base path
FUND_ACCOUNT_URL = "/fund_accounts"
//SETTLEMENT_URL ... settlements api base path
SETTLEMENT_URL = "/settlements"
//ITEM_URL ... item api base path
ITEM_URL = "/items"
)
180 changes: 180 additions & 0 deletions documents/addon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
## Addons

### Create an addon

```go
subscriptionId := "sub_00000000000001"
data := map[string]interface{}{
"item": map[string]interface{}{
"name":"Extra appala (papadum)",
"amount":3000,
"currency":"INR",
"description":"1 extra oil fried appala with meals",
},
"quantity":2,
}
body, err := client.Subscription.CreateAddon(subscriptionId, data, nil)
```

**Parameters:**

| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| subscriptionId* | string | The subscription ID to which the add-on is being added. |
| items* | object | Details of the add-on you want to create. |
| quantity | integer | This specifies the number of units of the add-on to be charged to the customer. Defaults to 1 |

**Response:**
```json
{
"id":"ao_00000000000001",
"entity":"addon",
"item":{
"id":"item_00000000000001",
"active":true,
"name":"Extra appala (papadum)",
"description":"1 extra oil fried appala with meals",
"amount":30000,
"unit_amount":30000,
"currency":"INR",
"type":"addon",
"unit":null,
"tax_inclusive":false,
"hsn_code":null,
"sac_code":null,
"tax_rate":null,
"tax_id":null,
"tax_group_id":null,
"created_at":1581597318,
"updated_at":1581597318
},
"quantity":2,
"created_at":1581597318,
"subscription_id":"sub_00000000000001",
"invoice_id":null
}
```
-------------------------------------------------------------------------------------------------------

### Fetch all addons

```go
options := map[string]interface{}{
"count": 1,
}
body, err := client.Addon.All(options, nil)
```

**Parameters:**

| Name | Type | Description |
|-------|-----------|--------------------------------------------------|
| from | timestamp | timestamp after which the payments were created |
| to | timestamp | timestamp before which the payments were created |
| count | integer | number of payments to fetch (default: 10) |
| skip | integer | number of payments to be skipped (default: 0) |

**Response:**
```json
{
"entity": "collection",
"count": 1,
"items": [
{
"id": "ao_00000000000002",
"entity": "addon",
"item": {
"id": "item_00000000000002",
"active": true,
"name": "Extra sweet",
"description": "1 extra sweet of the day with meals",
"amount": 90000,
"unit_amount": 90000,
"currency": "INR",
"type": "addon",
"unit": null,
"tax_inclusive": false,
"hsn_code": null,
"sac_code": null,
"tax_rate": null,
"tax_id": null,
"tax_group_id": null,
"created_at": 1581597318,
"updated_at": 1581597318
},
"quantity": 1,
"created_at": 1581597318,
"subscription_id": "sub_00000000000001",
"invoice_id": "inv_00000000000001"
}
]
}
```
-------------------------------------------------------------------------------------------------------

### Fetch an addon

```go
addonId := "ao_00000000000001"
body, err := client.Addon.Fetch(addonId, nil, nil)
```

**Parameters:**

| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| addonId* | string | addon id to be fetched |
**Response:**
```json
{
"id":"ao_00000000000001",
"entity":"addon",
"item":{
"id":"item_00000000000001",
"active":true,
"name":"Extra appala (papadum)",
"description":"1 extra oil fried appala with meals",
"amount":30000,
"unit_amount":30000,
"currency":"INR",
"type":"addon",
"unit":null,
"tax_inclusive":false,
"hsn_code":null,
"sac_code":null,
"tax_rate":null,
"tax_id":null,
"tax_group_id":null,
"created_at":1581597318,
"updated_at":1581597318
},
"quantity":2,
"created_at":1581597318,
"subscription_id":"sub_00000000000001",
"invoice_id":null
}
```
-------------------------------------------------------------------------------------------------------

### Delete an addon

```go
body, err := client.Addon.Delete(addonId, nil, nil)
```

**Parameters:**

| Name | Type | Description |
|-----------------|---------|------------------------------------------------------------------------------|
| addonId* | string | addon id to be deleted |

**Response:**
```json
[]
```
-------------------------------------------------------------------------------------------------------

**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/subscriptions/#add-ons)**
Loading

0 comments on commit 937c0c5

Please sign in to comment.