Cargo único y Meses Sin Intereses (MSI)

Tokenizar (cifrar) la información la tarjeta

Por motivos de seguridad, se requiere tokenizar la información sensible de la tarjeta en el frontend de tu sitio.

📘

Primeros pasos

Paso 1 - Añade la librería de ConektaJS a tu sitio

  • Para fines prácticos usamos jQuery en este tutorial.
  • Nuestra librería de frontend ConektaJS sólo tokeniza las tarjetas.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.conekta.io/js/latest/conekta.js"></script>

📘

Recuerda que...

Si estás construyendo una app, en lugar de ConektaJS usarás los SDKs de Android, iOS o Xamarin.

Objetos que regresa ConektaJS

  • Objeto token: es el objeto que regresamos en caso de éxito.
  • Objeto error: es el objeto que regresamos en caso de que algo haya salido mal.
// Token
{
  "id": "tok_a4Ff0dD2xYZZq82d9",
  "object": "token",
  "used": false,
  "livemode": true
}


// Error
{
  "type": "parameter_validation_error",
  "message": "Something went wrong on Conekta's end",
  "message_to_purchaser": "Your code could not be processed, please try again later",
  "error_code": "invalid_expiry_month",
  "param": "card[exp_month]"
}

Paso 1.1 - Añade tu script de tokenización

Definiciones

  • Conekta.setPublicKey() añade tu llave pública para permitir la tokenización de tarjetas.
  • conektaSuccessResponseHandler regresa un objeto token cuando la petición fue exitosa.
  • conektaErrorResponseHandler regresa un objeto error cuando la petición tuvo algún detalle.
  • Conekta.Token.create() envía la información a nuestro servidor.

El token sólo puede ser utilizado una vez y tiene un tiempo de expiración de una hora.

<script type="text/javascript" >
  Conekta.setPublicKey('key_KJysdbf6PotS2ut2');


  var conektaSuccessResponseHandler = function(token) {
    var $form = $("#card-form");
    //Inserta el token_id en la forma para que se envíe al servidor
     $form.append($('<input type="hidden" name="conektaTokenId" id="conektaTokenId">').val(token.id));
    $form.get(0).submit(); //Hace submit
  };
  var conektaErrorResponseHandler = function(response) {
    var $form = $("#card-form");
    $form.find(".card-errors").text(response.message_to_purchaser);
    $form.find("button").prop("disabled", false);
  };


  //jQuery para que genere el token después de dar click en submit
  $(function () {
    $("#card-form").submit(function(event) {
      var $form = $(this);
      // Previene hacer submit más de una vez
      $form.find("button").prop("disabled", true);
      Conekta.Token.create($form, conektaSuccessResponseHandler, conektaErrorResponseHandler);
      return false;
    });
  });
</script>

Paso 1.2 - Añade el formulario de la tarjeta a tu sitio

ConektaJS recopila la información de la tarjeta usando data-attributes pero si lo deseas puedes crear un objeto token.

<form action="" method="POST" id="card-form">
  <span class="card-errors"></span>
  <div>
    <label>
      <span>Nombre del tarjetahabiente</span>
      <input type="text" size="20" data-conekta="card[name]">
    </label>
  </div>
  <div>
    <label>
      <span>Número de tarjeta de crédito</span>
      <input type="text" size="20" data-conekta="card[number]">
    </label>
  </div>
  <div>
    <label>
      <span>CVC</span>
      <input type="text" size="4" data-conekta="card[cvc]">
    </label>
  </div>
  <div>
    <label>
      <span>Fecha de expiración (MM/AAAA)</span>
      <input type="text" size="2" data-conekta="card[exp_month]">
    </label>
    <span>/</span>
    <input type="text" size="4" data-conekta="card[exp_year]">
  </div>
  <button type="submit">Crear token</button>
</form>

Paso 2 - Añade tu llave privada y versión del API

Para este paso necesitarás tu llave privada de pruebas. Puedes encontrarla dando clic aquí.

# N/A
require_once("/path/to/lib/Conekta.php");
\Conekta\Conekta::setApiKey("key_eYvWV7gSDkNYXsmr");
\Conekta\Conekta::setApiVersion("2.0.0");
require "conekta"
Conekta.api_key = "key_eYvWV7gSDkNYXsmr"
Conekta.api_version = "2.0.0"
import conekta
conekta.api_key = "key_eYvWV7gSDkNYXsmr"
conekta.api_version = "2.0.0"
var conekta = require('conekta');
conekta.api_key = 'key_eYvWV7gSDkNYXsmr';
conekta.api_version = '2.0.0';
import com.conekta;
Conekta.setApiKey("key_eYvWV7gSDkNYXsmr");
com.conekta.Conekta.apiVersion = "2.0.0"
using conekta;
conekta.Api.apiKey = "key_eYvWV7gSDkNYXsmr";
conekta.Api.version = "2.0.0";
import (
    conekta "github.com/conekta/conekta-go"
)

conekta.APIKey = "key_pMcnDF4zFyWKyLG15LuqwA"

Paso 2.1 - Crea una orden y agrega el token

Al crear un order se generará el cargo de tu cliente. Si no deseas crear el cargo inmediato, puedes preparar la orden y después generar el cargo mandando la información del arreglo charges.

La información que debes enviar tiene que ser real ya que nuestro sistema de antifraude la necesita para revisar la veracidad de la transacción.

Los campos mostrados en el ejemplo son los mínimos requeridos, si deseas mejorar la veracidad de tus transacciones necesitas saber más sobre el objeto order, para ello, revisa nuestra REST API.

Meses Sin Intereses (Opcional)

En el ejemplo de arriba incluimos un campo optional de monthly_installments, es es una opción común para compras de montos altas, sobre todo para productos físicos en e-commerce. Esta opción permite al comprador pagar la cantidad total durante varias meses, permitiendo acceso a productos más caros sin endeudarse en el proceso. Como negocio recibirás el monto total de la compra con el calendario normal de cualquier otro método de pago pero tendrás que pagar una comisión más alta para que el banco puede financiarlo. El valor de monthly_installment va dividir los pagos entre el mismo número de meses, y acepta valores de 3, 6, 9, 12 and 18 (18 solo con Banamex).

Hay algunas restricciones para este método de pago:

  • Solo aplica para pagos con tarjetas de crédito mexicanas (tarjetas de débito mexicanas u internacionales regresarán un error)
  • Hay monto mínimos de compra
  • 300 MXN para 3 meses sin intereses
  • 600 MXN para 6 meses sin intereses
  • 900 MXN para 9 meses sin intereses
  • 1200 MXN para 12 meses sin intereses
  • 1800 MXN para 18 meses sin intereses
curl -H "Accept: application/vnd.conekta-v2.0.0+json" \
     -H "Content-type: application/json" \
     -u key_eYvWV7gSDkNYXsmr: \
     --header 'content-type: application/json' \
     --data '{
      "line_items": [{
          "name": "Tacos",
          "unit_price": 1000,
          "quantity": 120
      }],
      "shipping_lines": [{
          "amount": 1500,
          "carrier": "FEDEX"
      }],
      "currency": "MXN",
      "customer_info": {
          "name": "Arnulfo Quimare",
            "email": "[email protected]",
            "phone": "+52181818181"
      },
      "shipping_contact":{
           "address": {
               "street1": "Calle 123, int 2",
               "postal_code": "06100",
               "country": "MX"
           }
       },
     "metadata": {"reference": "12987324097", "more_info": "lalalalala"},
      "charges":[{
          "payment_method": {
             "monthly_installments": 3,
             "type": "card",
             "token_id": "tok_test_visa_4242"
          }
      }]
  }' https://api.conekta.io/orders
try{
  $order = \Conekta\Order::create(
    [
      "line_items" => [
        [
          "name" => "Tacos",
          "unit_price" => 1000,
          "quantity" => 120
        ]
      ],
      "shipping_lines" => [
        [
          "amount" => 1500,
          "carrier" => "FEDEX"
        ]
      ], //optional - shipping_lines are only required for physical goods
      "currency" => "MXN",
      "customer_info" => [
        "name" => "nombre",
        "email" => "[email protected]",
        "phone" => "5512345678"
      ),
      "shipping_contact" => [
        "address" => [
          "street1" => "Calle 123, int 2",
          "postal_code" => "06100",
          "country" => "MX"
        ]
      ], //optional - shipping_contact is only required for physical goods
      "metadata" => ["reference" => "12987324097", "more_info" => "lalalalala"],
      "charges" => [
        [
          "payment_method" => [
            "monthly_installments" => 3, //optional
            "type" => "card",
            "token_id" => "tok_test_visa_4242"
          ] //payment_method - use customer's default - a card
            //to charge a card, different from the default,
            //you can indicate the card's source_id as shown in the Retry Card Section
        ]
      ]
    ]
  );
} catch (\Conekta\ProcessingError $error){
  echo $error->getMessage();
} catch (\Conekta\ParameterValidationError $error){
  echo $error->getMessage();
} catch (\Conekta\Handler $error){
  echo $error->getMessage();
}
begin
  order = Conekta::Order.create({
    line_items: [{
        name: "Tacos",
        unit_price: 1000,
        quantity: 120
    }],
    shipping_lines: [{
        amount: 1500,
        carrier: "FEDEX"
    }], #optional - shipping_lines are only required for physical goods
    currency: "MXN",
    customer_info: {
      name: 'Fulanito Pérez',
      email: '[email protected]',
      phone: '+52181818181'
    },
    shipping_contact: {
        address: {
            street1: "Calle 123, int 2",
            postal_code: "06100",
            country: "MX"
        }
    }, #optional - shipping_contact is only required for physical goods
    charges: [{
        payment_method: {
          monthly_installments: 3,  #optional
          type: 'card',
          token_id: 'tok_test_visa_4242'
        } #payment_method - use the customer's default - a card
          #to charge a card, different from the default,
          #you can indicate the card's source_id as shown in the Retry Card Section
    }],
    metadata: {"reference" => "12987324097", "more_info" => "lalalalala"}
  })
rescue Conekta::Error => error
  for error_detail in error.details do
    puts error_detail.message
  end
end
try:
  order = conekta.Order.create({
      "line_items": [{
          "name": "Tacos",
          "unit_price": 1000,
          "quantity": 120
      }],
      "shipping_lines": [{
          "amount": 1500,
          "carrier": "FEDEX"
      }], #optional - shipping_lines are only required for physical goods
      "currency": "MXN",
      "customer_info": {
          "name": "John Constantine",
          "phone": "+525533445566",
          "email": "[email protected]",
          "corporate": False,      },
      "shipping_contact":{
       "address": {
         "street1": "Calle 123, int 2",
         "postal_code": "06100",
         "country": "MX"
       } #optional - shipping_contact is only required for physical goods
     },
    "metadata": { "description": "Compra de creditos: 300(MXN)", "reference": "1334523452345" },
    "charges":[{
      "payment_method": {
      "monthly_installments": 3, #optional
          "type": "card",
      "token_id": "tok_test_visa_4242"
      }  #payment_method - use the customer's default - a card
         #to charge a card, different from the default,
         #you can indicate the card's source_id as shown in the Retry Card Section
    }]
  })
except conekta.ConektaError as e:
  print e.message
order = conekta.Order.create({
    "line_items": [{
        "name": "Tacos",
        "unit_price": 1000,
        "quantity": 120
    }],
    "shipping_lines": [{
        "amount": 1500,
        "carrier": "FEDEX"
    }], //optional - shipping_lines are only required for physical goods
    "currency": "MXN",
    "customer_info": {
      'name': 'Fulanito Pérez',
      'email': '[email protected]',
      'phone': '+52181818181'
    },
    "shipping_contact":{
     "address": {
       "street1": "Calle 123, int 2",
       "postal_code": "06100",
       "country": "MX"
     }
   },  //optional - shipping_contact is only required for physical goods
  "metadata": { "description": "Compra de creditos: 300(MXN)", "reference": "1334523452345" },
  "charges":[{
    "payment_method": {
      'monthly_installments': 3, //optional 
      'type': 'card',
      'token_id': 'tok_test_visa_4242'
    }  //payment_methods - use the customer's default - a card
       //to charge a card, different from the default,
       //you can indicate the card's source_id as shown in the Retry Card Section
  }]
}, function(err, res) {
    if(err){
      console.log(err);
      return;
    }
    console.log(res.toObject());
});
try{
  Order order = Order.create(
    new JSONObject("{"
      + "'line_items': [{"
          + "'name': 'Tacos',"
          + "'unit_price': 1000,"
          + "'quantity': 120"
      + "}]," //line_items
      + "'shipping_lines': [{"
          + "'amount': 1500,"
          + "'carrier': 'FEDEX'"
      + "}]," //optional - shipping_lines are only required for physical goods
      + "'currency': 'MXN',"
      + "'customer_info': {"
        + "'name': 'Rene', "
        + "'email': '[email protected]',"
        + "'phone': '+52181818181'"
      + "}," //customer_info
      + "'shipping_contact':{"
         + "'address': {"
           + "'street1': 'Calle 123, int 2',"
           + "'postal_code': '06100',"
           + "'country': 'MX'"
         + "}"
       + "}," //optional - shipping_contact is only required for physical goods 
       +"'metadata': {'description': 'Compra de creditos: 300(MXN)' , 'reference' : '1334523452345'},"
      + "'charges':[{"
        + "'payment_method': {"
          + "'monthly_installments': 3," //optional
          + "'type': 'card',"
          + "'token_id: 'tok_test_visa_4242"
        + "}" //payment_method - use the customer's default - a card
              //to charge a card, different from the default,
              //you can indicate the card's source_id as shown in the Retry Card Section
      + "}]"
    + "}"
    )
  );
}catch (Conekta::Error e) {
   System.out.println(e.details.get(0).message);
}
try{
conekta.Order order = new conekta.Order().create(@"{
  ""line_items"": [{
    ""name"": ""Tacos"",
    ""unit_price"": 1000,
    ""quantity"": 120
  }],
  ""shipping_lines"": [{
    ""amount"": 1500,
    ""carrier"": ""FEDEX""
  }]," + //optional - shipping_lines are only required for physical goods
  @"""currency"": ""MXN"",
  ""customer_info"": {
    ""name"":""Bruce Wayne"",
    ""email"":""[email protected]"",
    ""phone"":""+52181818181""
  },
  ""shipping_contact"":{
    ""address"": {
      ""street1"": ""Calle 123, int 2"",
      ""postal_code"": ""06100"",
      ""country"": ""MX""
    }
  }," + //optional - shipping_contact is only required for physical goods 
  @"""metadata"":{""description"" : ""Compra de creditos: 300(MXN)"", ""reference"" : ""1334523452345""},
  ""charges"":[{
  ""payment_method"": {
    ""monthly_installments"": 12," + //optional
    @"""type"": ""card"",
    ""token_id"":""tok_test_visa_4242""
  }" + //payment_method - use the customer's default - a card
       //to charge a card, different from the default,
       //you can indicate the card's source_id as shown in the Retry Card Section
  @"}]
}");
} catch (ConektaException e) {
  foreach (JObject obj in e.details) {
    System.Console.WriteLine("\n [ERROR]:\n");
    System.Console.WriteLine("message:\t" + obj.GetValue("message"));
    System.Console.WriteLine("debug:\t" + obj.GetValue("debug_message"));
    System.Console.WriteLine("code:\t" + obj.GetValue("code"));
  }
}
Address := &conekta.Address{
    Street1: "Street1",
    Street2: "Street2",
    City: "City",
    State: "State",
    Country: "Country",
    PostalCode: "PostalCode",
}

customerParams := &conekta.CustomerParams{
    Name: "Fulanito Perez",
    Phone: "5512345678",
    Email: "[email protected]",
}

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

shippingParams := &conekta.ShippingLinesParams{
    Amount: 200,
    TrackingNumber: "123",
    Carrier: "Test Carrier",
    Method: "method",
}//optional - shipping_lines are only required for physical goods

shippingContactParams := &conekta.ShippingContactParams{
    Phone: "55-5555-5555",
    Receiver: "Miguel",
    BetweenStreets: "BetweenStreets",
    Address: Address,
}//optional - shipping_contact is only required for physical goods

chargeParams := &conekta.ChargeParams{
    PaymentMethod: &conekta.PaymentMethodParams{
        MonthlyIstalments: 3, //optional
        Type: "card",
        TokenID: "tok_test_visa_4242",
    },//payment_method - use customer's default - a card
    //to charge a card, different from the default,
    //you can indicate the card's source_id as shown in the Retry Card Section
}

orderParams := &conekta.OrderParams{}
orderParams.Currency = "MXN"
orderParams.CustomerInfo = customerParams
orderParams.LineItems = append(orderParams.LineItems, lineItemParams)
orderParams.ShippingLines = append(orderParams.ShippingLines, shippingParams)
orderParams.ShippingContact = shippingContactParams
orderParams.Charges = append(orderParams.Charges, chargeParams)

ord, err := order.Create(orderParams)
if err != nil {
    code := err.(conekta.Error).Details[0].Code
    //do something
    fmt.Printf(code)
} else {
    //Check if payment was successful
    if ord.payment_status == "paid" {
        fmt.Println(ord)
    } else {
        fmt.Println(" - ", ord.Charges.Data[0].FailureMessage)
        fmt.Println(" - ", ord.Charges.Data[0].FailureCode)
    }
}

Paso 2.2 - Procesar respuesta

Recibirás un objeto JSON con mucha información, puedes mostrar los campos que creas necesarios.

Una buena práctica es notificar a tu usuario vía email.

# N/A
echo "ID: ". $order->id;
echo "Status: ". $order->payment_status;
echo "$". $order->amount/100 . $order->currency;
echo "Order";
echo $order->line_items[0]->quantity .
      "-". $order->line_items[0]->name .
      "- $". $order->line_items[0]->unit_price/100;
echo "Payment info";
echo "CODE:". $order->charges[0]->payment_method->auth_code;
echo "Card info:".
      "- ". $order->charges[0]->payment_method->name .
      "- ". $order->charges[0]->payment_method->last4 .
      "- ". $order->charges[0]->payment_method->brand .
      "- ". $order->charges[0]->payment_method->type;


// Response
// ID: ord_2fsQdMUmsFNP2WjqS
// $ 1215.0 MXN
// Order
// 120 - Tacos - $10.0
// Payment info
// CODE: 035315
// Card info: 4242 - visa - banco - credit
puts "ID: #{order.id}"
puts "Status: #{order.payment_status}"
puts "$ #{(order.amount/100).to_f} #{order.currency}"
puts "Order"
puts "#{order.line_items[0].quantity}
      - #{order.line_items[0].name}
      - $ #{(order.line_items[0].unit_price/100).to_f}"
puts "Payment info"
puts "CODE: #{order.charges[0].payment_method.auth_code}"
puts "Card info:
      - #{order.charges[0].payment_method.name}
      - #{order.charges[0].payment_method.last4}
      - #{order.charges[0].payment_method.brand}
      - #{order.charges[0].payment_method.type}"


# Response
# ID: ord_2fsQdMUmsFNP2WjqS
# $ 1215.0 MXN
# Order
# 120 - Tacos - $10.0
# Payment info
# CODE: 035315
# Card info: 4242 - visa - banco - credit
print("ID: " + order.id)
print("Status: " + order.payment_status)
print("$" + str((order.amount/100)) + order.currency)
print("Order")
print(str(order.line_items[0].quantity) + " - "
            + order.line_items[0].name + " - "
            + str((order.line_items[0].unit_price/100)))
print("Payment info");
print("Code: " + order.charges[0].payment_method.auth_code)
print("Card info: "
              + order.charges[0].payment_method.name + " - "
              + order.charges[0].payment_method.last4 + " - "
              + order.charges[0].payment_method.brand + " - "
              + order.charges[0].payment_method.type)


# Response
# ID: ord_2fsQdMUmsFNP2WjqS
# $ 1215.0 MXN
# Order
# 120 - Tacos - $10.0
# Payment info
# CODE: 035315
# Card info: 4242 - visa - banco - credit
console.log("ID: " + res.toObject().id);
    console.log("Status: " + res.toObject().payment_status);
    console.log("$" + (res.toObject().amount/100) + res.toObject().currency);
    console.log("Order");
    console.log(res.toObject().line_items.data[0].quantity + " - "
            + res.toObject().line_items.data[0].name + " - "
            + (res.toObject().line_items.data[0].unit_price/100));
    console.log("Payment info");
    console.log("Code: " + res.toObject().charges.data[0].payment_method.auth_code);
    console.log("Card info: "
              + res.toObject().charges.data[0].payment_method.name + " - "
              + res.toObject().charges.data[0].payment_method.last4 + " - "
              + res.toObject().charges.data[0].payment_method.brand + " - "
              + res.toObject().charges.data[0].payment_method.type);


// Response
// ID: ord_2fsQdMUmsFNP2WjqS
// $ 1215.0 MXN
// Order
// 120 - Tacos - $10.0
// Payment info
// CODE: 035315
// Card info: 4242 - visa - banco - credit
LineItems line_item = (LineItems)order.line_items.get(0);
  Charge charge = (Charge) order.charges.get(0);
  PaymentMethod payment_method = (PaymentMethod) charge.payment_method;
  System.out.println("ID: " + order.id);
  System.out.println("Status: " + order.payment_status);
  System.out.println("$" + (order.amount/100) + order.currency);
  System.out.println("Order");
  System.out.println(line_item.quantity + " - "
                    + line_item.name + " - "
                    + (line_item.unit_price/100));
  System.out.println("Payment info");
  System.out.println("Code: " + payment_method.getVal("auth_code"));
  System.out.println("Card info: "
                    + payment_method.getVal("name") + " - "
                    + payment_method.getVal("last4") + " - "
                    + payment_method.getVal("brand") + " - "
                    + payment_method.getVal("type"));


// Response
// ID: ord_2fsQdMUmsFNP2WjqS
// $ 1215.0 MXN
// Order
// 120 - Tacos - $10.0
// Payment info
// CODE: 035315
// Card info: 4242 - visa - banco - credit
Console.WriteLine("ID: " + order.id);
            Console.WriteLine("Status: " + order.payment_status);
            Console.WriteLine("Amount: $" + (order.amount / 100) + order.currency);
            Console.WriteLine("Order:");
            LineItem line_item = (LineItem)order.line_items.at(0);
            Console.WriteLine(line_item.quantity + " - "
                              + line_item.name + " - "
                              + (line_item.unit_price / 100));
            Charge charge = (Charge)order.charges.at(0);
            Console.WriteLine("Code: " + charge.payment_method.auth_code);
            Console.WriteLine("Card info: "
                          + charge.payment_method.name + " - "
                          + charge.payment_method.last4 + " - "
                          + charge.payment_method.brand + " - "
                          + charge.payment_method.type);


// Response
// ID: ord_2fsQdMUmsFNP2WjqS
// $ 1215.0 MXN
// Order
// 120 - Tacos - $10.0
// Payment info
// CODE: 035315
// Card info: 4242 - visa - banco - credit
//Procesar respuesta
fmt.Println("ID: ", ord.ID)
fmt.Println("Status: ", ord.PaymentStatus)
fmt.Println("$", ord.Amount/100, ord.Currency)
fmt.Println("--------Order--------")
fmt.Println(ord.LineItems.Data[0].Quantity)
fmt.Println(ord.LineItems.Data[0].Name)
fmt.Println(ord.LineItems.Data[0].UnitPrice/100)
fmt.Println("--------Payment info--------")
fmt.Println("code: ", ord.Charges.Data[0].PaymentMethod.AuthCode)
fmt.Println("Card Info: ")
fmt.Println(" - ", ord.Charges.Data[0].PaymentMethod.Name)
fmt.Println(" - ", ord.Charges.Data[0].PaymentMethod.Last4)
fmt.Println(" - ", ord.Charges.Data[0].PaymentMethod.Brand)
fmt.Println(" - ", ord.Charges.Data[0].PaymentMethod.Type)

//Response
//ord_2nDAbSc2qY23Yk72s
//paid
//202 MXN
//2
//Naranjas Robadas
//100
//--------Payment info--------
//code:  0
//Card Info: 
// -  Jorge Lopez
// -  4242
// -  visa
// -  credit

👍

¡Listo!

Recuerda cambiar tus llaves pública y privada después de realizar pruebas.

Existirán casos en los que el cargo no será exitoso, puedes ofrecer a tu cliente utilizar otro método de pago. En estos casos puedes probar alguna de estas opciones:

1. Intentar con otra tarjeta

Para hacer un cargo con un método de pago diferente al default solo necesitas su payment_source_id, el cual podrás obtener dentro del objeto payment source.

curl --request POST \
 --url https://api.conekta.io/orders/ord_2fsQdMUmsFNP2WjqS/charges \
 --header 'accept: application/vnd.conekta-v2.0.0+json' \
 -u key_eYvWV7gSDkNYXsmr: \
 --header 'content-type: application/json' \
 --data '{
     "payment_method": {
         "type": "card",
         "payment_source_id": "src_2fkJPFjQKABcmiZWy"
     }
 }'
$charge = \Conekta\Order::createCharge(
 [
   "payment_method" => [
     "type" => "card",
     "payment_source_id" => "src_2fkJPFjQKABcmiZWy"
   ]
 ]
);
charge = order.create_charge({
   payment_method: {
      type: "card",
      payment_source_id: "src_2fkJPFjQKABcmiZWy"
    }
 })
charge = order.createCharge({
 "payment_method": {
     "type": "card",
     "payment_source_id": "src_2fkJPFjQKABcmiZWy"
 }
})
charge = conekta.Order.create_charge({
   "payment_method": {
       "type": "card",
       "payment_source_id": "src_2fkJPFjQKABcmiZWy"
   }
}, function(err, res) {
     console.log(res.toObject());
});
Charge charge = order.createCharge("{"
 + "'payment_method': {"
     + "'type': 'card',"
     + "'payment_source_id': 'src_2fkJPFjQKABcmiZWy'"
   + "}"
 +"}");
order.createCharge (@"{
  ""type"":""card"",
  ""payment_source_id"":""src_2fkJPFjQKABcmiZWy""
}");
paymentMethodParams := &conekta.PaymentMethodParams{
    Type: "card",
    PaymentSourceID: "src_2fkJPFjQKABcmiZWy",
}
charge := &conekta.ChargeParams{
    PaymentMethod: paymentMethodParams,
}

charge.Create("ord_2nDAbSc2qY23Yk72s", charge)

2. Intentar con otro método de pago

Te recomendamos sugerir otro método de pago como OXXO Pay o SPEI cuando los reintentos fallidos de tarjeta fueron más de 2.

curl --request POST \
  --url https://api.conekta.io/orders/ord_2fsQdMUmsFNP2WjqS/charges \
  --header 'accept: application/vnd.conekta-v2.0.0+json' \
  -u key_eYvWV7gSDkNYXsmr: \
  --header 'content-type: application/json' \
  --data '{
      "payment_method": {
          "type": "oxxo_cash"
      }
  }'


curl --request POST \
  --url https://api.conekta.io/orders/ord_2fsQdMUmsFNP2WjqS/charges \
  --header 'accept: application/vnd.conekta-v2.0.0+json' \
  -u key_eYvWV7gSDkNYXsmr: \
  --header 'content-type: application/json' \
  --data '{
      "payment_method": {
          "type": "spei"
      }
  }'
// OxxoPay
$charge = \Conekta\Order::createCharge(
  [
    "payment_method" => [
        "type" => "oxxo_cash"
    ]
  ]
);


// SPEI
$charge = \Conekta\Order::createCharge(
  [
    "payment_method" => [
        "type" => "spei"
    ]
  ]
);
# OxxoPay
charge = order.create_charge({
  payment_method: {
      type: "oxxo_cash"
  }
})


# SPEI
charge = order.create_charge({
  payment_method: {
      type: "spei"
  }
})
# OxxoPay
charge = order.createCharge({
  "payment_method": {
      "type": "oxxo_cash"
  }
})


# SPEI
charge = order.createCharge({
  "payment_method": {
      "type": "spei"
  }
})
// OxxoPay
charge = conekta.Order.create_charge({
    "payment_method": {
        "type": "oxxo_cash"
    }
}, function(err, res) {
      console.log(res.toObject());
});


// SPEI
charge = conekta.Order.create_charge({
    "payment_method": {
        "type": "spei"
    }
}, function(err, res) {
      console.log(res.toObject());
});
// OxxoPay
Charge charge = order.createCharge("{"
  + "'payment_method': {"
      + "'type': 'oxxo_cash'"
    + "}"
  +"}");


// SPEI
Charge charge = order.createCharge("{"
  + "'payment_method': {"
      + "'type': 'spei'"
    + "}"
  +"}");
// OxxoPay
order.createCharge (@"{
   ""type"":""oxxo_cash""
}");


// SPEI
order.createCharge (@"{
   ""type"":""spei""
}");
//OxxoPay
paymentMethodParams := &conekta.PaymentMethodParams{
    Type: "oxxo_cash",
    ExpiresAt: time.Now().AddDate(0, 0, 30).Unix(),
}
charge := &conekta.ChargeParams{
    PaymentMethod: paymentMethodParams,
}

charge.Create("ord_2nDAbSc2qY23Yk72s", charge)

//SPEI
paymentMethodParams := &conekta.PaymentMethodParams{
    Type: "spei",
    ExpiresAt: time.Now().AddDate(0, 0, 90).Unix(),
}
charge := &conekta.ChargeParams{
    PaymentMethod: paymentMethodParams,
}

charge.Create("ord_2nDAbSc2qY23Yk72s", charge)