private NotificationPushBVG GetNotificationPushBVG() { Dictionary <string, Object> generalData = new Dictionary <string, Object>(); generalData.Add(ElementNames.BVG_MERCHANT, "41702"); generalData.Add(ElementNames.BVG_SECURITY, "TODOPAGO 8A891C0676A25FBF052D1C2FFBC82DEE"); generalData.Add(ElementNames.BVG_REMOTE_IP_ADDRESS, "192.168.11.87"); generalData.Add(ElementNames.BVG_PUBLIC_REQUEST_KEY, "f50208ea-be00-4519-bf85-035e2733d09e"); generalData.Add(ElementNames.BVG_OPERATION_NAME, "Compra"); Dictionary <string, Object> operationData = new Dictionary <string, Object>(); operationData.Add(ElementNames.BVG_RESULT_CODE_MEDIOPAGO, "-1"); operationData.Add(ElementNames.BVG_RESULT_CODE_GATEWAY, "-1"); operationData.Add(ElementNames.BVG_ID_GATEWAY, "8"); operationData.Add(ElementNames.BVG_RESULT_MESSAGE, "Aprobada"); operationData.Add(ElementNames.BVG_OPERATION_DATE_TIME, "20160704085736"); operationData.Add(ElementNames.BVG_TICKET_MUNBER, "7866463542424"); operationData.Add(ElementNames.BVG_CODIGO_AUTORIZATION, "455422446756567"); operationData.Add(ElementNames.BVG_CURRENCY_CODE, "032"); operationData.Add(ElementNames.BVG_OPERATION_ID, "1234"); operationData.Add(ElementNames.BVG_CONCEPT, "compra"); operationData.Add(ElementNames.BVG_AMOUNT, "10,99"); operationData.Add(ElementNames.BVG_FACILITIES_PAYMENT, "03"); Dictionary <string, Object> tokenizationData = new Dictionary <string, Object>(); tokenizationData.Add(ElementNames.BVG_PUBLIC_TOKENIZATION_FIELD, "sydguyt3e862t76ierh76487638rhkh7"); tokenizationData.Add(ElementNames.BVG_CREDENTIAL_MASK, "4507XXXXXXXX0001"); NotificationPushBVG notificationPushBVG = new NotificationPushBVG(generalData, operationData, tokenizationData); return(notificationPushBVG); }
public static NotificationPushBVG ParseJsonToNotificationPushBVG(string json) { NotificationPushBVG notificationPush = new NotificationPushBVG(); if (json != null && json.Equals("")) { string message = "Response vacio o nulo"; throw new ResponseException(message); } Dictionary <string, object> result = ParseJsonToDictionary(json); if (result.ContainsKey(ElementNames.BVG_ERROR_CODE)) { string message = (string)result[ElementNames.BVG_ERROR_CODE] + " - " + (string)result[ElementNames.BVG_ERROR_MESSAGE]; throw new ResponseException(message); } if (result.ContainsKey("error")) { var status = result["status"]; string message = status + " - " + (string)result["message"]; throw new ResponseException(message); } notificationPush.SetStatusCode((string)result[ElementNames.BVG_STATUS_CODE]); notificationPush.SetStatusMessage((string)result[ElementNames.BVG_STATUS_MESSAGE]); return(notificationPush); }
public void NotificationPushBVG() { NotificationPushBVG notificationPushBVG = new NotificationPushBVG(); try { notificationPushBVG = connector.NotificationPush(GetNotificationPushBVG()); printDictionary(notificationPushBVG.toDictionary(), ""); } catch (EmptyFieldException ex) { Console.WriteLine(ex.Message); } catch (ResponseException ex) { Console.WriteLine(ex.Message); } catch (ConnectionException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public NotificationPushBVG NotificationPush(NotificationPushBVG notificationPush) { string publicRequestKey = (string)(notificationPush.GetGeneralData()[ElementNames.BVG_PUBLIC_REQUEST_KEY]); string URL = endpoint + BVTP_NOTIFICATION_PUSH + "/" + publicRequestKey; string json = OperationsParserBVG.GenerateNotificationPushJson(notificationPush); string result = ExecuteRequest(json, URL, METHOD_PUT, true); return(OperationsParserBVG.ParseJsonToNotificationPushBVG(result)); }
public static string GenerateNotificationPushJson(NotificationPushBVG notificationPush) { Dictionary <string, object> aux = new Dictionary <string, object>(); aux.Add(ElementNames.BVG_GENERAL_DATA, notificationPush.GetGeneralData()); aux.Add(ElementNames.BVG_OPERATION_DATA, notificationPush.GetOperationData()); aux.Add(ElementNames.BVG_TOKENIZATION_DATA, notificationPush.GetTokenizationData()); string notificationPushJson = JsonConvert.SerializeObject(aux, Newtonsoft.Json.Formatting.Indented); return(notificationPushJson); }
public NotificationPushBVG NotificationPush(NotificationPushBVG notificationPush) { NotificationPushBVG result = notificationPush; NotificationPushValidate nv = new NotificationPushValidate(); if (nv.ValidateNotificationPush(notificationPush)) { result = bvgClient.NotificationPush(notificationPush); } return(result); }
public Boolean ValidateNotificationPush(NotificationPushBVG notificationPush) { Boolean valid = true; Dictionary <string, Object> generalData = notificationPush.GetGeneralData(); Dictionary <string, Object> operationData = notificationPush.GetOperationData(); Dictionary <string, Object> tokenizationData = notificationPush.GetTokenizationData(); valid = ValidateGeneralData(generalData) && ValidateOperationData(operationData); valid = valid && ValidateTokenizationData(tokenizationData); valid = valid && ValidateFormatNotificationPush(generalData, operationData, tokenizationData); return(valid); }
public void NotificationPushFailTransactionTest() { BvgConnectorMock connector = GetConnector(NotificationPushDataProvider.GetNotificationPushWrongTransaction()); NotificationPushBVG response = connector.NotificationPush(NotificationPushDataProvider.GetNotificationPushBVG()); Assert.AreNotEqual(null, response); Assert.AreEqual(false, String.IsNullOrEmpty(response.GetStatusCode())); Assert.AreEqual(false, String.IsNullOrEmpty(response.GetStatusMessage())); Assert.AreEqual("2070", response.GetStatusCode()); }
public void NotificationPushFailWithoutFieldTest() { BvgConnectorMock connector = GetConnector(NotificationPushDataProvider.GetNotificationPushWithoutField()); NotificationPushBVG response = connector.NotificationPush(NotificationPushDataProvider.GetNotificationPushBVG()); Assert.AreNotEqual(null, response); Assert.AreEqual(false, String.IsNullOrEmpty(response.GetStatusCode())); Assert.AreEqual(false, String.IsNullOrEmpty(response.GetStatusMessage())); Assert.AreEqual("1014", response.GetStatusCode()); }
public void TransactionFailValidationTest() { BvgConnectorMock connector = GetConnector(NotificationPushDataProvider.GetNotificationPushOkResponse()); NotificationPushBVG response = connector.NotificationPush(NotificationPushDataProvider.GetNotificationPushWrongFieldBVG()); }