diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8b02a23..a664487 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:versionName="0.6"> extends BaseState { getLoyality(user['loyalty_url']); } + bool purchaseInProgress = false; Map user; String card = ''; String loyality = ''; @@ -186,35 +187,37 @@ class PurchaseScreenState extends BaseState { } purchase(String sumTotal) async { - if (await platform.invokeMethod('isOnline')) { + if (!purchaseInProgress) { + purchaseInProgress = true; + platform.invokeMethod('getDocID').then((result) { - platform.invokeMethod('getDocID').then((result) { + String url = user['purchases_url']; - String url = user['purchases_url']; + var body = { + 'doc_id': result, + 'curr_iso_code': '643', + 'commit': 'true', + 'sum_total': sumTotal + }; - var body = { - 'doc_id': result, - 'curr_iso_code': '643', - 'commit': 'true', - 'sum_total': sumTotal - }; + var headers = { + 'DM-Authorization': 'dmapptoken $appToken', + 'Authorization': 'dmtoken ${token}' + }; - var headers = { - 'DM-Authorization': 'dmapptoken $appToken', - 'Authorization': 'dmtoken ${token}' - }; + httpClient.post(url, body: body, headers: headers).then((response) { - httpClient.post(url, body: body, headers: headers).then((response) { + print(response.body); + Navigator.of(context).pop(); + pushRoute(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name'])); - print(response.body); - Navigator.of(context).pop(); - pushRoute(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name'])); - - }).catchError((error) { - print(error.toString()); - }); - }); + }).catchError((error) { + purchaseInProgress = false; + print(error.toString()); + }); + }); + } } } }