Exemplo n.º 1
0
 private CustomerRequest BuildCreateRequest()
 {
     return(new CustomerRequest
     {
         FirstName = "Test",
         LastName = "Payer",
         Email = Environment.GetEnvironmentVariable("USER_EMAIL"),
         Phone = new PhoneRequest
         {
             AreaCode = "03492",
             Number = "123456",
         },
         Address = new CustomerDefaultAddressRequest
         {
             Id = "123",
             StreetName = "Street",
             StreetNumber = 123,
         },
         Description = "customer description",
         Identification = IdentificationHelper.GetIdentification(User),
         Metadata = new Dictionary <string, object>
         {
             ["key1"] = "value1",
         },
         DateRegistred = DateTime.Now.AddMonths(-6),
     });
 }
Exemplo n.º 2
0
 private CustomerRequest BuildCustomerCreateRequest()
 {
     return(new CustomerRequest
     {
         FirstName = "Test",
         LastName = "Payer",
         Email = Environment.GetEnvironmentVariable("USER_EMAIL"),
         Identification = IdentificationHelper.GetIdentification(User),
     });
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a test card token.
        /// </summary>
        /// <param name="user">User.</param>
        /// <param name="paymentStatus">Desired payment status.</param>
        /// <returns>The test card token./returns>
        public Task <CardToken> CreateTestCardToken(User user, string paymentStatus)
        {
            var request = new CardTokenTestCreate
            {
                CardNumber      = SiteIdCard[user.SiteId],
                SecurityCode    = "123",
                ExpirationMonth = 11,
                ExpirationYear  = DateTime.Now.AddYears(10).Year,
                Cardholder      = new CardTokenCardholderTestCreate
                {
                    Name           = StatusCardholderName[paymentStatus],
                    Identification = IdentificationHelper.GetIdentification(user),
                },
            };

            return(SendAsync(
                       "/v1/card_tokens",
                       MercadoPago.Http.HttpMethod.POST,
                       request));
        }
Exemplo n.º 4
0
        private async Task <AdvancedPaymentCreateRequest> BuildCreateRequestAsync(
            bool capture, string paymentStatus)
        {
            CardToken cardToken =
                await cardTokenClient.CreateTestCardToken(User, paymentStatus);

            return(new AdvancedPaymentCreateRequest
            {
                ApplicationId = "59441713004005",
                Payments = new List <AdvancedPaymentSplitPaymentRequest>
                {
                    new AdvancedPaymentSplitPaymentRequest
                    {
                        PaymentMethodId = "master",
                        PaymentTypeId = "credit_card",
                        Token = cardToken.Id,
                        DateOfExpiration = DateTime.UtcNow.Add(TimeSpan.FromDays(120)),
                        TransactionAmount = 1000,
                        Installments = 1,
                        ProcessingMode = "aggregator",
                        Description = "Payment",
                        ExternalReference = "Test" + Guid.NewGuid().ToString(),
                        StatementDescriptor = "ADVPAYTEST",
                    },
                },
                Disbursements = new List <AdvancedPaymentDisbursementRequest>
                {
                    new AdvancedPaymentDisbursementRequest
                    {
                        Amount = 400,
                        ExternalReference = "Seller1" + Guid.NewGuid().ToString(),
                        CollectorId = 539673000,
                        ApplicationFee = 1,
                        MoneyReleaseDays = 5,
                    },
                    new AdvancedPaymentDisbursementRequest
                    {
                        Amount = 600,
                        ExternalReference = "Seller2" + Guid.NewGuid().ToString(),
                        CollectorId = 488656838,
                        ApplicationFee = 0.5m,
                    },
                },
                Payer = new AdvancedPaymentPayerRequest
                {
                    Email = Environment.GetEnvironmentVariable("USER_EMAIL"),
                    FirstName = "Test",
                    LastName = "User",
                    Address = new AddressRequest
                    {
                        ZipCode = "06233200",
                        StreetName = "Street",
                        StreetNumber = "120",
                    },
                    Identification = IdentificationHelper.GetIdentification(User),
                },
                ExternalReference = "ADV" + Guid.NewGuid().ToString(),
                Description = "Test",
                BinaryMode = false,
                Capture = capture,
                AdditionalInfo = new AdvancedPaymentAdditionalInfoRequest
                {
                    IpAddress = "127.0.0.1",
                    Payer = new AdvancedPaymentAdditionalInfoPayerRequest
                    {
                        FirstName = "Test",
                        LastName = "User",
                        RegistrationDate = DateTime.UtcNow.AddDays(-10),
                        Address = new AddressRequest
                        {
                            ZipCode = "06233200",
                            StreetName = "Street",
                            StreetNumber = "120",
                        },
                        Phone = new PhoneRequest
                        {
                            AreaCode = "11",
                            Number = "999999999",
                        },
                    },
                    Items = new List <AdvancedPaymentItemRequest>
                    {
                        new AdvancedPaymentItemRequest
                        {
                            Id = "123",
                            Title = "Title",
                            PictureUrl = "https://www.mercadopago.com/logomp3.gif",
                            Description = "Description",
                            CategoryId = "Category",
                            Quantity = 1,
                            UnitPrice = 1000,
                        },
                    },
                    Shipments = new AdvancedPaymentShipmentsRequest
                    {
                        ReceiverAddress = new AdvancedPaymentReceiverAddressRequest
                        {
                            ZipCode = "06233200",
                            StreetName = "Street",
                            StreetNumber = "120",
                            Floor = "1",
                            Apartment = "A",
                        },
                    },
                },
                Metadata = new Dictionary <string, object>
                {
                    ["key1"] = "value1",
                },
            });
        }
        private async Task <PaymentCreateRequest> BuildCreateRequestAsync(
            bool capture, string paymentStatus)
        {
            CardToken cardToken =
                await cardTokenClient.CreateTestCardToken(User, paymentStatus);

            return(new PaymentCreateRequest
            {
                Payer = new PaymentPayerRequest
                {
                    Email = Environment.GetEnvironmentVariable("USER_EMAIL"),
                    EntityType = "individual",
                    Type = "customer",
                    Identification = IdentificationHelper.GetIdentification(User),
                    FirstName = "Test",
                    LastName = "User",
                },
                BinaryMode = false,
                Capture = capture,
                ExternalReference = Guid.NewGuid().ToString(),
                Description = "Payment description",
                Metadata = new Dictionary <string, object>
                {
                    ["key1"] = "value1",
                    ["key2"] = "value2",
                },
                TransactionAmount = 10,
                PaymentMethodId = "master",
                Token = cardToken.Id,
                Installments = 1,
                StatementDescriptor = "STAT-DESC",
                NotificationUrl = "https://seu-site.com.br/webhooks",
                CallbackUrl = "https://seu-site.com.br/callbackurl",
                ProcessingMode = "aggregator",
                DateOfExpiration = DateTime.Now.AddDays(30),
                AdditionalInfo = new PaymentAdditionalInfoRequest
                {
                    IpAddress = "127.0.0.1",
                    Items = new List <PaymentItemRequest>
                    {
                        new PaymentItemRequest
                        {
                            Id = "SKU-1",
                            Title = "Product",
                            PictureUrl = "https://www.mercadopago.com/org-img/MLB/design/2015/m_pago/logos/mp_processado_02.png",
                            Description = "Product description",
                            CategoryId = "cat",
                            Quantity = 1,
                            UnitPrice = 10,
                            Warranty = false,
                            EventDate = DateTime.Now,
                            CategoryDescriptor = new PaymentCategoryDescriptorRequest
                            {
                                Passenger = new PaymentPassengerRequest
                                {
                                    Identification = IdentificationHelper.GetIdentification(User),
                                    FirstName = "Test",
                                    LastName = "User",
                                },
                                Route = new PaymentRouteRequest
                                {
                                    ArrivalDateTime = DateTime.Now.AddDays(30),
                                    Company = "company",
                                    Departure = "derpature",
                                    DepartureDateTime = DateTime.Now.AddDays(30),
                                    Destination = "destination",
                                },
                            },
                        },
                    },
                    Payer = new PaymentAdditionalInfoPayerRequest
                    {
                        FirstName = "Test",
                        LastName = "User",
                        RegistrationDate = DateTime.Now.AddDays(-30),
                        Phone = new PhoneRequest
                        {
                            AreaCode = "11",
                            Number = "999999999",
                        },
                        Address = new AddressRequest
                        {
                            ZipCode = "0600000",
                            StreetName = "Street",
                            StreetNumber = "123",
                        },
                        AuthenticationType = "None",
                        IsFirstPurchaseOnline = false,
                        IsPrimeUser = false,
                        LastPurchase = DateTime.Now.AddDays(-10),
                    },
                    Shipments = new PaymentShipmentsRequest
                    {
                        ReceiverAddress = new PaymentReceiverAddressRequest
                        {
                            ZipCode = "0600000",
                            StreetName = "Street",
                            StreetNumber = "123",
                            Apartment = "23",
                            Floor = "First",
                            CityName = "City",
                            StateName = "State",
                        },
                        ExpressShipment = false,
                        LocalPickup = false,
                    },
                },
            });
        }
 private PreferenceRequest BuildRequest()
 {
     return(new PreferenceRequest
     {
         Items = new List <PreferenceItemRequest>
         {
             new PreferenceItemRequest
             {
                 Description = "Description",
                 Id = "123",
                 PictureUrl = "http://product.image.png",
                 Quantity = 1,
                 Title = "Title",
                 UnitPrice = 100,
             },
         },
         Payer = new PreferencePayerRequest
         {
             Email = Environment.GetEnvironmentVariable("USER_EMAIL"),
             Name = "Test",
             Surname = "User",
             Phone = new PhoneRequest
             {
                 AreaCode = "11",
                 Number = "999999999",
             },
             Identification = IdentificationHelper.GetIdentification(User),
             Address = new AddressRequest
             {
                 ZipCode = "06000000",
                 StreetName = "Street",
                 StreetNumber = "123",
             },
         },
         PaymentMethods = new PreferencePaymentMethodsRequest
         {
             ExcludedPaymentMethods = new List <PreferencePaymentMethodRequest>
             {
                 new PreferencePaymentMethodRequest
                 {
                     Id = "visa",
                 },
             },
             ExcludedPaymentTypes = new List <PreferencePaymentTypeRequest>
             {
                 new PreferencePaymentTypeRequest
                 {
                     Id = "debit_card",
                 },
             },
             DefaultPaymentMethodId = "master",
             Installments = 6,
             DefaultInstallments = 1,
         },
         Shipments = new PreferenceShipmentsRequest
         {
             Mode = "custom",
             LocalPickup = false,
             Dimensions = "10x10x20,500",
             ReceiverAddress = new PreferenceReceiverAddressRequest
             {
                 ZipCode = "06000000",
                 StreetNumber = "123",
                 StreetName = "Street",
                 Floor = "12",
                 Apartment = "120A",
             },
             Cost = 10,
         },
         BackUrls = new PreferenceBackUrlsRequest
         {
             Success = "https://seller/success",
             Pending = "https://seller/pending",
             Failure = "https://seller/failure",
         },
         NotificationUrl = "https://seller/notification",
         AdditionalInfo = "Additional info",
         AutoReturn = "all",
         ExternalReference = Guid.NewGuid().ToString(),
         Expires = true,
         ExpirationDateFrom = DateTime.Now,
         ExpirationDateTo = DateTime.Now.AddMonths(1),
         Tracks = new List <PreferenceTrackRequest>
         {
             new PreferenceTrackRequest
             {
                 Type = "google_ad",
                 Values = new PreferenceTrackValuesRequest
                 {
                     ConversionId = "1123",
                     ConversionLabel = "label",
                 },
             },
             new PreferenceTrackRequest
             {
                 Type = "facebook_ad",
                 Values = new PreferenceTrackValuesRequest
                 {
                     PixelId = "111111",
                 },
             },
         },
         BinaryMode = true,
         Taxes = new List <PreferenceTaxRequest>
         {
             new PreferenceTaxRequest
             {
                 Type = "Custom",
                 Value = 2,
             },
         },
         ProcessingModes = new List <string> {
             "aggregator",
         },
     });
 }