SDPPaymentNotificationResponse GenerateSampleSDPAsynchronousPaymentNotificationResponse(SDPPaymentNotificationRequest request) { SDPPaymentNotificationResponse sample = new SDPPaymentNotificationResponse(); sample.statusCode = "Success"; sample.statusDetail = "Success"; return sample; }
public ActionResult ReceiveAsynchPaymentNotification(SDPPaymentNotificationRequest notification, SDPBuyGoodsNotificationRequest buyGoodsNotification) { //SDPAsynchronousPaymentNotificationRequest ContentResult cResult = new ContentResult(); try { cResult.ContentType = "application/json"; cResult.ContentEncoding = Encoding.UTF8; cResult.Content = null; ServerRequestBase sdpRequest = null; string serializedNotif = ""; string requestType = "AsynchronousPaymentNotificationRequest"; if (notification != null && notification.externalTrxId != null) { serializedNotif = JsonConvert.SerializeObject(notification, new IsoDateTimeConverter()); sdpRequest = notification; } else if (buyGoodsNotification != null && buyGoodsNotification.receiptNumber != null) { requestType = "SDPBuyGoodsNotificationRequest"; serializedNotif = JsonConvert.SerializeObject(buyGoodsNotification, new IsoDateTimeConverter()); sdpRequest = buyGoodsNotification; } _auditLogRepository.AddLog(Guid.Empty, requestType, "From HSenid", "Json: " + serializedNotif); /*_messageDeserialize.DeserializeSDPRequest( ClientRequestResponseType.AsynchronousPaymentNotification.ToString(), json);*/ SDPPaymentNotificationResponse sdpapnResponse = null; ClientRequestResponseBase crrRequest = null; Guid spid = Guid.Empty; string subscriber = ""; _resolveMessageService.ProcessSDPRequest(sdpRequest, out crrRequest, out subscriber, out spid); //convert into our entity sdpapnResponse = ProcessSDPPaymentNotification(sdpRequest, crrRequest); string result = JsonConvert.SerializeObject(sdpapnResponse, new IsoDateTimeConverter()); _auditLogRepository.AddLog(Guid.Empty, "AsynchronousPaymentNotificationResponse", "To HSenid", "Json: " + result); cResult.Content = result; } catch (Exception ex) { _auditLogRepository.AddLog(Guid.Empty, "AsynchronousPaymentNotificationRequest", "From HSenid", "Error: " + ex.Message); cResult.Content = "Error processing notification"; } return cResult; }
SDPPaymentNotificationRequest GenerateSampleSDPAsynchronousPaymentNotificationRequest() { var existingPaymentRequest = _paymentRequestRepository.GetAll().OfType<PaymentRequest>() .Where(n => n.TransactionRefId == sampleExternalTrxId.ToString()).LastOrDefault(); SDPPaymentNotificationRequest sample = new SDPPaymentNotificationRequest(); sample.externalTrxId = existingPaymentRequest.TransactionRefId.ToString(); sample.paidAmount = existingPaymentRequest.Amount.ToString(); sample.currency = existingPaymentRequest.Currency; sample.internalTrxId = Guid.NewGuid().ToString(); sample.statusCode = "Success"; sample.statusDetail = "Success"; //sample.referenceId = existingPaymentResponse.SDPReferenceId; sample.timestamp = DateTime.Now; return sample; }
public async Task<SDPPaymentNotificationResponse> ReceiveAsynchPaymentNotificationTest(SDPPaymentNotificationRequest request) { SDPPaymentNotificationResponse _response = new SDPPaymentNotificationResponse(); HttpClient httpClient = setupHttpClient(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string url = "api/bridge/payment/postpaymentnotification"; try { var response = await httpClient.PostAsJsonAsync(url, request); _response = await response.Content.ReadAsAsync<SDPPaymentNotificationResponse>(); } catch (Exception ex) { string error = "Failed to retrieve payment notification.\n" + (ex.InnerException == null ? "" : ex.InnerException.Message); _log.Error(error); _response.statusCode = "Error"; _response.statusDetail = error; } return _response; }