purchase screen coupons list final
This commit is contained in:
@@ -219,44 +219,60 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
|
||||
purchaseInProgress = true;
|
||||
|
||||
String token = await helper.getToken();
|
||||
helper.getMerchantID().then((result) {
|
||||
helper.getCurrency().then((currency) {
|
||||
var body = {
|
||||
'doc_id': result,
|
||||
'curr_iso_code': currency.toString(),
|
||||
'commit': 'true',
|
||||
'sum_total': sumTotal
|
||||
};
|
||||
var result = await helper.getMerchantID();
|
||||
var currency = await helper.getCurrency();
|
||||
|
||||
getPurchaseRequest(user['purchases_url'], body, token)
|
||||
.then((response) {
|
||||
print(response.body);
|
||||
Map parsedMap = JSON.decode(response.body);
|
||||
var body = {
|
||||
'doc_id': result,
|
||||
'curr_iso_code': currency.toString(),
|
||||
'commit': 'true',
|
||||
'sum_total': sumTotal
|
||||
};
|
||||
|
||||
Navigator.of(context).pop();
|
||||
var purchaseResponse;
|
||||
|
||||
if (parsedMap.containsKey('errors')) {
|
||||
List<String> errors = parsedMap['errors'];
|
||||
Scaffold
|
||||
.of(context)
|
||||
.showSnackBar(new SnackBar(content: new Text(errors[0])));
|
||||
} else {
|
||||
pushRouteReplacement(
|
||||
context,
|
||||
new PurchaseSuccessScreen(
|
||||
sumTotal,
|
||||
user['first_name'] == null ? '' : user['first_name'],
|
||||
helper,
|
||||
app,
|
||||
parsedMap
|
||||
));
|
||||
}
|
||||
}).catchError((error) {
|
||||
purchaseInProgress = false;
|
||||
print(error.toString());
|
||||
});
|
||||
});
|
||||
});
|
||||
try {
|
||||
purchaseResponse = await getPurchaseRequest(user['purchases_url'], body, token);
|
||||
print(purchaseResponse.body);
|
||||
} catch(error) {
|
||||
purchaseInProgress = false;
|
||||
print(error.toString());
|
||||
}
|
||||
|
||||
Map purchase = JSON.decode(purchaseResponse.body);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
|
||||
if (purchase.containsKey('errors')) {
|
||||
List<String> errors = purchase['errors'];
|
||||
Scaffold
|
||||
.of(context)
|
||||
.showSnackBar(new SnackBar(content: new Text(errors[0])));
|
||||
} else {
|
||||
var couponsResponse;
|
||||
|
||||
try {
|
||||
couponsResponse = await getCouponsRequest(purchase['coupons_url'], token);
|
||||
print(couponsResponse.body);
|
||||
} catch(error) {
|
||||
purchaseInProgress = false;
|
||||
print(error.toString());
|
||||
}
|
||||
|
||||
Map coupons = JSON.decode(couponsResponse.body);
|
||||
|
||||
pushRouteReplacement(
|
||||
context,
|
||||
new PurchaseSuccessScreen(
|
||||
sumTotal,
|
||||
user['first_name'] == null ? '' : user['first_name'],
|
||||
helper,
|
||||
app,
|
||||
purchase,
|
||||
coupons['results']
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user