Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Surya Bintara
Cleon Mobile Front End
Commits
6b18238b
Commit
6b18238b
authored
2 years ago
by
Surya B
Browse files
Options
Download
Email Patches
Plain Diff
mengupdate metode pembayaran
parent
15011b20
master
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
assets/logo/qris.png
+0
-0
assets/logo/qris.png
lib/api/api_services.dart
+23
-10
lib/api/api_services.dart
lib/views/shop/pembayaran.dart
+6
-43
lib/views/shop/pembayaran.dart
with
29 additions
and
53 deletions
+29
-53
assets/logo/qris.png
0 → 100644
View file @
6b18238b
2.04 KB
This diff is collapsed.
Click to expand it.
lib/api/api_services.dart
View file @
6b18238b
...
...
@@ -53,24 +53,20 @@ class ApiServices {
}
}
Future
<
String
>
pembayaran
(
String
pembayaran
,
int
harga
,
int
idPaket
)
async
{
late
String
result
;
Future
<
void
>
pembayaran
(
String
pembayaran
,
int
harga
,
int
idPaket
)
async
{
switch
(
pembayaran
)
{
case
'gopay'
:
result
=
await
gopay
(
harga
,
idPaket
);
await
gopay
(
harga
,
idPaket
);
break
;
case
'alfamart'
:
break
;
case
'indomaret'
:
case
'qris'
:
await
qris
(
harga
,
idPaket
);
break
;
default
:
result
=
'
metode pembayaran tidak ada
'
;
throw
Exception
(
"
metode pembayaran tidak ada
"
)
;
}
return
result
;
}
Future
<
String
>
gopay
(
int
harga
,
int
idPaket
)
async
{
Future
<
void
>
gopay
(
int
harga
,
int
idPaket
)
async
{
Map
<
String
,
dynamic
>
result
;
String
?
token
=
await
getToken
();
final
response
=
await
http
.
post
(
...
...
@@ -88,6 +84,23 @@ class ApiServices {
return
result
[
'actions'
][
1
][
'url'
];
}
Future
<
void
>
qris
(
int
harga
,
int
idPaket
)
async
{
Map
<
String
,
dynamic
>
result
;
String
?
token
=
await
getToken
();
final
response
=
await
http
.
post
(
Uri
.
parse
(
"
$API
/gopay?harga=
$harga
&id_paket=
$idPaket
"
),
headers:
{
'Authorization'
:
'Bearer
$token
'
});
result
=
jsonDecode
(
response
.
body
);
if
(
result
[
'status_code'
]
!=
"201"
)
{
throw
Exception
(
"invalid response"
);
}
if
(!
await
launchUrlString
(
result
[
'actions'
][
0
][
'url'
],
mode:
LaunchMode
.
externalApplication
))
{
throw
Exception
(
"can't show qr code"
);
}
}
Future
<
Transaksi
>
requestPaket
(
int
idPaket
)
async
{
String
?
token
=
await
getToken
();
final
response
=
await
http
.
post
(
Uri
.
parse
(
"
$API
/create-riwayat"
),
...
...
This diff is collapsed.
Click to expand it.
lib/views/shop/pembayaran.dart
View file @
6b18238b
...
...
@@ -16,7 +16,7 @@ class Pembayaran extends StatefulWidget {
State
<
Pembayaran
>
createState
()
=>
_PembayaranState
();
}
enum
MetodePembayaran
{
gopay
,
indomaret
,
alfamart
}
enum
MetodePembayaran
{
gopay
,
qris
}
class
_PembayaranState
extends
State
<
Pembayaran
>
{
final
api
=
ApiServices
();
...
...
@@ -80,7 +80,7 @@ class _PembayaranState extends State<Pembayaran> {
],
),
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
1
1
5
),
padding:
const
EdgeInsets
.
only
(
bottom:
15
0
),
child:
Column
(
children:
[
Text
(
...
...
@@ -126,39 +126,12 @@ class _PembayaranState extends State<Pembayaran> {
maxWidth:
40
,
minHeight:
20
,
minWidth:
20
),
child:
Image
.
asset
(
'assets/logo/
alfamart
.png'
),
child:
Image
.
asset
(
'assets/logo/
qris
.png'
),
),
title:
Text
(
"
Alfamart
"
),
title:
Text
(
"
QRIS
"
),
trailing:
Radio
<
MetodePembayaran
>(
activeColor:
Color
(
0xff867EBA
),
value:
MetodePembayaran
.
alfamart
,
groupValue:
_metodePembayaran
,
onChanged:
(
MetodePembayaran
?
value
)
{
setState
(()
{
_metodePembayaran
=
value
;
});
},
),
),
),
Card
(
margin:
EdgeInsets
.
only
(
top:
10
,
right:
10
,
left:
10
,
bottom:
5
),
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
10
))),
child:
ListTile
(
leading:
ConstrainedBox
(
constraints:
BoxConstraints
(
maxHeight:
40
,
maxWidth:
40
,
minHeight:
20
,
minWidth:
20
),
child:
Image
.
asset
(
'assets/logo/indomaret.png'
),
),
title:
Text
(
"Indomaret"
),
trailing:
Radio
<
MetodePembayaran
>(
activeColor:
Color
(
0xff867EBA
),
value:
MetodePembayaran
.
indomaret
,
value:
MetodePembayaran
.
qris
,
groupValue:
_metodePembayaran
,
onChanged:
(
MetodePembayaran
?
value
)
{
setState
(()
{
...
...
@@ -171,15 +144,6 @@ class _PembayaranState extends State<Pembayaran> {
],
),
),
// TextButton(
// onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// Success(idPaket: widget.paket.id)));
// },
// child: Text("Success Page")),
Container
(
width:
MediaQuery
.
of
(
context
).
size
.
width
,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.1
,
...
...
@@ -206,11 +170,10 @@ class _PembayaranState extends State<Pembayaran> {
onPressed:
()
{
// print(_metodePembayaran.toString().split('.').last);
EasyLoading
.
show
(
status:
'loading'
).
then
((
_
)
async
{
String
result
=
await
api
.
pembayaran
(
await
api
.
pembayaran
(
_metodePembayaran
.
toString
().
split
(
'.'
).
last
,
widget
.
paket
.
harga
+
1000
,
widget
.
paket
.
id
);
print
(
result
);
EasyLoading
.
dismiss
();
});
},
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help