These docs are for v2.1.0. Click to read the latest docs for v2.2.0.

Reintentos de pago

En el caso de que el pago de un cargo falle, podríamos agregar nuevos cargos sobre el monto restante de la orden para poder completarlo

Por ejemplo:

Si tenemos una orden de $500.00 con 2 cargos:

  • Cargo con transferencia: $300.00
  • Cargo con tarjeta: $200.00 -> Cargo fallido

Deberíamos agregar un nuevo cargo a la orden para poder hacer un reintento de pago.

📘

¿Puedo seguir combinando pagos del saldo restante?

Sí, puedes seguir combinando pagos del saldo restante ($200.00 según el ejemplo), puedes combinar 2 cargos extras de $100.00 ya sea con spei o tarjetas

Actualizando la orden

curl --location --request PUT 'http://api.conekta.io/orders/ORDER_ID' \
--header 'Accept: application/vnd.conekta-v2.1.0+json' \
--header 'Content-type: application/json' \
--header 'Authorization: Basic API_KEY' \
--data '{
   "charges": [
        {
             "payment_method": {
                "type": "card",
                "token_id": "TOKEN_ID"
            },
            "amount": 20000
        }
        
   ]
}'
order = Conekta::Order.find("ORDER_ID")

params = {
  charges: [
    {
      payment_method: {
        type: "card",
        token_id: "TOKEN_ID"
      },
      amount: 20000
    }
  ]
}

order.update(params)
$order = \Conekta\Order::find("ORDER_ID");

$params = array(
  'charges' => array(
    array(
      'payment_method' => array(
        'type' => 'card',
        'token_id' => 'TOKEN_ID'
      ),
      'amount' => 20000
    )
  )
);

$order->update($params);
params = {
    "charges": [
        {
            "payment_method": {
                "type": "card",
                "token_id": "TOKEN_ID"
            },
            "amount": 20000
        }
    ]
}

order.update(params)
Conekta.Order.find('ORDER_ID', function(err, order) {
  const params = {
    "charges": [
      {
        "payment_method": {
          "type": "card",
          "token_id": "TOKEN_ID"
        },
        "amount": 20000
      }
    ]
  };

  order.update(params, function(err, order) {
    console.log(order.toObject());
  });
});

Respuesta

{
   "livemode":false,
   "amount":50000,
   "currency":"MXN",
   "payment_status":"partially_paid",
   "amount_refunded":0,
   "split_payment":true,
   "customer_info":{
      "email":"[email protected]",
      "phone":"5522997233",
      "name":"Nicolás Cedrón",
      "corporate":true,
      "customer_id":null,
      "object":"customer_info"
   },
   "shipping_contact":null,
   "channel":null,
   "fiscal_entity":null,
   "object":"order",
   "id":"ord_2uatmgUCbHmpKLcUU",
   "metadata":{
      
   },
   "is_refundable":true,
   "processing_mode":null,
   "created_at":1695094326,
   "updated_at":1695094327,
   "line_items":{
      "object":"list",
      "has_more":false,
      "total":1,
      "data":[
         {
            "name":"Box of Cohiba S1s",
            "description":null,
            "unit_price":50000,
            "quantity":1,
            "sku":null,
            "tags":null,
            "brand":null,
            "type":null,
            "object":"line_item",
            "id":"line_item_2uatmgUCbHmpKLcUS",
            "parent_id":"ord_2uatmgUCbHmpKLcUU",
            "metadata":{
               
            },
            "antifraud_info":{
               
            }
         }
      ]
   },
   "shipping_lines":null,
   "tax_lines":null,
   "discount_lines":null,
   "charges":{
      "object":"list",
      "has_more":false,
      "total":2,
      "data":[
         {
            "id":"650916368973ba484c9985a8",
            "livemode":false,
            "created_at":1695094326,
            "currency":"MXN",
            "failure_code":null,
            "failure_message":null,
            "monthly_installments":null,
            "device_fingerprint":null,
            "channel":null,
            "payment_method":{
               "name":"QA Testing",
               "exp_month":"12",
               "exp_year":"24",
               "auth_code":"1882",
               "object":"card_payment",
               "type":"credit",
               "normalized_device_fingerprint":null,
               "last4":"0957",
               "brand":"visa",
               "issuer":"bbva",
               "account_type":"cuenta oro",
               "contract_id":"S430991000",
               "country":"MX",
               "fraud_score":null,
               "fraud_indicators":[
                  
               ],
               "token_id":"tok_2u32nGqWqVjW96dUc"
            },
            "object":"charge",
            "description":"Payment from order",
            "is_refundable":true,
            "reference_id":null,
            "status":"paid",
            "amount":20000,
            "paid_at":1695094327,
            "customer_id":"",
            "order_id":"ord_2uatmgUCbHmpKLcUU",
            "refunds":null
         },
         {
            "id":"650916368973ba484c9985a0",
            "livemode":false,
            "created_at":1695094326,
            "currency":"MXN",
            "failure_code":null,
            "failure_message":null,
            "monthly_installments":null,
            "device_fingerprint":null,
            "channel":null,
            "payment_method":{
               "clabe":"646180111812345678",
               "bank":"STP",
               "issuing_account_holder_name":null,
               "issuing_account_tax_id":null,
               "issuing_account_bank":null,
               "issuing_account_number":null,
               "receiving_account_holder_name":null,
               "receiving_account_tax_id":null,
               "receiving_account_number":"646180111812345678",
               "receiving_account_bank":"STP",
               "reference_number":null,
               "description":null,
               "tracking_code":null,
               "executed_at":null,
               "payment_attempts":[
                  
               ],
               "object":"bank_transfer_payment",
               "type":"spei",
               "expires_at":1702867793
            },
            "object":"charge",
            "description":"Payment from order",
            "is_refundable":false,
            "reference_id":null,
            "status":"pending_payment",
            "amount":30000,
            "paid_at":null,
            "customer_id":"",
            "order_id":"ord_2uatmgUCbHmpKLcUU",
            "refunds":null,
            "reference":"646180111812345678"
         }
      ]
   }
}

Errores

Si el monto enviado no corresponde al restante del order, recibirás:

{
    "details": [
        {
            "debug_message": "The order amount does not match with the sum of charges amounts.",
            "message": "La cantidad a pagar debe ser igual al total de la orden.",
            "param": "amount",
            "code": "conekta.errors.parameter_validation.combo.order.amount.invalid_charges_amount"
        }
    ],
    "object": "error",
    "type": "parameter_validation_error",
    "log_id": "643863ce77a374b7a7580b5e"
}

Si te pasa de los límites recibirás:

{  
    "details": [  
        {  
            "debug_message": "The order amount does not match with the sum of charges amounts.",  
            "message": "La cantidad a pagar debe ser igual al total de la orden.",  
            "param": "amount",  
            "code": "conekta.errors.parameter_validation.combo.order.amount.invalid_charges_amount"  
        }  
    ],  
    "object": "error",  
    "type": "parameter_validation_error",  
    "log_id": "643863ce77a374b7a7580b5e"  
}

Did this page help you?