Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beasy-mobile
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
G
beasy-mobile
Commits
fc9ba58f
Commit
fc9ba58f
authored
Sep 06, 2024
by
G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use of switch case for better flow
parent
cdf2a4fb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
orangePayment.ts
src/utils/requests/orangePayment.ts
+15
-4
No files found.
src/utils/requests/orangePayment.ts
View file @
fc9ba58f
...
...
@@ -74,20 +74,31 @@ export const getTransactionStatus = async (orderId: string) => {
});
log
.
http
(
"getTransactionStatus |"
,
JSON
.
stringify
(
response
,
null
,
2
));
if
(
response
.
status
===
"INITIATED"
)
{
switch
(
response
.
status
)
{
case
"SUCCESS"
:
{
log
.
http
(
"getTransactionStatus |"
,
JSON
.
stringify
(
response
,
null
,
2
));
return
response
;
}
case
"INITIATED"
:
{
log
.
warn
(
"Payment is still in progress, throwing error for mutation to catch"
);
const
error
=
new
Error
(
"Payment is still in progress"
);
error
.
name
=
"ORANGE_PAYMENT_IN_PROGRESS"
;
throw
error
;
}
if
(
response
.
status
===
"FAILED"
)
{
case
"FAILED"
:
{
log
.
warn
(
"Payment failed, throwing error for mutation to catch"
);
const
error
=
new
Error
(
"Payment failed"
);
error
.
name
=
"ORANGE_PAYMENT_FAILED"
;
throw
error
;
}
log
.
http
(
"getTransactionStatus |"
,
JSON
.
stringify
(
response
,
null
,
2
));
return
response
;
default
:
{
log
.
warn
(
"An unknown error occured, throwing error for mutation to catch"
);
const
error
=
new
Error
(
"Payment failed"
);
error
.
name
=
"UNKNOWN_PAYMENT_ERROR"
;
throw
error
;
}
}
}
catch
(
error
)
{
log
.
error
(
"getTransactionStatus |"
,
error
);
throw
error
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment