我正在尝试将 paytm 集成到我的应用中。我试图以 JSON 格式从服务器中提取签名和 orderid
。但我收到以下错误。
错误:
W/xample.dctrade(20336): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
E/flutter (20336): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: FormatException: Unexpected character (at character 2)
E/flutter (20336): {signature: sTknIJpTHoZLxyQhCO9UgXNz5lKcsOs5/jOKHDwWpCXHdK46Aa4pBUslC8YmwtV...
E/flutter (20336): ^
E/flutter (20336):
代码如下:
Future<GetToken> gettoken() async{
final String url = "https://dcgroupofcompany.com/payment/payment.php";
Map<String, String> headers = {
'Content-Type': 'application/json;charset=UTF-8',
'Charset': 'utf-8'};
final response = await http.get(Uri.parse(url),headers: headers);
Map<String, dynamic> map = json.decode(response.body);
String token = map.toString();
return getTokenFromJson(token);
}
Future<void> startTransaction() async{
final GetToken _token = await gettoken();
String orderId = _token.orderid.toString();
String txntokens = _token.signature.toString();
String callbackUrl = "https://securegw-stage.paytm.in/theia/api/v1/initiateTransaction?mid="+mid+"&orderId="+orderId;
print(orderId);
}
JSON:
{
"signature": "pvuSBnN6l\/DapUvaYqL+5MTjxEpAolky1bNSf08cScQMPd5INfYH3xVTNCDnyEY\/Yb8qxEE4J6M1nxXoaVusFl+6bEo\/v8xfO1+eifipN74=",
"orderid": "DCTR150308020208"
}
有人知道如何解决这个问题吗?