Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Owo Sugiana
/
iso8583-web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0e84e6a6
authored
Apr 25, 2020
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
web-client.py ada opsi --bit
1 parent
c17027df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
4 deletions
contrib/web-client.py
contrib/web-client.py
View file @
0e84e6a
...
...
@@ -17,6 +17,18 @@ durations = {}
json_responses
=
{}
def
error
(
s
):
print
(
'ERROR: {}'
.
format
(
s
))
sys
.
exit
()
def
required
(
name
,
default
=
None
):
value
=
getattr
(
option
,
name
)
if
not
value
and
not
default
:
error
(
'--{} harus diisi'
.
format
(
name
))
p
[
name
]
=
value
or
default
def
create_thread
(
func
,
args
=
[]):
thread
=
Thread
(
target
=
func
,
args
=
args
)
# Exit the server thread when the main thread terminates
...
...
@@ -55,7 +67,10 @@ help_host = 'default ' + default_host
help_count
=
'default {}'
.
format
(
default_count
)
help_method
=
'default '
+
default_method
help_invoice_id
=
'dibutuhkan saat --method inquiry, payment, atau reversal'
help_amount
=
'dibutuhkan saat --method=payment'
help_amount
=
'dibutuhkan saat --method payment dan reversal'
help_ntb
=
'dibutuhkan saat --method payment dan reversal'
help_stan
=
'dibutuhkan saat --method payment dan reversal'
help_bit
=
'bit tambahan, contoh: --bit=42:TOKOPEDIA'
parser
=
OptionParser
()
parser
.
add_option
(
''
,
'--url'
,
default
=
default_url
,
help
=
help_url
)
...
...
@@ -65,6 +80,9 @@ parser.add_option(
parser
.
add_option
(
''
,
'--method'
,
default
=
default_method
,
help
=
help_method
)
parser
.
add_option
(
''
,
'--invoice-id'
,
help
=
help_invoice_id
)
parser
.
add_option
(
''
,
'--amount'
,
type
=
int
,
help
=
help_amount
)
parser
.
add_option
(
''
,
'--ntb'
,
help
=
help_ntb
)
parser
.
add_option
(
''
,
'--stan'
,
help
=
help_stan
)
parser
.
add_option
(
''
,
'--bit'
,
help
=
help_bit
)
option
,
args
=
parser
.
parse_args
(
sys
.
argv
[
1
:])
url
=
option
.
url
...
...
@@ -72,9 +90,20 @@ count = option.count
p
=
dict
(
host
=
option
.
host
)
if
option
.
method
!=
'echo'
:
p
[
'invoice_id'
]
=
option
.
invoice_id
if
option
.
method
==
'payment'
:
p
[
'amount'
]
=
option
.
amount
p
[
'ntb'
]
=
datetime
.
now
()
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
m
%
s'
)
if
option
.
method
in
(
'payment'
,
'reversal'
):
required
(
'amount'
)
if
option
.
method
==
'payment'
:
required
(
'ntb'
,
datetime
.
now
()
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
m
%
s'
))
required
(
'stan'
,
datetime
.
now
()
.
strftime
(
'
%
H
%
M
%
S'
))
else
:
required
(
'ntb'
)
required
(
'stan'
)
if
option
.
bit
:
bits
=
dict
()
for
t
in
option
.
bit
.
split
(
','
):
bit
,
value
=
t
.
split
(
':'
)
bits
[
bit
]
=
value
p
[
'bits'
]
=
bits
data
=
dict
(
method
=
option
.
method
,
params
=
[
p
],
jsonrpc
=
'2.0'
)
for
i
in
range
(
count
):
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment