public DataMessage SaveControlNumber(ControlNumberResp model) { PaymentRepository payment = new PaymentRepository(Configuration); var controlNumberExists = payment.CheckControlNumber(model.internal_identifier, model.control_number); var response = payment.SaveControlNumber(model, controlNumberExists); if (payment.PaymentId != null) { var ackResponse = payment.GetReqControlNumberAck(payment.PaymentId); if (!response.ErrorOccured && !controlNumberExists) { ControlNumberAssignedSms(payment); } else { ControlNumberNotassignedSms(payment, response.MessageValue); } } return(response); }
public async Task <DataMessage> SaveIntent(IntentOfPay intent, int?errorNumber = 0, string errorMessage = null) { IPaymentRepository payment = new PaymentRepository(Configuration); var intentResponse = payment.SaveIntent(intent, errorNumber, errorMessage); DataMessage return_message = new DataMessage(); return_message.Code = intentResponse.Code; return_message.MessageValue = intentResponse.MessageValue; if (intentResponse.Code == 0) { var objstring = intentResponse.Data.ToString(); List <AssignedControlNumber> data = JsonConvert.DeserializeObject <List <AssignedControlNumber> >(objstring); var ret_data = data.FirstOrDefault(); decimal transferFee = 0; //Get the transfer Fee if (intent.type_of_payment != null) { transferFee = payment.determineTransferFee(payment.ExpectedAmount, (TypeOfPayment)intent.type_of_payment); var success = payment.UpdatePaymentTransferFee(payment.PaymentId, transferFee, (TypeOfPayment)intent.type_of_payment); } var amountToBePaid = payment.GetToBePaidAmount(payment.ExpectedAmount, transferFee); var response = payment.PostReqControlNumber(intent.enrolment_officer_code, payment.PaymentId, intent.phone_number, amountToBePaid, intent.policies); if (response.ControlNumber != null) { var controlNumberExists = payment.CheckControlNumber(payment.PaymentId, response.ControlNumber); return_message = payment.SaveControlNumber(response.ControlNumber, controlNumberExists); if (payment.PaymentId != null) { if (!return_message.ErrorOccured && !controlNumberExists) { ret_data.control_number = response.ControlNumber; ControlNumberAssignedSms(payment); } else { ControlNumberNotassignedSms(payment, return_message.MessageValue); } } } else if (response.Posted == true) { return_message = payment.SaveControlNumberAkn(response.ErrorOccured, response.ErrorMessage); } else if (response.ErrorOccured == true) { return_message = payment.SaveControlNumberAkn(response.ErrorOccured, response.ErrorMessage); ControlNumberNotassignedSms(payment, response.ErrorMessage); } return_message.Data = ret_data; } else { return_message = intentResponse; return_message.Data = new AssignedControlNumber(); } return(return_message); }