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

Commit

Permalink
Check for valid razorpay status in case where transaction has been ap…
Browse files Browse the repository at this point in the history
…proved by the reviewer but valid is still false

#24
  • Loading branch information
notdrone committed Apr 12, 2018
1 parent 3c49b0d commit 9034f08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/api/transaction-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export enum transactionActionEnum {
}

export enum nodalStatusEnum {
internalError = -2,
noop = -1,
notInitiated = 0,
initiates = 1,
Expand Down Expand Up @@ -110,7 +111,7 @@ export const getAllTransactionsAPI = (
mode: _.transaction_mode,
nodal: {
id: getNodalId(_),
status: getNodalStatus(_),
status: getNodalStatus(_, _.action_status),
},
transactionDetails: _.eko_transactions.map(($: any) => ({
amount: $.amount,
Expand All @@ -126,10 +127,16 @@ export const getAllTransactionsAPI = (
.catch(() => [])
}

const getNodalStatus = (_: any) => {
const getNodalStatus = (_: any, actionStatus: transactionActionEnum) => {
if (_.razorpay_payment_status.Valid) {
return _.razorpay_payment_status.Int64 as nodalStatusEnum
}
if (
!_.razorpay_payment_status.Valid &&
actionStatus === transactionActionEnum.approve
) {
return nodalStatusEnum.internalError
}
return nodalStatusEnum.noop
}

Expand Down
1 change: 1 addition & 0 deletions src/helpers/color-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const getNodalTransactionColor = (status: nodalStatusEnum): string => {
return positiveGreen
case nodalStatusEnum.dispute:
case nodalStatusEnum.failed:
case nodalStatusEnum.internalError:
return alertRed
case nodalStatusEnum.authorized:
return identity
Expand Down

0 comments on commit 9034f08

Please sign in to comment.