generateGatewayInitParams method
dynamic
generateGatewayInitParams(
- dynamic objectData,
- String mode
)
Implementation
generateGatewayInitParams(
var objectData,
String mode,
) async {
late Map<String, String> params;
// String node = "";
// String nodeId = "";
if (mode == "PURCHASE") {
Datum content = objectData as Datum;
String availabilityId = content.contentdetails!.length == 1
? content.contentdetails![0].availabilityset![0].toString()
: content.contentdetails![1].availabilityset![0].toString();
var data = await NetworkHandler.getPriceClass(availabilityId);
String priceClassId =
data['priceclassdetail'][0]['priceclassid'].toString();
String currency = data['priceclassdetail'][0]['currency'].toString();
String price = data['priceclassdetail'][0]['price'].toString();
params = {
'devicetype': kIsWeb ? 'WEB' : 'MOBILE',
'amount': price,
'currency': currency,
'transactionpurpose': 'PURCHASE',
'transactionmode': 'CC',
'availabilityid': availabilityId,
'objectid': content.isEpisode ? content.seriesid : content.objectid,
'objecttype': content.objecttype ?? "CONTENT",
'objecttitle': content.isEpisode ? content.seriesname : content.title,
'priceclassid': priceClassId,
};
} else if (mode == "SUBSCRIPTION") {
String price = objectData['price'];
String currency = objectData['currency'];
String availabilityId = objectData['availabilityid'];
String planid = objectData['planid'];
params = {
//'devicetype': 'WEB',
'devicetype': kIsWeb ? 'WEB' : 'MOBILE',
'amount': price,
'currency': currency,
'transactionpurpose': 'SUBSCRIPTION',
'transactionmode': 'CC',
'availabilityid': availabilityId,
'planid': planid,
};
} else if (mode == "EVENT") {
// nodeId = objectData['hostid'];
// node = "coach";
String amount = objectData['amount'];
String instructorId = objectData['hostid'];
String idevent = objectData['eventid'];
String sessionid = objectData['sessionid'];
var purchaseMetadata = {
'hostid': instructorId,
'eventid': idevent,
'sessionid': sessionid
};
params = {
'devicetype': kIsWeb ? 'WEB' : 'MOBILE',
'amount': amount,
'currency': 'INR',
'transactionpurpose': 'PURCHASE',
'transactionmode': 'CC',
'availabilityid': 'QAF0HEPH',
'objectid': 'iryXkXDrdzcH',
'priceclassid': '9UGLQ5PK',
'purchasetype': 'SESSION',
'purchasemetadata': jsonEncode(purchaseMetadata),
};
}
String callbackUrl = "";
if (kIsWeb) {
try {
// if (mode != "EVENT") {
// if (objectData.objecttype == ContentModel.content) {
// node = "videos";
// } else {
// node = "courses";
// }
// }
// nodeId = objectData.objectid;
// String title = "redirected";
// callbackUrl = '${AppUrls.redirectUrl}/$node/$nodeId/$title';
// callbackUrl = ProviderConstants.webHostUrl;
} catch (objectidError) {
// callbackUrl = ProviderConstants.webHostUrl;
}
} else {
//callbackUrl = "${ProviderConstants.webHostUrl}/payment_redirection.html";
}
params['callbackUrl'] = callbackUrl;
return params;
}