Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New IPNhandler #58

Closed
wants to merge 66 commits into from
Closed

New IPNhandler #58

wants to merge 66 commits into from

Conversation

dotfede
Copy link
Contributor

@dotfede dotfede commented Jul 25, 2018

Se introduce una clase MercadoPago.Ipn que resuelve de manera sencilla y sin usar reflection la misma problemática que la clase MercadoPago.Core.MPIPN, es decir:

  • Ante un determinado topic y id, se determina si el topic corresponde a un Payment o a un MerchantOrder.
  • se hace un FindById() del recurso correspondiente utilizando el id provisto
  • se invoca la acción definida por el consumidor según corresponda.

Ejemplo:

        public static void IpnNotification(string topic, string id)
        {
            Ipn.HandleNotification(topic, id, onPaymentReceived: OnPaymentReceived, onMerchantOrderReceived: OnMerchantOrderReceived);
        }

        private static void OnPaymentReceived(Payment payment)
        {
            Console.WriteLine($"Payment Received: {payment.Id}");
        }

        private static void OnMerchantOrderReceived(MerchantOrder merchantOrder)
        {
            Console.WriteLine($"Merchant Order Received: {merchantOrder.Id}");
        }

Ventajas respecto del approach anterior:

  • No utiliza reflection
  • No es un método genérico, con lo cuál no se le pueden pasar tipos inválidos (por ejemplo Customer)
  • No presenta la ambigüedad de determinar el tipo de recurso de 2 maneras (usando un type parameter y dependiendo del valor de topic)
  • No realiza el request FindById() en caso de que el consumidor no desee realizar ninguna acción ante un tipo de recurso determinado, ahorrando llamadas HTTP innecesarias.

joelibaceta and others added 28 commits July 11, 2018 00:07
# Conflicts:
#	MercadoPagoSDK.Test/Resources/PaymentTest.cs
#	px-dotnet/Core/MPBase.cs
#	px-dotnet/DataStructures/Payment/Payer.cs
#	px-dotnet/Resources/Payment.cs
@dotfede dotfede closed this Sep 27, 2018
@dotfede dotfede deleted the NewIpnHandler branch September 27, 2018 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant