From 86b7268b5019003f71e0048cfa01401f6e1ac1c6 Mon Sep 17 00:00:00 2001 From: Matthew Patrick <Matthew.535200018@stu.untar.ac.id> Date: Thu, 28 Apr 2022 11:27:37 +0700 Subject: [PATCH] Added checkoutPost API --- lib/api/api.dart | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/api/api.dart b/lib/api/api.dart index f332fb6..7ab7577 100644 --- a/lib/api/api.dart +++ b/lib/api/api.dart @@ -45,8 +45,27 @@ Future<dynamic> loginPost({email, password}) async { } Future<dynamic> getTransactions() async { - String tempKey = 'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp'; - var req = await Dio().post(host + '/transaction', queryParameters: {'key': tempKey}); + String tempKey = + 'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp'; + var req = await Dio() + .post(host + '/transaction', queryParameters: {'key': tempKey}); var res = req.data; return res; -} \ No newline at end of file +} + +Future<dynamic> checkoutPost(data) async { + String tempKey = + 'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp'; + Response req = await Dio().post( + (host + '/checkout'), + queryParameters: {'key': tempKey}, + data: data, + options: Options( + contentType: Headers.formUrlEncodedContentType, + validateStatus: (status) { + return status! < 500; + }, + ), + ); + return req.statusCode; +}