Crear Orden

Crea una orden nueva.

Argumentos

Tipo

Descripción

currency

string

Divisa con la cual se realizará el cobro. Utiliza el código de 3 letras del Estándar Internacional ISO 4217.

line_items

list

Lista de los productos que se venden en la orden. Debe tener al menos un producto.

shipping_lines

list

Lista de los costos de envío. Si la tienda en línea ofrece productos digitales, este parámetro es opcional.

tax_lines

list (opcional)

Lista de los impuestos que se pagan.

discount_lines

list (opcional)

Lista de los descuentos que se aplican a la orden.

pre_authorize

boolean (opcional)

Indica si los cargos de la orden deben ser preautorizados.

customer_info

hash

Hash que contiene la información del cliente.

customer_id

string

ID del cliente. Es obligatorio cuando no se envían los otros campos de customer_info.

name

string

Nombre del cliente. (opcional si se envía el id)

phone

string

Teléfono del cliente. (opcional si se envía el id)

email

string

Email del cliente. (opcional si se envía el id)

corporate

boolean

Booleano que indica si el usuario es corporativo o no, el default es false. (opcional)

shipping_contact

hash

Detalles del envío, obligatorio en caso de mandar un shipping_line. Si no recibimos un shipping_contact en la orden, se utilizará el shipping_contact del customer por default.

charges

list

Lista de los cargos que se generaron para cubrir el monto de la orden.

checkout

Hash

Hash que contiene la información sobre las opciones de la integración del checkout.

Conekta::Order.create({
  currency: "MXN",
  customer_info: {
    customer_id: "cus_zzmjKsnM9oacyCwV3",
    antifraud_info: {
      paid_transactions: 4
    }
  },
  line_items: [{
    name: "Box of Cohiba S1s",
    unit_price: 35000,
    quantity: 1,
    antifraud_info: {
      trip_id: "12345",
      driver_id: "driv_1231",
      ticket_class: "economic",
      pickup_latlon: "23.4323456,-123.1234567",
      dropoff_latlon: "23.4323456,-123.1234567"
    }
  }],
  charges: [{
    payment_method: {
      type: "default"
    }
  }]
})
curl -H "Accept: application/vnd.conekta-v2.0.0+json" \
     -H "Content-type: application/json" \
     -u key_eYvWV7gSDkNYXsmr: \
     -X POST -d '{
        "currency": "MXN",
        "customer_info": {
          "customer_id": "cus_zzmjKsnM9oacyCwV3",
          "antifraud_info": {
            "paid_transactions": 4
          }
        },
        "line_items": [{
          "name": "Box of Cohiba S1s",
          "unit_price": 35000,
          "quantity": 1,
          "antifraud_info": {
            "trip_id": "12345",
            "driver_id": "driv_1231",
            "ticket_class": "economic",
            "pickup_latlon": "23.4323456,-123.1234567",
            "dropoff_latlon": "23.4323456,-123.1234567"
          }
        }],
        "charges": [{
          "payment_method": {
            "type": "default"
          }
        }]
      }' https://api.conekta.io/orders
\Conekta\Order::create([
  'currency' => 'MXN',
  'customer_info' => [
    'customer_id' => 'cus_zzmjKsnM9oacyCwV3',
    'antifraud_info' => [
      'paid_transactions' => 4
    ]
  ]
  'line_items' => [
    [
      'name' => 'Box of Cohiba S1s',
      'unit_price' => 35000,
      'quantity' => 1,
      'antifraud_info' => [
          'trip_id'        => '12345',
          'driver_id'      => 'driv_1231',
          'ticket_class'   => 'economic',
          'pickup_latlon'  => '23.4323456,-123.1234567',
          'dropoff_latlon' => '23.4323456,-123.1234567'
      ]
    ]
  ],
  'charges' => [
    [
      'payment_method' => [
        'type' => 'default'
      ]
    ]
  ]
]);
conekta.Order.create({
  "currency": "MXN",
  "customer_info": {
    "customer_id": "cus_zzmjKsnM9oacyCwV3",
    "antifraud_info": {
      "paid_transactions": 4
    }
  },
  "line_items": [{
    "name": "Box of Cohiba S1s",
    "unit_price": 35000,
    "quantity": 1,
    "antifraud_info": {
      "trip_id": "12345",
      "driver_id": "driv_1231",
      "ticket_class": "economic",
      "pickup_latlon": "23.4323456,-123.1234567",
      "dropoff_latlon": "23.4323456,-123.1234567"
    }
  }],
  "charges": [{
    "payment_method": {
      "type": "default"
    }
  }]
}, function(err, order) {
    console.log(order.toObject());
})
conekta.Order.create({
  "currency": "MXN",
  "customer_info": {
    "customer_id": "cus_zzmjKsnM9oacyCwV3"
  },
  "line_items": [{
    "name": "Box of Cohiba S1s",
    "unit_price": 35000,
    "quantity": 1
  }],
  "charges": [{
    "payment_method": {
      "type": "default"
    }
  }]
})
Order.create(new JSONObject("{"
    + "'currency': 'MXN', "
    + "'customer_info': {"
        + "'customer_id': 'cus_zzmjKsnM9oacyCwV3',"
        + "'antifraud_info': {"
        +   "'paid_transactions': 4"
        + "}"
    + "},"
    + "'line_items': [{"
        + "'name': 'Box of Cohiba S1s',"
        + "'unit_price': 35000,"
        + "'quantity': 1,"
        + "'antifraud_info': {"
            + "'trip_id': '12345',"
            + "'driver_id': 'driv_1231',"
            + "'ticket_class': 'economic',"
            + "'pickup_latlon': '23.4323456,-123.1234567',"
            + "'dropoff_latlon': '23.4323456,-123.1234567'"
        + "}"
    + "}],"
    + "'charges': [{"
        + "'payment_method': {"
            + "'type': 'default'"
        + "}"
    + "}]"
+ "}"));
Order order = new conekta.Order().create(@"{
  ""currency"":""MXN"",
  ""customer_info"": {
    ""customer_id"": ""cus_zzmjKsnM9oacyCwV3"",
    ""antifraud_info"": {
      ""paid_transactions"": 4
    }
  },
  ""line_items"": [{
    ""name"": ""Box of Cohiba S1s"",
    ""unit_price"": 35000,
    ""quantity"": 1,
    ""antifraud_info"": {
      ""trip_id"": ""12345"",
      ""driver_id"": ""5f671gaqg1"",
      ""ticket_class"": ""X"",
      ""driver_id"": ""5f671gaqg1"",
      ""pickup_latlon"": ""19.4153209,-99.1804722"",
      ""dropoff_latlon"": ""19.434606,-99.1639283""
    }
  }],
  ""charges"": [{
    ""payment_method"": {
      ""type"": ""default""
    }
  }]
}");
import  (
    conekta "github.com/conekta/conekta-go"
    "github.com/conekta/conekta-go/order"
)

Address := &conekta.Address{
        Street1:    "Street1",
        Street2:    "Street2",
        City:       "City",
        State:      "State",
        Country:    "Country",
        PostalCode: "PostalCode", 
    }

    customerParams := &conekta.CustomerParams{
        Name:  "name_customer",
        Email: "[email protected]",
        Phone: "55-5555-5555",  
    }

    lineItemParams := &conekta.LineItemsParams{
        Name:      "Naranjas Robadas",
        UnitPrice: 10000,
        Quantity:  2, 
    }

    shippingParams := &conekta.ShippingLinesParams{
        Amount:         200,
        TrackingNumber: "123",
        Carrier:        "Test Carrier",
        Method:         "method", 
    }

    shippingContactParams := &conekta.ShippingContactParams{
        Phone:          "55-5555-5555",
        Receiver:       "Miguel",
        BetweenStreets: "BetweenStreets",
        Address:        Address,  
    }

    chargeParams := &conekta.ChargeParams{
        PaymentMethod: &conekta.PaymentMethodParams{
            Type:    "card",
            TokenID: "tok_test_visa_4242",  
            //ExpiresAt: time.Now().AddDate(0, 0, 90).Unix(),
            //ExpiresAt es para usar en caso de enviar cargo tipo oxxo. Reemplazar por TokenID
        },
    }

    orderParams := &conekta.OrderParams{}
    orderParams.Currency = "MXN"
    orderParams.CustomerInfo = customerParams
    orderParams.PreAuth =  true //en caso de no pasar este parametro, procesar la orden no podrá ser posible
    orderParams.LineItems = append(orderParams.LineItems, lineItemParams)
    orderParams.ShippingLines = append(orderParams.ShippingLines, shippingParams)
    orderParams.ShippingContact = shippingContactParams
    orderParams.Charges = append(orderParams.Charges, chargeParams)


    order.Create(orderParams)