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
67504954
Commit
67504954
authored
Jun 18, 2024
by
G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic implementation of wave payment workflow
parent
0db3e2e3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
0 deletions
+92
-0
wavePayment.ts
src/utils/requests/wavePayment.ts
+92
-0
No files found.
src/utils/requests/wavePayment.ts
0 → 100644
View file @
67504954
import
{
LOG
}
from
"@logger"
;
import
base64
from
"react-native-base64"
;
import
axiosRequest
from
"../axios-request"
;
const
log
=
LOG
.
extend
(
"wavePayment"
);
export
interface
IwavePaymentStarter
{
// biome-ignore lint/style/useNamingConvention: <API requirement>
type_paiement
:
2
;
// id 2 is for wave.
marchand
:
string
;
service
:
string
;
montant
:
number
;
}
export
interface
IwaveStarterRespone
{
id
:
string
;
amount
:
string
;
// biome-ignore lint/style/useNamingConvention: <api response>
checkout_status
:
string
;
// biome-ignore lint/style/useNamingConvention: <api response>
client_reference
:
unknown
;
currenfy
:
string
;
// biome-ignore lint/style/useNamingConvention: <api response>
error_url
:
string
;
// biome-ignore lint/style/useNamingConvention: <api response>
last_payment_errror
:
unknown
;
// biome-ignore lint/style/useNamingConvention: <api response>
business_name
:
string
;
// biome-ignore lint/style/useNamingConvention: <api response>
payment_status
:
string
;
// biome-ignore lint/style/useNamingConvention: <api response>
succes_url
:
string
;
// biome-ignore lint/style/useNamingConvention: <api response>
wave_launch_url
:
string
;
// biome-ignore lint/style/useNamingConvention: <api response>
when_completed
:
unknown
;
// biome-ignore lint/style/useNamingConvention: <api response>
when_created
:
string
;
// biome-ignore lint/style/useNamingConvention: <api response>
when_expires
:
string
;
}
export
interface
IwaveStatusResponse
{
status
:
string
;
code
:
number
;
message
:
IwaveStarterRespone
;
}
const
basictoken
=
base64
.
encode
(
"admin:admin"
);
export
const
initTransaction
=
async
(
payload
:
IwavePaymentStarter
)
=>
{
log
.
http
(
"initTransaction"
,
payload
);
// const basictoken = base64.encode("admin:admin");
try
{
const
response
=
await
axiosRequest
<
IwaveStarterRespone
>
({
url
:
"/transactions/"
,
method
:
"POST"
,
headers
:
{
// biome-ignore lint/style/useNamingConvention: <explanation>
Authorization
:
`Basic
${
basictoken
}
`
,
},
data
:
payload
,
});
log
.
http
(
"initTransaction |"
,
JSON
.
stringify
(
response
,
null
,
2
));
return
response
;
}
catch
(
error
)
{
log
.
error
(
"getTransactionStatus |"
,
error
);
throw
error
;
}
};
export
const
getTransactionStatus
=
async
(
id
:
string
)
=>
{
log
.
http
(
"getTransactionStatus"
,
id
);
// const basictoken = base64.encode("admin:admin");
try
{
const
response
=
await
axiosRequest
<
IwaveStarterRespone
>
({
url
:
`/wave-session/
${
id
}
`
,
headers
:
{
// biome-ignore lint/style/useNamingConvention: <explanation>
Authorization
:
`Basic
${
basictoken
}
`
,
},
});
log
.
http
(
"getTransactionStatus |"
,
JSON
.
stringify
(
response
,
null
,
2
));
return
response
;
}
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