Reembolsar Orden

Una orden reembolsada describe los artículos, monto y razón por la que una orden está siendo reembolsada.

Argumentos

Industria: Transporte

Tipo

Descripción

id

string

El id de la orden.

reason

string

Razón del reembolso.

amount

integer (opcional)

Monto a reembolsar en caso de reembolso parcial.

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.

Razones

  • requested_by_client
  • cannot_be_fulfilled
  • duplicated_transaction
  • suspected_fraud
  • other
order = Conekta::Order.find("ord_2fw8LMoXP8BeVLcVn")
order.refund({
  reason: 'requested_by_client',
  amount: 15000
})

{
  id: "ord_2fw8EWJusiRrxdPzT",
  object: "order",
  livemode: false,
  amount: 35000,
  amount_refunded: 15000,
  payment_status: "partially_refunded",
  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: "partially_refunded",
      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: []
      }
      refunds: {
        object: "list",
        has_more: false,
        total: 1,
        data: [{
          id: "58b8b111edbb6e799eef7743",
          object: "refund",
          amount: -15000,
          auth_code: "411021",
          created_at: 1597069683
        }]
      }
    }]
  },
  metadata: {}
}
curl -H "Accept: application/vnd.conekta-v2.0.0+json" \
     -H "Content-type: application/json" \
     -u key_eYvWV7gSDkNYXsmr: \
     -X POST -d '{
          "amount": 15000,
          "reason": "requested_by_client"
        }' https://api.conekta.io/orders/ord_2fw8EWJusiRrxdPzT/refunds
$order = \Conekta\Order::find("ord_2fw8EWJusiRrxdPzT")
$order->refund([
  'reason' => 'requested_by_client',
  'amount' => 15000
])

{
  "id": "ord_2fw8EWJusiRrxdPzT",
  "object": "order",
  "livemode": false,
  "amount": 35000,
  "amount_refunded": 15000,
  "payment_status": "partially_refunded",
  "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": "partially_refunded",
      "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": []
      }
      "refunds": {
        "object": "list",
        "has_more": false,
        "total": 1,
        "data": [{
          "id": "58b8b111edbb6e799eef7743",
          "object": "refund",
          "amount": -15000,
          "auth_code": "411021",
          "created_at": 1597069683
        }]
      }
    }]
  },
  "metadata": {}
}
conekta.Order.find("ord_2fw8EWJusiRrxdPzT", function(err, order) {
  order.createRefund({
    "reason": "requested_by_client",
    "amount": 1000
  }, function(err, res) {
    console.log(res);
  });
});

{
  "id": "ord_2fw8EWJusiRrxdPzT",
  "object": "order",
  "livemode": false,
  "amount": 35000,
  "amount_refunded": 15000,
  "payment_status": "partially_refunded",
  "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": "partially_refunded",
      "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": []
      }
      "refunds": {
        "object": "list",
        "has_more": false,
        "total": 1,
        "data": [{
          "id": "58b8b111edbb6e799eef7743",
          "object": "refund",
          "amount": -15000,
          "auth_code": "411021",
          "created_at": 1597069683
        }]
      }
    }]
  },
  "metadata": {}
}
order = conekta.Order.find("ord_2fw8EWJusiRrxdPzT")
order.refund({
  "reason": "requested_by_client",
  "amount": 15000
})

{
  "id": "ord_2fw8EWJusiRrxdPzT",
  "object": "order",
  "livemode": false,
  "amount": 35000,
  "amount_refunded": 15000,
  "payment_status": "partially_refunded",
  "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": "partially_refunded",
      "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": []
      }
      "refunds": {
        "object": "list",
        "has_more": false,
        "total": 1,
        "data": [{
          "id": "58b8b111edbb6e799eef7743",
          "object": "refund",
          "amount": -15000,
          "auth_code": "411021",
          "created_at": 1597069683
        }]
      }
    }]
  },
  "metadata": {}
}
Order order = Order.find("ord_2fw8EWJusiRrxdPzT");
JSONObject validRefund = new JSONObject("{"
  + "'amount': 15000,"
  + "'reason': 'requested_by_client'"
+ "}");

order.refund(validRefund);

{
  id = ord_2fw8EWJusiRrxdPzT,
  object = order,
  livemode = false,
  amount = 35000,
  amount_refunded = 15000,
  payment_status = partially_refunded,
  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 = partially_refunded,
      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 = []
      }
      refunds = {
        object = list,
        has_more = false,
        total = 1,
        data = [{
          id = 58b8b111edbb6e799eef7743,
          object = refund,
          amount = -15000,
          auth_code = "411021",
          created_at = 1597069683
        }]
      }
    }]
  },
  metadata = {}
}
Order order = new Order().find("ord_2fw8EWJusiRrxdPzT");

order.refund(@"{
  ""reason"": "requested_by_client",
  ""amount"": 15000
}");

{
  "id": "ord_2fw8EWJusiRrxdPzT",
  "object": "order",
  "livemode": false,
  "amount": 35000,
  "amount_refunded": 15000,
  "payment_status": "partially_refunded",
  "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": "partially_refunded",
      "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": []
      },
      "refunds": {
        "object": "list",
        "has_more": false,
        "total": 1,
        "data": [{
          "id": "58b8b111edbb6e799eef7743",
          "object": "refund",
          "amount": -15000,
          "auth_code": "411021",
          "created_at": 1597069683
        }]
      }
    }]
  },
  "metadata": {}
}
import  (
    conekta "github.com/conekta/conekta-go"
    "github.com/conekta/conekta-go/order"
)

orderRefund := &conekta.OrderRefundParams{}
orderRefund.Reason = ""
orderRefund.Amount = 1500
order.Refund("ord_2fw8EWJusiRrxdPzT", orderRefund)