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

Add Payouts, Payout Links and transactions #184

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions src/main/java/com/razorpay/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,17 @@ public class Constants {
static final String VIRTUAL_ACCOUNT_RECEIVERS = "virtual_accounts/%s/receivers";
static final String VIRTUAL_ACCOUNT_ALLOWEDPAYERS = "virtual_accounts/%s/allowed_payers";
static final String VIRTUAL_ACCOUNT_DELETE_ALLOWEDPAYERS = "virtual_accounts/%s/allowed_payers/%s";

static final String PAYOUT_CREATE = "payouts";
static final String PAYOUT_FETCH = "payouts/%s";
static final String PAYOUT_FETCH_ALL = "payouts";
static final String PAYOUT_CANCEL_QUEUED = "payouts/%s";

static final String PAYOUT_LINK_CREATE = "payouts-links";
static final String PAYOUT_LINK_FETCH = "payouts-links/%s";
static final String PAYOUT_LINK_FETCH_ALL = "payouts-links";
static final String PAYOUT_LINK_CANCEL = "payouts-links/%s";

static final String TRANSACTIONS_FETCH = "transactions/%s";
static final String TRANSACTIONS_FETCH_ALL = "transactions";
}
10 changes: 10 additions & 0 deletions src/main/java/com/razorpay/Payout.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.razorpay;

import org.json.JSONObject;

public class Payout extends Entity {

public Payout(JSONObject jsonObject) {
super(jsonObject);
}
}
41 changes: 41 additions & 0 deletions src/main/java/com/razorpay/PayoutClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.razorpay;

import java.util.List;

import org.json.JSONObject;

public class PayoutClient extends ApiClient {

PayoutClient(String auth) {
super(auth);
}

public Payout create(JSONObject request) throws RazorpayException {
return post(Constants.PAYOUT_CREATE, request);
}

public Payout fetch(String id) throws RazorpayException {
return get(String.format(Constants.PAYOUT_FETCH, id), null);
}

public Payout cancel(String id, JSONObject request) throws RazorpayException {
return post(String.format(Constants.PAYOUT_CANCEL_QUEUED, id), request);
}

/**
* It is wrapper of fetchAll with parameter here sending null defines fetchAll
* with a default values without filteration
* @throws RazorpayException
*/
public List<Payout> fetchAll() throws RazorpayException {
return fetchAll(null);
}

/**
* This method get list of payouts filtered by parameters @request
* @throws RazorpayException
*/
public List<Payout> fetchAll(JSONObject request) throws RazorpayException {
return getCollection(Constants.PAYOUT_FETCH_ALL, request);
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/razorpay/PayoutLink.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.razorpay;

import org.json.JSONObject;

public class PayoutLink extends Entity{

public PayoutLink(JSONObject jsonObject) {
super(jsonObject);
}
}
41 changes: 41 additions & 0 deletions src/main/java/com/razorpay/PayoutLinkClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.razorpay;

import org.json.JSONObject;

import java.util.List;

public class PayoutLinkClient extends ApiClient {

PayoutLinkClient(String auth) {
super(auth);
}

public PayoutLink create(JSONObject request) throws RazorpayException {
return post(Constants.PAYOUT_LINK_CREATE, request);
}

public PayoutLink fetch(String id) throws RazorpayException {
return get(String.format(Constants.PAYOUT_LINK_FETCH, id), null);
}

public PayoutLink cancel(String id, JSONObject request) throws RazorpayException {
return post(String.format(Constants.PAYOUT_LINK_CANCEL, id), request);
}

/**
* It is wrapper of fetchAll with parameter here sending null defines fetchAll
* with a default values without filteration
* @throws RazorpayException
*/
public List<PayoutLink> fetchAll() throws RazorpayException {
return fetchAll(null);
}

/**
* This method get list of payout link filtered by parameters @request
* @throws RazorpayException
*/
public List<PayoutLink> fetchAll(JSONObject request) throws RazorpayException {
return getCollection(Constants.PAYOUT_LINK_FETCH_ALL, request);
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/razorpay/RazorpayClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class RazorpayClient {
public ItemClient items;
public FundAccountClient fundAccount;
public VirtualAccountClient virtualAccounts;
public PayoutClient payouts;
public PayoutLinkClient payoutLinks;
public TransactionsClient transactions;

public RazorpayClient(String key, String secret) throws RazorpayException {
this(key, secret, false);
Expand All @@ -46,6 +49,9 @@ public RazorpayClient(String key, String secret, Boolean enableLogging) throws R
items = new ItemClient(auth);
fundAccount = new FundAccountClient(auth);
virtualAccounts = new VirtualAccountClient(auth);
payouts = new PayoutClient(auth);
payoutLinks = new PayoutLinkClient(auth);
transactions = new TransactionsClient(auth);
}

public RazorpayClient addHeaders(Map<String, String> headers) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/razorpay/Transactions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.razorpay;

import org.json.JSONObject;

public class Transactions extends Entity {

public Transactions(JSONObject jsonObject) {
super(jsonObject);
}
}
33 changes: 33 additions & 0 deletions src/main/java/com/razorpay/TransactionsClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.razorpay;

import org.json.JSONObject;

import java.util.List;

public class TransactionsClient extends ApiClient {

TransactionsClient(String auth) {
super(auth);
}

public PayoutLink fetch(String id) throws RazorpayException {
return get(String.format(Constants.TRANSACTIONS_FETCH, id), null);
}

/**
* It is wrapper of fetchAll with parameter here sending null defines fetchAll
* with a default values without filteration
* @throws RazorpayException
*/
public List<Transactions> fetchAll() throws RazorpayException {
return fetchAll(null);
}

/**
* This method get list of transactions filtered by parameters @request
* @throws RazorpayException
*/
public List<Transactions> fetchAll(JSONObject request) throws RazorpayException {
return getCollection(Constants.TRANSACTIONS_FETCH_ALL, request);
}
}