Para crair um pedido, voce precisa chamar o método PayOrder. Veja um exemplo abaixo:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using CobreDireto.net;

        protected void btnCriarPedido_Click(object sender, EventArgs e)

        {

            CobreDireto.net.PayOrder p = new net.PayOrder()

            {

                OrderData = new OrderData()

                {

                    MerchantReference = Guid.NewGuid().ToString(),

                    TaxFreight = "0000",

                    OrderSubtotal = "200", //Dois Reais

                    OrderTotal = "200", // Dois Reais

                    OrderItems = new List<OrderItem>() {

                        new OrderItem(){ Code = "1", Description="Produto 1", Units=1, UnitValue="100" /*Um real*/},

                        new OrderItem(){ Code = "2", Description="Produto 2", Units=1, UnitValue="100" /*Um real*/}

                    }

                },

                BehaviorData = new BehaviorData()

                {

                    UrlPostBell =  "http://www.meusite.com.br/postbell.aspx",

                    UrlRedirectError = "http://www.meusite.com.br/error.aspx",

                    UrlRedirectSuccess = "http://www.meusite.com.br/sucess.aspx"

                },

                PaymentData = new PaymentData()

                {

                    Payment = new PaymentData.PaymentChoice()

                    {

 

                        //Installments = 1,

                        PaymentMethod = PaymentMethod.boleto_bb

                    }

                },

                CustomerData = new CustomerData()

                {

                    CustomerInfo = new CustomerItem()

                    {

                        AddressZip = "7030040000",

                        Document = "12345678909",

                        Email = "penihel@gmail.com",

                        FirstName = "Penihel",

                        LastName = "Moreira",

                        MiddleName = "Roosewelt",

                        PhoneHome = new Phone() { AreaCode = "61", PhoneNumber = "55555555" }

                    },

                    BillingInfo = new CustomerItem()

                    {

                        AddressZip = "70000000",

                        Document = "12345678909",

                        Email = "penihel@gmail.com",

                        FirstName = "Penihel",

                        LastName = "Moreira",

                        MiddleName = "Roosewelt",

                        PhoneHome = new Phone() { AreaCode = "61", PhoneNumber = "55555555" }

                    },

                    ShipmentInfo = new CustomerItem()

                    {

                        AddressZip = "70000000",

                        Document = "12345678909",

                        Email = "penihel@gmail.com",

                        FirstName = "Penihel",

                        LastName = "Moreira",

                        MiddleName = "Roosewelt",

                        PhoneHome = new Phone() { AreaCode = "61", PhoneNumber = "55555555" }

                    }

                }

            };

 

            try

            {

                PayOrderReturn x = CobreDireto.net.Manager.PayOrder(p);

                Response.Redirect(x.BPagData.Url);

            }

            catch (Exception ex)

            {

 

                txt.Text = ex.Message;

            }

 

           

        }

 

 

 



Last edited Nov 8, 2010 at 11:58 AM by penihel, version 4

Comments

No comments yet.