예제 #1
0
파일: Program.cs 프로젝트: couras/dotnet
        static void Main(string[] args)
        {
            bool isSandbox = false;
            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            // Instantiate a new preApproval request
            PreApprovalRequest preApproval = new PreApprovalRequest();

            // Sets the currency
            preApproval.Currency = Currency.Brl;

            // Sets a reference code for this preApproval request, it is useful to identify this payment in future notifications.
            preApproval.Reference = "REF1234";

            // Sets your customer information.
            preApproval.Sender = new Sender(
                "Joao Comprador",
                "*****@*****.**",
                new Phone("11", "56273440")
            );

            // Sets the preApproval informations
            var now = DateTime.Now;
            preApproval.PreApproval = new PreApproval();
            preApproval.PreApproval.Charge = Charge.Manual;
            preApproval.PreApproval.Name = "Seguro contra roubo do Notebook";
            preApproval.PreApproval.AmountPerPayment = 100.00m;
            preApproval.PreApproval.MaxAmountPerPeriod = 100.00m;
            preApproval.PreApproval.MaxPaymentsPerPeriod = 5;
            preApproval.PreApproval.Details = string.Format("Todo dia {0} será cobrado o valor de {1} referente ao seguro contra roubo do Notebook.", now.Day, preApproval.PreApproval.AmountPerPayment.ToString("C2"));
            preApproval.PreApproval.Period = Period.Monthly;
            preApproval.PreApproval.DayOfMonth = now.Day;
            preApproval.PreApproval.InitialDate = now;
            preApproval.PreApproval.FinalDate = now.AddMonths(6);
            preApproval.PreApproval.MaxTotalAmount = 600.00m;

            // Sets the url used by PagSeguro for redirect user after ends checkout process
            preApproval.RedirectUri = new Uri("http://www.lojamodelo.com.br/retorno");

            // Sets the url used for user review the signature or read the rules
            preApproval.ReviewUri = new Uri("http://www.lojamodelo.com.br/revisao");

            SenderDocument senderCPF = new SenderDocument(Documents.GetDocumentByType("CPF"), "12345678909");
            preApproval.Sender.Documents.Add(senderCPF);

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

                Uri preApprovalRedirectUri = preApproval.Register(credentials);

                Console.WriteLine("URL do pagamento : " + preApprovalRedirectUri);
                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                Console.WriteLine(exception.Message + "\n");

                foreach (ServiceError element in exception.Errors)
                {
                    Console.WriteLine(element + "\n");
                }
                Console.ReadKey();
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: couras/dotnet
        static void Main(string[] args)
        {
            PagSeguroConfiguration.UrlXmlConfiguration = ".../.../.../.../.../Configuration/PagSeguroConfig.xml";

            bool isSandbox = false;
            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            // Instantiate a new checkout
            CreditCardCheckout checkout = new CreditCardCheckout();

            // Sets the payment mode
            checkout.PaymentMode = PaymentMode.DEFAULT;

            // Sets the receiver e-mail should will get paid
            checkout.ReceiverEmail = "*****@*****.**";

            // Sets the currency
            checkout.Currency = Currency.Brl;

            // Add items
            checkout.Items.Add(new Item("0001", "Notebook Prata", 2, 2000.00m));
            checkout.Items.Add(new Item("0002", "Notebook Rosa", 2, 150.99m));

            // Sets a reference code for this checkout, it is useful to identify this payment in future notifications.
            checkout.Reference = "REF1234";

            // Sets shipping information for this payment request
            checkout.Shipping = new Shipping();
            checkout.Shipping.ShippingType = ShippingType.Sedex;
            checkout.Shipping.Cost = 0.00m;
            checkout.Shipping.Address = new Address(
                "BRA",
                "SP",
                "Sao Paulo",
                "Jardim Paulistano",
                "01452002",
                "Av. Brig. Faria Lima",
                "1384",
                "5o andar"
            );

            // Sets your customer information.
            // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br
            checkout.Sender = new Sender(
                "Joao Comprador",
                "*****@*****.**",
                new Phone("11", "56273440")
            );

            SenderDocument senderCPF = new SenderDocument(Documents.GetDocumentByType("CPF"), "12345678909");
            checkout.Sender.Documents.Add(senderCPF);

            // Sets credit card token.
            checkout.Token = "1f31f3de024e4e5f8539d84cbc8b2a49";

            //Sets installments information
            checkout.Installment = new Installment(1, 50.00m);

            // Sets the url used by PagSeguro for redirect user after ends checkout process
            checkout.NotificationURL = "http://www.lojamodelo.com.br";

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);
                Transaction result = TransactionService.CreateCheckout(credentials, checkout);
                Console.WriteLine(result);
                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                Console.WriteLine(exception.Message + "\n");
                foreach (ServiceError element in exception.Errors)
                {
                    Console.WriteLine(element + "\n");
                }
                Console.ReadKey();
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: rrispoli/dotnet
        static void Main(string[] args)
        {
            // TODO: Substitute the parameters below with your credentials
            //AccountCredentials credentials = new AccountCredentials("*****@*****.**", "your_token_here");
            AccountCredentials credentials = PagSeguroConfiguration.Credentials;

            try
            {

                // Instantiate a new payment request
                PaymentRequest payment = new PaymentRequest();

                // Sets the currency
                payment.Currency = Currency.Brl;

                // Add an item for this payment request
                payment.Items.Add(new Item("0001", "Notebook Prata", 1, 2430.00m));

                // Add another item for this payment request
                payment.Items.Add(new Item("0002", "Notebook Rosa", 2, 150.99m));

                // Sets a reference code for this payment request, it is useful to identify this payment in future notifications.
                payment.Reference = "REF1234";

                // Sets shipping information for this payment request
                payment.Shipping = new Shipping();
                payment.Shipping.ShippingType = ShippingType.Sedex;

                //Passando valor para ShippingCost
                payment.Shipping.Cost = 10.00m;

                payment.Shipping.Address = new Address(
                    "BRA",
                    "SP",
                    "Sao Paulo",
                    "Jardim Paulistano",
                    "01452002",
                    "Av. Brig. Faria Lima",
                    "1384",
                    "5o andar"
                );

                // Sets your customer information.
                payment.Sender = new Sender(
                    "Joao Comprador",
                    "*****@*****.**",
                    new Phone("11", "56273440")
                );

                // Sets the url used by PagSeguro for redirect user after ends checkout process
                payment.RedirectUri = new Uri("http://www.lojamodelo.com.br");

                // Add checkout metadata information
                payment.AddMetaData(MetaDataItemKeys.GetItemKeyByDescription("CPF do passageiro"), "123.456.789-09", 1);
                payment.AddMetaData("PASSENGER_PASSPORT", "23456", 1);

                // Another way to set checkout parameters
                payment.AddParameter("senderBirthday", "07/05/1980");
                payment.AddIndexedParameter("itemColor", "verde", 1);
                payment.AddIndexedParameter("itemId", "0003", 3);
                payment.AddIndexedParameter("itemDescription", "Mouse", 3);
                payment.AddIndexedParameter("itemQuantity", "1", 3);
                payment.AddIndexedParameter("itemAmount", "200.00", 3);

                SenderDocument senderCPF = new SenderDocument(Documents.GetDocumentByType("CPF"), "12345678909");
                payment.Sender.Documents.Add(senderCPF);

                // Sets the preApproval informations
                payment.PreApproval = new PreApproval();
                var now = DateTime.Now;

                // Only works with Manual
                payment.PreApproval.Charge = Charge.Manual;

                payment.PreApproval.Name = "Seguro contra roubo do Notebook";
                payment.PreApproval.AmountPerPayment = 100.00m;
                payment.PreApproval.MaxAmountPerPeriod = 100.00m;
                payment.PreApproval.Details = string.Format("Todo dia {0} será cobrado o valor de {1} referente ao seguro contra roubo do Notebook.", now.Day, payment.PreApproval.AmountPerPayment.ToString("C2"));
                payment.PreApproval.Period = Period.Monthly;
                payment.PreApproval.DayOfMonth = now.Day;
                payment.PreApproval.InitialDate = now;
                payment.PreApproval.FinalDate = now.AddMonths(6);
                payment.PreApproval.MaxTotalAmount = 600.00m;
                payment.PreApproval.MaxPaymentsPerPeriod = 1;

                payment.ReviewUri = new Uri("http://www.lojamodelo.com.br/revisao");

                Uri paymentRedirectUri = payment.Register(credentials);

                Console.WriteLine("URL do pagamento : " + paymentRedirectUri);
                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                if (exception.StatusCode == HttpStatusCode.Unauthorized)
                {
                    Console.WriteLine("Unauthorized: please verify if the credentials used in the web service call are correct.\n");
                }
                Console.ReadKey();
            }
        }
예제 #4
0
파일: Program.cs 프로젝트: pagseguro/dotnet
        static void Main(string[] args)
        {
            PagSeguroConfiguration.UrlXmlConfiguration = ".../.../.../.../.../Configuration/PagSeguroConfig.xml";

            bool isSandbox = false;
            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            // Instantiate a new checkout
            OnlineDebitCheckout checkout = new OnlineDebitCheckout();

            // Sets the payment mode
            checkout.PaymentMode = PaymentMode.DEFAULT;

            // Sets the receiver e-mail should will get paid
            checkout.ReceiverEmail = "*****@*****.**";

            // Sets the currency
            checkout.Currency = Currency.Brl;

            // Add items
            checkout.Items.Add(new Item("0001", "Notebook Prata", 1, 1300.00m));
            checkout.Items.Add(new Item("0002", "Notebook Rosa", 1, 150.99m));

            // Sets a reference code for this checkout, it is useful to identify this payment in future notifications.
            checkout.Reference = "REF1234";

            // Sets shipping information for this payment request
            checkout.Shipping = new Shipping();
            checkout.Shipping.ShippingType = ShippingType.Sedex;
            checkout.Shipping.Cost = 0.00m;
            checkout.Shipping.Address = new Address(
                "BRA",
                "SP",
                "Sao Paulo",
                "Jardim Paulistano",
                "01452002",
                "Av. Brig. Faria Lima",
                "1384",
                "5o andar"
            );

            // Sets your customer information.
            // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br
            checkout.Sender = new Sender(
                "Joao Comprador",
                "*****@*****.**",
                new Phone("11", "56273440")
            );
            checkout.Sender.Hash = "b2806d600653cbb2b195f317ca9a1a58738187a02c05bf7f2280e2076262e73b";
            SenderDocument senderCPF = new SenderDocument(Documents.GetDocumentByType("CPF"), "12345678909");
            checkout.Sender.Documents.Add(senderCPF);

            // Sets the notification url
            checkout.NotificationURL = "http://www.lojamodelo.com.br";

            // Sets the bank information
            checkout.BankName = BankName.Bradesco;

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);
                Transaction result = TransactionService.CreateCheckout(credentials, checkout);

                Console.WriteLine(result);
                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                Console.WriteLine(exception.Message + "\n");

                foreach (ServiceError element in exception.Errors)
                {
                    Console.WriteLine(element + "\n");
                }
                Console.ReadKey();
            }
        }
예제 #5
0
파일: Program.cs 프로젝트: Japle/dotnet
        static void Main(string[] args)
        {
            bool isSandbox = true;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            try
            {

                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

                // Instantiate a new payment request
                PaymentRequest payment = new PaymentRequest();

                // Sets the currency
                payment.Currency = Currency.Brl;

                // Add an item for this payment request
                payment.Items.Add(new Item("0001", "Notebook Prata", 1, 2430.00m));

                // Add another item for this payment request
                payment.Items.Add(new Item("0002", "Notebook Rosa", 2, 150.99m));

                // Sets a reference code for this payment request, it is useful to identify this payment in future notifications.
                payment.Reference = "REF1234";

                // Sets shipping information for this payment request
                payment.Shipping = new Shipping();
                payment.Shipping.ShippingType = ShippingType.Sedex;

                //Passando valor para ShippingCost
                payment.Shipping.Cost = 10.00m;

                payment.Shipping.Address = new Address(
                    "BRA",
                    "SP",
                    "Sao Paulo",
                    "Jardim Paulistano",
                    "01452002",
                    "Av. Brig. Faria Lima",
                    "1384",
                    "5o andar"
                );

                // Sets your customer information.
                payment.Sender = new Sender(
                    "Joao Comprador",
                    "*****@*****.**",
                    new Phone("11", "56273440")
                );

                // Sets the url used by PagSeguro for redirect user after ends checkout process
                payment.RedirectUri = new Uri("http://www.lojamodelo.com.br");

                // Add checkout metadata information
                payment.AddMetaData(MetaDataItemKeys.GetItemKeyByDescription("CPF do passageiro"), "123.456.789-09", 1);
                payment.AddMetaData("PASSENGER_PASSPORT", "23456", 1);

                // Another way to set checkout parameters
                payment.AddParameter("senderBirthday", "07/05/1980");
                payment.AddIndexedParameter("itemColor", "verde", 1);
                payment.AddIndexedParameter("itemId", "0003", 3);
                payment.AddIndexedParameter("itemDescription", "Mouse", 3);
                payment.AddIndexedParameter("itemQuantity", "1", 3);
                payment.AddIndexedParameter("itemAmount", "200.00", 3);

                SenderDocument senderCPF = new SenderDocument(Documents.GetDocumentByType("CPF"), "12345678909");
                payment.Sender.Documents.Add(senderCPF);

                Uri paymentRedirectUri = payment.Register(credentials);

                Console.WriteLine("URL do pagamento : " + paymentRedirectUri);
                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                Console.WriteLine(exception.Message + "\n");

                foreach (ServiceError element in exception.Errors)
                {
                    Console.WriteLine(element + "\n");
                }
                Console.ReadKey();
            }
        }
예제 #6
0
파일: Program.cs 프로젝트: rrispoli/dotnet
        static void Main(string[] args)
        {
            // TODO: Substitute the parameters below with your credentials
            //AccountCredentials credentials = new AccountCredentials("*****@*****.**", "your_token_here");
            AccountCredentials credentials = PagSeguroConfiguration.Credentials;

            try
            {
                // Instantiate a new preApproval request
                PreApprovalRequest preApproval = new PreApprovalRequest();

                // Sets the currency
                preApproval.Currency = Currency.Brl;

                // Sets a reference code for this preApproval request, it is useful to identify this payment in future notifications.
                preApproval.Reference = "REF1234";

                // Sets your customer information.
                preApproval.Sender = new Sender(
                    "Joao Comprador",
                    "*****@*****.**",
                    new Phone("11", "56273440")
                );

                // Sets the preApproval informations
                var now = DateTime.Now;
                preApproval.PreApproval = new PreApproval();
                preApproval.PreApproval.Charge = Charge.Auto;
                preApproval.PreApproval.Name = "Seguro contra roubo do Notebook";
                preApproval.PreApproval.AmountPerPayment = 100.00m;
                preApproval.PreApproval.MaxAmountPerPeriod = 100.00m;
                preApproval.PreApproval.Details = string.Format("Todo dia {0} será cobrado o valor de {1} referente ao seguro contra roubo do Notebook.", now.Day, preApproval.PreApproval.AmountPerPayment.ToString("C2"));
                preApproval.PreApproval.Period = Period.Monthly;
                preApproval.PreApproval.DayOfMonth = now.Day;
                preApproval.PreApproval.InitialDate = now;
                preApproval.PreApproval.FinalDate = now.AddMonths(6);
                preApproval.PreApproval.MaxTotalAmount = 600.00m;

                // Sets the url used by PagSeguro for redirect user after ends checkout process
                preApproval.RedirectUri = new Uri("http://www.lojamodelo.com.br/retorno");

                // Sets the url used for user review the signature or read the rules
                preApproval.ReviewUri = new Uri("http://www.lojamodelo.com.br/revisao");

                SenderDocument senderCPF = new SenderDocument(Documents.GetDocumentByType("CPF"), "12345678909");
                preApproval.Sender.Documents.Add(senderCPF);

                Uri preApprovalRedirectUri = preApproval.Register(credentials);

                Console.WriteLine("URL do pagamento : " + preApprovalRedirectUri);
                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                if (exception.StatusCode == HttpStatusCode.Unauthorized)
                {
                    Console.WriteLine("Unauthorized: please verify if the credentials used in the web service call are correct.\n");
                }
                Console.ReadKey();
            }
        }
예제 #7
0
파일: Program.cs 프로젝트: pagseguro/dotnet
        static void Main(string[] args)
        {
            //Use global configuration
            //PagSeguroConfiguration.UrlXmlConfiguration = "../../../../../Configuration/PagSeguroConfig.xml";

            bool isSandbox = false;
            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            // Instantiate a new payment request
            PaymentRequest payment = new PaymentRequest();

            // Sets the currency
            payment.Currency = Currency.Brl;

            // Add an item for this payment request
            payment.Items.Add(new Item("0001", "Notebook Prata", 1, 2430.00m));

            // Add another item for this payment request
            payment.Items.Add(new Item("0002", "Notebook Rosa", 2, 150.99m));

            // Sets a reference code for this payment request, it is useful to identify this payment in future notifications.
            payment.Reference = "REF1234";

            // Sets shipping information for this payment request
            payment.Shipping = new Shipping();
            payment.Shipping.ShippingType = ShippingType.Sedex;

            //Passando valor para ShippingCost
            payment.Shipping.Cost = 10.00m;

            payment.Shipping.Address = new Address(
                "BRA",
                "SP",
                "Sao Paulo",
                "Jardim Paulistano",
                "01452002",
                "Av. Brig. Faria Lima",
                "1384",
                "5o andar"
            );

            // Sets your customer information.
            payment.Sender = new Sender(
                "Joao Comprador",
                "*****@*****.**",
                new Phone("11", "56273440")
            );

            SenderDocument document = new SenderDocument(Documents.GetDocumentByType("CPF"), "12345678909");
            payment.Sender.Documents.Add(document);

            // Sets the url used by PagSeguro for redirect user after ends checkout process
            payment.RedirectUri = new Uri("http://www.lojamodelo.com.br");

            // Add checkout metadata information
            payment.AddMetaData(MetaDataItemKeys.GetItemKeyByDescription("CPF do passageiro"), "123.456.789-09", 1);
            payment.AddMetaData("PASSENGER_PASSPORT", "23456", 1);

            // Another way to set checkout parameters
            payment.AddParameter("senderBirthday", "07/05/1980");
            payment.AddIndexedParameter("itemColor", "verde", 1);
            payment.AddIndexedParameter("itemId", "0003", 3);
            payment.AddIndexedParameter("itemDescription", "Mouse", 3);
            payment.AddIndexedParameter("itemQuantity", "1", 3);
            payment.AddIndexedParameter("itemAmount", "200.00", 3);

            // Add discount per payment method
            payment.AddPaymentMethodConfig(PaymentMethodConfigKeys.DiscountPercent, 50.00, PaymentMethodGroup.CreditCard);

            // Add installment without addition per payment method
            payment.AddPaymentMethodConfig(PaymentMethodConfigKeys.MaxInstallmentsNoInterest, 6, PaymentMethodGroup.CreditCard);

            // Add installment limit per payment method
            payment.AddPaymentMethodConfig(PaymentMethodConfigKeys.MaxInstallmentsLimit, 8, PaymentMethodGroup.CreditCard);

            // Add and remove groups and payment methods
            List<string> accept = new List<string>();
            accept.Add(ListPaymentMethodNames.DebitoItau);
            accept.Add(ListPaymentMethodNames.DebitoHSBC);
            payment.AcceptPaymentMethodConfig(ListPaymentMethodGroups.CreditCard, accept);

            List<string> exclude = new List<string>();
            exclude.Add(ListPaymentMethodNames.Boleto);
            payment.ExcludePaymentMethodConfig(ListPaymentMethodGroups.Boleto, exclude);

            try
            {
                /// Create new account credentials
                /// This configuration let you set your credentials from your ".cs" file.
                AccountCredentials credentials = new AccountCredentials("*****@*****.**", "256422BF9E66458CA3FE41189AD1C94A");

                /// @todo with you want to get credentials from xml config file uncommend the line below and comment the line above.
                //AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

                Uri paymentRedirectUri = payment.Register(credentials);

                Console.WriteLine("URL do pagamento : " + paymentRedirectUri);
                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                Console.WriteLine(exception.Message + "\n");

                foreach (ServiceError element in exception.Errors)
                {
                    Console.WriteLine(element + "\n");
                }
                Console.ReadKey();
            }
        }