public static void Main () { MP mp = new MP("ACCESS_TOKEN"); Hashtable payment = mp.get ("/v1/payments/[ID]"); Console.WriteLine (payment.ToString()); }
public static void Main () { MP mp = new MP("CLIENT_ID", "CLIENT_SECRET"); Hashtable balance = mp.get ("/users/USER_ID/mercadopago_account/balance"); Console.WriteLine (balance.ToString()); }
public static void Main () { MP mp = new MP("ACCESS_TOKEN"); Hashtable cards = mp.get ("/v1/customers/[CUSTOMER_ID]/cards"); Console.WriteLine (cards["response"].ToString()); }
public static void Main () { MP mp = new MP("ACCESS_TOKEN"); Hashtable paymentMethods = mp.get ("/v1/payment_methods"); Console.WriteLine (paymentMethods.ToString()); }
public static void Main() { MP mp = new MP("CLIENT_ID", "CLIENT_SECRET"); Hashtable balance = mp.get("/users/USER_ID/mercadopago_account/balance"); Console.WriteLine(balance.ToString()); }
public static void Main() { MP mp = new MP("ACCESS_TOKEN"); Hashtable payment = mp.get("/v1/payments/[ID]"); Console.WriteLine(payment.ToString()); }
public static void Main() { MP mp = new MP("ACCESS_TOKEN"); Hashtable paymentMethods = mp.get("/v1/payment_methods"); Console.WriteLine(paymentMethods.ToString()); }
public static void Main() { MP mp = new MP("ACCESS_TOKEN"); Hashtable cards = mp.get("/v1/customers/[CUSTOMER_ID]/cards"); Console.WriteLine(cards["response"].ToString()); }
public static void Main () { MP mp = new MP("ACCESS_TOKEN"); Dictionary<String, String> filters = new Dictionary<String, String> (); filters.Add("email", "your.payer@email"); Hashtable customer = mp.get ("/v1/customers/search", filters); Console.WriteLine (customer.ToString()); }
public static void Main() { MP mp = new MP("ACCESS_TOKEN"); Dictionary <String, String> filters = new Dictionary <String, String> (); filters.Add("email", "your.payer@email"); Hashtable customer = mp.get("/v1/customers/search", filters); Console.WriteLine(customer.ToString()); }
public static void Main () { MP mp = new MP("ACCESS_TOKEN"); Dictionary<String, String> filters = new Dictionary<String, String> (); filters.Add("email", "your.payer@email"); Hashtable saved_customer = mp.get ("/v1/customers/search", filters); Integer customer_id = saved_customer["response"]["id"]; Hashtable card = mp.post ("/v1/customers/"+customer_id+"/cards", "{\"token\": \"ff8080814c11e237014c1ff593b57b4d\"}"); Console.WriteLine (card.ToString()); }
public static void Main() { MP mp = new MP("ACCESS_TOKEN"); Dictionary <String, String> filters = new Dictionary <String, String> (); filters.Add("email", "your.payer@email"); Hashtable saved_customer = mp.get("/v1/customers/search", filters); Integer customer_id = saved_customer["response"]["results"][0]["id"]; Hashtable card = mp.post("/v1/customers/" + customer_id + "/cards", "{\"token\": \"ff8080814c11e237014c1ff593b57b4d\"}"); Console.WriteLine(card.ToString()); }
public JObject GetCustomer([FromUri(Name = "seller_email")] string sellerEmail, [FromUri(Name = "buyer_email")] string buyerEmail) { var buyer = (Buyer)_userService.GetByEmail(buyerEmail, false); var seller = (Seller)_userService.GetByEmail(sellerEmail, true); var mp = new MP(seller.Token.AccessToken); var customer = mp.get("/v1/customers/" + buyer.MPCustomerId, true); if (customer["response"] != null) { var response = JsonConvert.SerializeObject(customer["response"]); return(JObject.Parse(response)); } return(new JObject()); }
public HttpResponseMessage Notifications([FromBody] WebhooksDTO webhooksDto) { var type = HttpContext.Current.Request.QueryString["type"]; var dataId = HttpContext.Current.Request.QueryString["data.id"]; var response = Request.CreateResponse(HttpStatusCode.Created); var fcmNotificationMessageTitle = ""; var fcmNotificationMessageText = ""; string registrationToken = null; if (type.Equals("payment")) { // Obtengo los datos del pago creado y notifico al vendedor. if (webhooksDto.Action.Equals("payment.created")) { var sellerId = webhooksDto.UserId; var paymentId = webhooksDto.Data.Id; var seller = _sellerService.GetByMPSellerUserId(sellerId); var mp = new MP(seller.Token.AccessToken); // TODO cambiar el nombre a registrationToken en la db registrationToken = seller.Device.RegistrationId; var paymentDetail = mp.get("/v1/payments/" + paymentId, true); var paymentDetails = ((Hashtable)paymentDetail["response"]); var status = paymentDetails["status"]; var payerEmail = ((Hashtable)paymentDetails["payer"])["email"]; var description = paymentDetails["description"]; var transactionAmount = paymentDetails["transaction_amount"]; var dateLastUpdated = paymentDetails["date_last_updated"]; if (status.Equals("approved")) { fcmNotificationMessageTitle += "Pago APROBADO"; } else if (status.Equals("rejected")) { fcmNotificationMessageTitle += "Pago RECHAZADO"; } fcmNotificationMessageText += "Comprador: " + payerEmail + " - (" + description + ")" + " por $ " + transactionAmount + " a las " + dateLastUpdated; } else if (webhooksDto.Action.Equals("payment.updated")) { } } else if (type.Equals("mp-connect")) { if (webhooksDto.Action.Equals("application.authorized")) { } else if (webhooksDto.Action.Equals("application.deauthorized")) { } } var client = new RestClient(ConfigurationManager.AppSettings["FCM_API_BASE_URL"]); var fcmRequest = new RestRequest("/fcm/send", Method.POST); fcmRequest.RequestFormat = DataFormat.Json; fcmRequest.JsonSerializer = new RestSharpJsonNetSerializer(); fcmRequest.AddHeader("Content-Type", "application/json"); fcmRequest.AddHeader("Authorization", "key=" + ConfigurationManager.AppSettings["FCM_SERVER_KEY"]); var fcmNotificationMessageDto = new FCMNotificationMessageDTO { Data = new FCMNotificationMessageDTO.FCMNotificationMessageDetailDTO { Type = "notifications", Title = fcmNotificationMessageTitle, Text = fcmNotificationMessageText }, To = registrationToken }; string json = JsonConvert.SerializeObject(fcmNotificationMessageDto, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); fcmRequest.AddJsonBody(fcmNotificationMessageDto); IRestResponse fcmResponse = client.Execute(fcmRequest); return(response); }
public JObject DoPayment([FromBody] PaymentDataDTO paymentData) { // Obtengo al Comprador y al Vendedor. var buyer = (Buyer)_userService.GetByEmail(paymentData.BuyerEmail, false); var seller = (Seller)_userService.GetByEmail(paymentData.SellerEmail, true); var mp = new MP(seller.Token.AccessToken); // Me fijo si ya existia un Customer con ese email. var filters = new Dictionary <String, String> { { "email", paymentData.BuyerEmail } }; var customerSearch = mp.get("/v1/customers/search", filters); var customerSearchResponse = (Hashtable)customerSearch["response"]; var results = (ArrayList)customerSearchResponse["results"]; string customerId; // No existe el Customer para ese mail. if (results.Count == 0) { var customerSaved = mp.post("/v1/customers", "{\"email\": \"" + paymentData.BuyerEmail + "\"}"); customerSearchResponse = (Hashtable)customerSaved["response"]; customerId = (string)customerSearchResponse["id"]; buyer.MPCustomerId = (string)customerId; _userService.Update(buyer); } // Existe el Customer para ese mail. else { var resultsHashtable = (Hashtable)results[0]; customerId = (string)resultsHashtable["id"]; } var transactionAmount = paymentData.TransactionAmount; var cardToken = paymentData.CardToken; var paymentMethodId = paymentData.PaymentMethodId; var applicationFee = 0.03f * transactionAmount; var data = "{" + "\"transaction_amount\": " + transactionAmount + "," + "\"token\": \"" + cardToken + "\"," + "\"description\": \"" + paymentData.Description + "\"," + "\"installments\": 1," + "\"payment_method_id\": \"" + paymentMethodId + "\"," + "\"application_fee\": " + applicationFee + "," + "\"statement_descriptor\": \"MULTIPAY\"," + "\"binary_mode\": true," + "\"payer\": {" + "\"id\": \"" + customerId + "\"" + "}" + "}"; var paymentInfo = mp.post("/v1/payments", data); // Guardo la tarjeta para que quede asociada si el pago salio de forma correcta. var card = mp.post("/v1/customers/" + customerId + "/cards", "{\"token\": \"" + cardToken + "\"}"); if ((int)paymentInfo["status"] == (int)HttpStatusCode.Created) { var response = JsonConvert.SerializeObject(paymentInfo["response"]); return(JObject.Parse(response)); } return(new JObject()); }