Una orden representa una compra. Incluye todos los detalles relacionados a ella, como método de pago, envío, productos comprados, cargos, descuentos e impuestos.
Objeto Orden
Atributos
Tipo | Descripción | |
---|---|---|
id | string | Identificador único de la orden asignado al azar. |
object | string | Clase del objeto. En este caso, "order". |
created_at | integer (32-bit unix timestamp) | Fecha de creación de la orden. |
updated_at | integer (32-bit unix timestamp) | Fecha de la última actualización de la orden. |
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. |
livemode | boolean | true: Modo de producción. false: Modo de prueba |
metadata | hash | Hash en donde el usuario puede enviar información adicional para la orden. |
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. |
amount | integer | Cantidad que se calcula por el sistema a partir de 'line_items', 'shipipng_lines', 'tax_lines' y 'discount_lines'. |
amount_refunded | integer | Cantidad a la cual se hizo un refund a través de la llamada a orders/:order_id/refund. |
payment_status | string | El status del pago de la orden. Este campo es controlado por el sistema y puede ser pending_payment, declined, expired, paid, refunded, partially_refunded, charged_back, pre_authorized y voided. |
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 ) |
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) |
antifraud_info | hash | Información relevante de la actividad de la empresa. |
paid_transactions | integer | Número de transacciones del cliente. |
account_created_at | integer (32-bit unix timestamp) | Fecha de cuando fue creada la cuenta. (opcional si se envía 'customer'.) |
first_paid_at | integer (32-bit unix timestamp) | Fecha de la primera compra exitosa del cliente. (opcional si se envía 'customer'_info.) |
charges | list | Lista de los cargos que se generaron para cubrir el monto de la orden. |
puts order.inspect
{
id: "ord_2fw8EWJusiRrxdPzT",
object: "order",
livemode: false,
amount: 35000,
amount_refunded: 0,
payment_status: "paid",
currency: "MXN",
customer_info: {
object: "customer_info",
customer_id: "cus_zzmjKsnM9oacyCwV3",
name: "Mario Perez",
email: "[email protected]",
phone: "+5215555555555",
antifraud_info: {
account_created_at: 1484040996,
first_paid_at: 1485151007,
paid_transactions: 4
}
},
created_at: 1597069682,
updated_at: 1597069682,
line_items: {
object: "list",
has_more: false,
total: 1,
data: [{
id: "line_item_2fw8EWJusiRrxdPzR",
object: "line_item",
name: "Box of Cohiba S1s",
unit_price: 35000,
quantity: 1,
parent_id: "ord_2fw8EWJusiRrxdPzT",
antifraud_info: {
trip_id: "12345",
driver_id: "driv_1231",
ticket_type: "economic",
pickup_latlon: "23.4323456,-123.1234567",
dropoff_latlon: "23.4323456,-123.1234567"
},
metadata: {}
}]
},
charges: {
object: "list",
has_more: false,
total: 1,
data: [{
id: "589026bbedbb6e56430016ad",
object: "charge",
livemode: false,
created_at: 1597069682,
status: "paid",
amount: 35000,
paid_at: 1485842112,
currency: "MXN",
fee: 1467,
customer_id: "",
order_id: "ord_2fw8EWJusiRrxdPzT",
payment_method: {
object: "card_payment",
type: "credit",
name: "Jorge Lopez",
exp_month: "12",
exp_year: "19",
auth_code: "490884",
last4: "4242",
brand: "visa",
issuer: "",
account_type: "",
country: "MX",
fraud_score: 29,
fraud_indicators: []
}
}]
},
metadata: {}
}
{
"id": "ord_2fw8EWJusiRrxdPzT",
"object": "order",
"livemode": false,
"amount": 35000,
"amount_refunded": 0,
"payment_status": "paid",
"currency": "MXN",
"customer_info": {
"object": "customer_info",
"customer_id": "cus_zzmjKsnM9oacyCwV3",
"name": "Mario Perez",
"email": "[email protected]",
"phone": "+5215555555555",
"antifraud_info":{
"account_created_at": 1484040996,
"first_paid_at": 1485151007,
"paid_transactions": 4
}
},
"created_at": 1597069682,
"updated_at": 1597069682,
"line_items": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "line_item_2fw8EWJusiRrxdPzR",
"object": "line_item",
"name": "Box of Cohiba S1s",
"unit_price": 35000,
"quantity": 1,
"parent_id": "ord_2fw8EWJusiRrxdPzT",
"antifraud_info": {
"trip_id": "12345",
"driver_id": "driv_1231",
"ticket_class": "economic",
"pickup_latlon": "23.4323456,-123.1234567",
"dropoff_latlon": "23.4323456,-123.1234567"
},
"metadata": {}
}]
},
"charges": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "589026bbedbb6e56430016ad",
"object": "charge",
"livemode": false,
"created_at": 1597069682,
"status": "paid",
"amount": 35000,
"paid_at": 1485842112,
"currency": "MXN",
"fee": 1467,
"customer_id": "",
"order_id": "ord_2fw8EWJusiRrxdPzT",
"payment_method": {
"object": "card_payment",
"type": "credit",
"name": "Jorge Lopez",
"exp_month": "12",
"exp_year": "19",
"auth_code": "490884",
"last4": "4242",
"brand": "visa",
"issuer": "",
"account_type": "",
"country": "MX",
"fraud_score": 29,
"fraud_indicators": []
}
}]
},
"metadata": {}
}
echo $order
{
"id": "ord_2fw8EWJusiRrxdPzT",
"object": "order",
"livemode": false,
"amount": 35000,
"amount_refunded": 0,
"payment_status": "paid",
"currency": "MXN",
"customer_info": {
"object": "customer_info",
"customer_id": "cus_zzmjKsnM9oacyCwV3",
"name": "Mario Perez",
"email": "[email protected]",
"phone": "+5215555555555",
"antifraud_info":{
"account_created_at": 1484040996,
"first_paid_at": 1485151007,
"paid_transactions": 4
}
},
"created_at": 1597069682,
"updated_at": 1597069682,
"line_items": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "line_item_2fw8EWJusiRrxdPzR",
"object": "line_item",
"name": "Box of Cohiba S1s",
"unit_price": 35000,
"quantity": 1,
"parent_id": "ord_2fw8EWJusiRrxdPzT",
"antifraud_info": {
"trip_id": "12345",
"driver_id": "driv_1231",
"ticket_class": "economic",
"pickup_latlon": "23.4323456,-123.1234567",
"dropoff_latlon": "23.4323456,-123.1234567"
},
"metadata": {}
}]
},
"charges": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "589026bbedbb6e56430016ad",
"object": "charge",
"livemode": false,
"created_at": 1597069682,
"status": "paid",
"amount": 35000,
"paid_at": 1485842112,
"currency": "MXN",
"fee": 1467,
"customer_id": "",
"order_id": "ord_2fw8EWJusiRrxdPzT",
"payment_method": {
"object": "card_payment",
"type": "credit",
"name": "Jorge Lopez",
"exp_month": "12",
"exp_year": "19",
"auth_code": "490884",
"last4": "4242",
"brand": "visa",
"issuer": "",
"account_type": "",
"country": "MX",
"fraud_score": 29,
"fraud_indicators": []
}
}]
},
"metadata": {}
}
console.log(order);
{
"id": "ord_2fw8EWJusiRrxdPzT",
"object": "order",
"livemode": false,
"amount": 35000,
"amount_refunded": 0,
"payment_status": "paid",
"currency": "MXN",
"customer_info": {
"object": "customer_info",
"customer_id": "cus_zzmjKsnM9oacyCwV3",
"name": "Mario Perez",
"email": "[email protected]",
"phone": "+5215555555555",
"antifraud_info":{
"account_created_at": 1484040996,
"first_paid_at": 1485151007,
"paid_transactions": 4
}
},
"created_at": 1597069682,
"updated_at": 1597069682,
"line_items": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "line_item_2fw8EWJusiRrxdPzR",
"object": "line_item",
"name": "Box of Cohiba S1s",
"unit_price": 35000,
"quantity": 1,
"parent_id": "ord_2fw8EWJusiRrxdPzT",
"antifraud_info": {
"trip_id": "12345",
"driver_id": "driv_1231",
"ticket_class": "economic",
"pickup_latlon": "23.4323456,-123.1234567",
"dropoff_latlon": "23.4323456,-123.1234567"
},
"metadata": {}
}]
},
"charges": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "589026bbedbb6e56430016ad",
"object": "charge",
"livemode": false,
"created_at": 1597069682,
"status": "paid",
"amount": 35000,
"paid_at": 1485842112,
"currency": "MXN",
"fee": 1467,
"customer_id": "",
"order_id": "ord_2fw8EWJusiRrxdPzT",
"payment_method": {
"object": "card_payment",
"type": "credit",
"name": "Jorge Lopez",
"exp_month": "12",
"exp_year": "19",
"auth_code": "490884",
"last4": "4242",
"brand": "visa",
"issuer": "",
"account_type": "",
"country": "MX",
"fraud_score": 29,
"fraud_indicators": []
}
}]
},
"metadata": {}
}
print order
{
"id": "ord_2fw8EWJusiRrxdPzT",
"object": "order",
"livemode": false,
"amount": 35000,
"amount_refunded": 0,
"payment_status": "paid",
"currency": "MXN",
"customer_info": {
"object": "customer_info",
"customer_id": "cus_zzmjKsnM9oacyCwV3",
"name": "Mario Perez",
"email": "[email protected]",
"phone": "+5215555555555",
"antifraud_info":{
"account_created_at": 1484040996,
"first_paid_at": 1485151007,
"paid_transactions": 4
}
},
"created_at": 1597069682,
"updated_at": 1597069682,
"line_items": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "line_item_2fw8EWJusiRrxdPzR",
"object": "line_item",
"name": "Box of Cohiba S1s",
"unit_price": 35000,
"quantity": 1,
"parent_id": "ord_2fw8EWJusiRrxdPzT",
"antifraud_info": {
"trip_id": "12345",
"driver_id": "driv_1231",
"ticket_class": "economic",
"pickup_latlon": "23.4323456,-123.1234567",
"dropoff_latlon": "23.4323456,-123.1234567"
},
"metadata": {}
}]
},
"charges": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "589026bbedbb6e56430016ad",
"object": "charge",
"livemode": false,
"created_at": 1597069682,
"status": "paid",
"amount": 35000,
"paid_at": 1485842112,
"currency": "MXN",
"fee": 1467,
"customer_id": "",
"order_id": "ord_2fw8EWJusiRrxdPzT",
"payment_method": {
"object": "card_payment",
"type": "credit",
"name": "Jorge Lopez",
"exp_month": "12",
"exp_year": "19",
"auth_code": "490884",
"last4": "4242",
"brand": "visa",
"issuer": "",
"account_type": "",
"country": "MX",
"fraud_score": 29,
"fraud_indicators": []
}
}]
},
"metadata": {}
}
System.out.println(order.toString());
{
id = ord_2fw8EWJusiRrxdPzT,
object = order,
livemode = false,
amount = 35000,
amount_refunded = 0,
payment_status = paid,
currency = MXN,
customer_info = {
object = customer_info,
customer_id = cus_zzmjKsnM9oacyCwV3,
name = Mario Perez,
email = [email protected],
phone = +5215555555555,
antifraud_info ={
account_created_at = 1484040996,
first_paid_at = 1485151007,
paid_transactions = 4
}
},
created_at = 1597069682,
updated_at = 1597069682,
line_items = {
object = list,
has_more = false,
total = 1,
data = [{
id = line_item_2fw8EWJusiRrxdPzR,
object = line_item,
name = Box of Cohiba S1s,
unit_price = 35000,
quantity = 1,
parent_id = ord_2fw8EWJusiRrxdPzT,
antifraud_info = {
trip_id = 12345,
driver_id = driv_1231,
ticket_class = economic,
pickup_latlon = 23.4323456,-123.1234567,
dropoff_latlon = 23.4323456,-123.1234567
},
metadata = {}
}]
},
charges = {
object = list,
has_more = false,
total = 1,
data = [{
id = 589026bbedbb6e56430016ad,
object = charge,
livemode = false,
created_at = 1597069682,
status = paid,
amount = 35000,
paid_at = 1485842112,
currency = MXN,
fee = 1467,
customer_id = ,
order_id = ord_2fw8EWJusiRrxdPzT,
payment_method = {
object = card_payment,
type = credit,
name = Jorge Lopez,
exp_month = 12,
exp_year = 19,
auth_code = 490884,
last4 = 4242,
brand = visa,
issuer = ,
account_type = ,
country = MX,
fraud_score = 29,
fraud_indicators = []
}
}]
},
metadata = {}
}
System.Console.WriteLine(order);
{
"id": "ord_2fw8EWJusiRrxdPzT",
"object": "order",
"livemode": false,
"amount": 35000,
"amount_refunded": 0,
"payment_status": "paid",
"currency": "MXN",
"customer_info": {
"object": "customer_info",
"customer_id": "cus_zzmjKsnM9oacyCwV3",
"name": "Mario Perez",
"email": "[email protected]",
"phone": "+5215555555555",
"antifraud_info":{
"account_created_at": 1484040996,
"first_paid_at": 1485151007,
"paid_transactions": 4
}
},
"created_at": 1597069683,
"updated_at": 1597069683,
"line_items": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "line_item_2fw8EWJusiRrxdPzR",
"object": "line_item",
"name": "Box of Cohiba S1s",
"unit_price": 35000,
"quantity": 1,
"parent_id": "ord_2fw8EWJusiRrxdPzT",
"antifraud_info": {
"trip_id": "12345",
"driver_id": "driv_1231",
"ticket_class": "economic",
"pickup_latlon": "23.4323456,-123.1234567",
"dropoff_latlon": "23.4323456,-123.1234567"
},
"metadata": {}
}]
},
"charges": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "589026bbedbb6e56430016ad",
"object": "charge",
"livemode": false,
"created_at": 1597069683,
"status": "paid",
"amount": 35000,
"paid_at": 1485842112,
"currency": "MXN",
"fee": 1467,
"customer_id": "",
"order_id": "ord_2fw8EWJusiRrxdPzT",
"payment_method": {
"object": "card_payment",
"type": "credit",
"name": "Jorge Lopez",
"exp_month": "12",
"exp_year": "19",
"auth_code": "490884",
"last4": "4242",
"brand": "visa",
"issuer": "",
"account_type": "",
"country": "MX",
"fraud_score": 29,
"fraud_indicators": []
}
}]
},
"metadata": {}
}
{
"id": "ord_2fw8EWJusiRrxdPzT",
"object": "order",
"livemode": false,
"amount": 35000,
"amount_refunded": 0,
"payment_status": "paid",
"currency": "MXN",
"customer_info": {
"object": "customer_info",
"customer_id": "cus_zzmjKsnM9oacyCwV3",
"name": "Mario Perez",
"email": "[email protected]",
"phone": "+5215555555555",
"antifraud_info":{
"account_created_at": 1484040996,
"first_paid_at": 1485151007,
"paid_transactions": 4
}
},
"created_at": 1597069682,
"updated_at": 1597069682,
"line_items": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "line_item_2fw8EWJusiRrxdPzR",
"object": "line_item",
"name": "Box of Cohiba S1s",
"unit_price": 35000,
"quantity": 1,
"parent_id": "ord_2fw8EWJusiRrxdPzT",
"antifraud_info": {
"trip_id": "12345",
"driver_id": "driv_1231",
"ticket_class": "economic",
"pickup_latlon": "23.4323456,-123.1234567",
"dropoff_latlon": "23.4323456,-123.1234567"
},
"metadata": {}
}]
},
"charges": {
"object": "list",
"has_more": false,
"total": 1,
"data": [{
"id": "589026bbedbb6e56430016ad",
"object": "charge",
"livemode": false,
"created_at": 1597069682,
"status": "paid",
"amount": 35000,
"paid_at": 1485842112,
"currency": "MXN",
"fee": 1467,
"customer_id": "",
"order_id": "ord_2fw8EWJusiRrxdPzT",
"payment_method": {
"object": "card_payment",
"type": "credit",
"name": "Jorge Lopez",
"exp_month": "12",
"exp_year": "19",
"auth_code": "490884",
"last4": "4242",
"brand": "visa",
"issuer": "",
"account_type": "",
"country": "MX",
"fraud_score": 29,
"fraud_indicators": []
}
}]
},
"metadata": {}
}