Skip to content
This repository has been archived by the owner on Oct 29, 2018. It is now read-only.

Commit

Permalink
Add nodal object in transaction-api
Browse files Browse the repository at this point in the history
  • Loading branch information
notdrone committed Apr 12, 2018
1 parent 4497903 commit 1cadfbe
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/api/transaction-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export enum transactionType {
}

export enum transactionMode {
cash = 'CASH',
neft = 'NEFT',
imps = 'IMPS',
}

export enum splitTransactionStatus {
Expand All @@ -32,6 +33,16 @@ export enum transactionActionEnum {
reject = 3,
}

export enum nodalStatusEnum {
noop = -1,
notInitiated = 0,
initiates = 1,
authorized = 2,
failed = 3,
captureSuccess = 4,
dispute = 5,
}

export interface ISplitTransaction {
id: string
amount: number
Expand All @@ -58,6 +69,10 @@ export interface ITransaction {
createdTimestamp: string
updatedTimestamp: string
transactionDetails?: ISplitTransaction[]
nodal: {
id: string
status: nodalStatusEnum
}
}

const getAllTransactionsFormData = (limit: number, offset: number) => {
Expand All @@ -66,6 +81,9 @@ const getAllTransactionsFormData = (limit: number, offset: number) => {
data.append('offset', `${offset}`)
return data
}

const getNodalId = (_: any) => _.razorpay_payment_id.String

export const getAllTransactionsAPI = (
limit: number = 1000,
offset: number = 0,
Expand All @@ -88,6 +106,10 @@ export const getAllTransactionsAPI = (
},
id: _.transaction_id,
mode: _.transaction_mode,
nodal: {
id: getNodalId(_),
status: getNodalStatus(_),
},
transactionDetails: _.eko_transactions.map(($: any) => ({
amount: $.amount,
createdTimestamp: $.created_at,
Expand All @@ -102,6 +124,13 @@ export const getAllTransactionsAPI = (
.catch(() => [])
}

const getNodalStatus = (_: any) => {
if (_.razorpay_payment_status.Valid) {
return _.razorpay_payment_status.Int64 as nodalStatusEnum
}
return nodalStatusEnum.noop
}

const transactionActionFormData = (
transactionId: string,
action: transactionActionEnum,
Expand Down

0 comments on commit 1cadfbe

Please sign in to comment.