{"pp_Amount":"4222","pp_AuthCode":"","pp_BankID":"","pp_BillReference":"billRef","pp_Language":"EN","pp_MerchantID":"My ID","pp_ResponseCode":"199","pp_ResponseMessage":"Sorry! Your transaction was not successful. Please try again later.","pp_RetreivalReferenceNo":"230221337471","pp_SubMerchantId":"","pp_TxnCurrency":"PKR","pp_TxnDateTime":"20230221154200","pp_TxnRefNo":"T20230221154200","pp_SettlementExpiry":"","pp_TxnType":"MWALLET","pp_Version":"1.1","ppmpf_1":"030844#####","ppmpf_2":"","ppmpf_3":"","ppmpf_4":"","ppmpf_5":"","pp_SecureHash":"EECFF4DA57C8B3BDC741461B5D0C4BA73082C9A2A0F5078E727DDAE2864B7065"}
I Don't know what is issue in my code I've used this Link
My Code is
`import 'dart:convert';
import 'package:intl/intl.dart';
import 'package:crypto/crypto.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:improvement/citizen_portal/colors.dart';
import 'package:improvement/citizen_portal/widgets/button.dart';
class JazzCashIntegration extends StatefulWidget {
const JazzCashIntegration({Key? key}) : super(key: key);
@override
State<JazzCashIntegration> createState() => _JazzCashIntegrationState();
}
class _JazzCashIntegrationState extends State<JazzCashIntegration> {
TextEditingController amountCtrl = TextEditingController();
bool hasnotAmount = true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Center(child: Text('Jazz Cash Testing')),
elevation: 0,
),
body: Center(
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Align(
alignment: Alignment.topLeft,
child: Text(
'Please Enter Amount:',
style: TextStyle(
color: MyColors.appText,
fontWeight: FontWeight.w600,
fontSize: 15),
),
),
TextField(
controller: amountCtrl,
keyboardType: TextInputType.number,
decoration: InputDecoration(
filled: true,
isDense: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide.none),
fillColor: MyColors.appWhiteShade,
labelText: 'Enter Amount',
floatingLabelBehavior: FloatingLabelBehavior.never,
errorText: !hasnotAmount ? 'Please Enter amount': null,
),
onSubmitted: (value) {
if (value.isEmpty) {
setState(() {
hasnotAmount = true;
});
}
else{
setState(() {
hasnotAmount = false;
});
}
},
),
GestureDetector(
onTap: (){
payment();
},
child: const RoundBtn(txt: 'Confirm', hasIcon: false))
],
),
),
),
);
}
payment() async{
var digest;
String dateandtime = DateFormat("yyyyMMddHHmmss").format(DateTime.now());
String dexpiredate = DateFormat("yyyyMMddHHmmss").format(DateTime.now().add(Duration(days: 1)));
String tre = "T"+dateandtime;
String pp_Amount=
amountCtrl.text.trim().toString();
String pp_BillReference="billRef";
String pp_Description="Description";
String pp_Language="EN";
String pp_MerchantID= "My Merchant ID";
String pp_Password="My Password";
String pp_ReturnURL="https://sandbox.jazzcash.com.pk/ApplicationAPI/API/Payment/DoTransaction";
String pp_ver = "1.1";
String pp_TxnCurrency= "PKR";
String pp_TxnDateTime=dateandtime.toString();
String pp_TxnExpiryDateTime=dexpiredate.toString();
String pp_TxnRefNo=tre.toString();
String pp_TxnType="MWALLET";
String ppmpf_1="030844#####";
String IntegeritySalt = "My Salt";
String and = '&';
String superdata=
IntegeritySalt+and+
pp_Amount+and+
pp_BillReference +and+
pp_Description +and+
pp_Language +and+
pp_MerchantID +and+
pp_Password +and+
pp_ReturnURL +and+
pp_TxnCurrency+and+
pp_TxnDateTime +and+
pp_TxnExpiryDateTime +and+
pp_TxnRefNo+and+
pp_TxnType+and+
pp_ver+and+
ppmpf_1
;
var key = utf8.encode(IntegeritySalt);
var bytes = utf8.encode(superdata);
var hmacSha256 = Hmac(sha256, key);
Digest sha256Result = hmacSha256.convert(bytes);
var url = 'https://sandbox.jazzcash.com.pk/ApplicationAPI/API/Payment/DoTransaction';
var response = await http.post(Uri.parse(url), body: {
"pp_Version": pp_ver,
"pp_TxnType": pp_TxnType,
"pp_Language": pp_Language,
"pp_MerchantID": pp_MerchantID,
"pp_Password": pp_Password,
"pp_TxnRefNo": tre,
"pp_Amount": pp_Amount,
"pp_TxnCurrency": pp_TxnCurrency,
"pp_TxnDateTime": dateandtime,
"pp_BillReference": pp_BillReference,
"pp_Description": pp_Description,
"pp_TxnExpiryDateTime":dexpiredate,
"pp_ReturnURL": pp_ReturnURL,
"pp_SecureHash": sha256Result.toString(),
"ppmpf_1":ppmpf_1
});
print(response.statusCode.toString());
print("response=>");
print(response.body);
}
}
`