Conekta Developer's Hub

Bienvenido al Conekta Developer's Hub. Aquí encontrarás la más robusta documentación del API Conekta y todos los tutoriales que te ayudarán a comenzar a recibir pagos de la manera más rápida, sencilla y segura.

Link de Pago con MSI

Link de pago

Crear link de pago fácilmente a través de API y compártelo con tus clientes.

📘

Primeros pasos

  • Instalar e incluir alguna de nuestras SDKs en tu proyecto.
  • Utilizar tu propia llave privada. Si no la conoces, puedes obtenerla aquí.

Paso 1 - Crear el link de pago.

El siguiente snippet incorpora todas las partes del paso 1. Copia y pega el siguiente fragmento de código en tu sandbox y corre el código para crear a un checkout object y opcionalmente también puedes enviarlo por correo electrónico ó SMS.

Para más información sobre las diferentes partes del snippet favor de seguir el resto del tutorial.

curl --request POST \
  --url https://api.conekta.io/checkouts \
  --header 'accept: application/vnd.conekta-v2.0.0+json' \
  -u key_eYvWV7gSDkNYXsmr: \
  --header 'content-type: application/json' \
  --data '{
    "name": "Payment Link Name",
    "type": "PaymentLink",
    "recurrent": false,
    "expires_at": 1590882634,
    "allowed_payment_methods": ["cash", "card", "bank_transfer"],
    "needs_shipping_contact": true,
    "monthly_installments_enabled": true,
    "monthly_installments_options": [3, 6, 9, 12],
    "order_template": {
        "line_items": [{
            "name": "Red Wine",
            "unit_price": 1000,
            "quantity": 10
        }],
        "metadata": {
          "mycustomkey": "12345",
          "othercustomkey": "abcd"
        },
        "currency": "MXN",
        "customer_info": {
            "name": "Juan Perez",
            "email": "[email protected]",
            "phone": "5566982090"
        }
    }
 }'
<?php

$validCheckout = [
  'name' => "Payment Link Name",
  'type' => "PaymentLink",
  'recurrent' => false,
  'expires_at' => 1600882634,
  'allowed_payment_methods' => ["cash", "card", "bank_transfer"],
  'needs_shipping_contact' => true,
  'monthly_installments_enabled' => true,
  'monthly_installments_options' => [3, 6, 9, 12],
  'order_template' => [
    'line_items' => [[
      'name' => "Red Wine",
      'unit_price' => 1000,
      'quantity' => 10
    ]],
    'metadata' => [
      'mycustomkey' => "12345",
      'othercustomkey' => "abcd"
    ],
    'currency' => "MXN",
    'customer_info' => [
      'name' => "Juan Perez",
      'email' => "[email protected]",
      'phone' => "5566982090"
    ]
  ]
];
$checkout = Checkout::create($validCheckout);
valid_checkout = {
  name: "Payment Link Name",
  type: "PaymentLink",
  recurrent: false,
  expires_at: 1607848572,
  allowed_payment_methods: ["cash", "card", "bank_transfer"],
  needs_shipping_contact: true,
  monthly_installments_enabled: true,
  monthly_installments_options: [3, 6, 9, 12],
  order_template: {
    line_items: [{
      name: "Red Wine",
      unit_price: 200000,
      quantity: 1
    }],
    metadata: {
      mycustomkey: "12345",
      othercustomkey: "abcd"
    },
    currency: "MXN",
    customer_info: {
      name: "Juan Perez",
      email: "[email protected]",
      phone: "5566982090"
    }
  }
}
checkout = Conekta::Checkout.create(valid_checkout)
checkout = conekta.Checkout.create({
   {
       "name": "Payment Link Name",
       "type": "PaymentLink",
       "recurrent": False,
       "expires_at": 1590882634,
       "allowed_payment_methods": ["cash", "card", "bank_transfer"],
       "needs_shipping_contact": True,
       "monthly_installments_enabled": False,
       "monthly_installments_options": [3, 6, 9, 12],
       "order_template": {
           "line_items": [{
               "name": "Red Wine",
               "unit_price": 1000,
               "quantity": 10
           }],
       "currency": "MXN",
       "customer_info": {
           "customer_id": "cus_2oAokFrKM7CyVxGJm"
       },
       "metadata": {
          "mycustomkey": "12345",
          "othercustomkey": "abcd"
       }
     }
   }
})
conekta.Checkout.create({
   {
       "name": "Payment Link Name",
       "type": "PaymentLink",
       "recurrent": false,
       "expires_at": 1590882634,
       "allowed_payment_methods": ["cash", "card", "bank_transfer"],
       "needs_shipping_contact": true,
       "monthly_installments_enabled": false,
       "monthly_installments_options": [3, 6, 9, 12],
       "order_template": {
           "line_items": [{
               "name": "Red Wine",
               "unit_price": 1000,
               "quantity": 10
           }],
       "currency": "MXN",
       "customer_info": {
           "customer_id": "cus_2oAokFrKM7CyVxGJm"
       },
       "metadata": {
           "mycustomkey": "12345"
       }
     }
   }
}, function(err, res) {
  if(err){
    console.log(err);
    return;
  }
  console.log(res.toObject());
});
using Newtonsoft.Json;

var validCheckout = new
  {
    checkout = new
      {
        name = "Payment Link Name",
        type = "PaymentLink",
        recurrent = false,
            expires_at = 1607848572,
        allowed_payment_methods = new string[] 
          {
            "cash", 
            "card", 
            "bank_transfer"
          },
        needs_shipping_contact = true,
        monthly_installments_enabled = true,
        monthly_installments_options = new int[]
          {
            3, 
            6, 
            9, 
            12
          },
        order_template: new
          {
            line_items = new 
              [
                new
                {
                  name = "Red Wine",
                  unit_price = 200000,
                  quantity = 1
                }
              ],
            metadata: new 
              {
                mycustomkey = "12345",
                        othercustomkey = "abcd"
              },
            currency: "MXN",
            customer_info = new 
              {
                name = "Juan Perez",
                email = "[email protected]",
                phone = "5566982090"
              }
          }
      }
  };

var checkout = new Checkout()
  .create(JsonConvert.SerializeObject(validCheckout));
import  (
    conekta "github.com/conekta/conekta-go"
    "github.com/conekta/conekta-go/checkout"
)
conekta.APIKey = "key_pMcnDF4zFyWKyLG15LuqwA"

checkoutParams := &conekta.Checkout{
        Name:                       "Payment Link Name",
        Type:                       "PaymentLink",
        Recurrent:                  false,
        ExpiresAt:                  time.Now().Unix() + int64(259200) + int64(rand.Float64()*3600),
        AllowedPaymentMethods:      []string{"cash", "card", "bank_transfer"},
        NeedsShippingContact:       true,
        MonthlyInstallmentsEnabled: false,
        MonthlyInstallmentsOptions: []int64{3, 6, 9, 12},
        OrderTemplate: &OrderParams{
            Currency: "MXN",
            LineItems: []*LineItemsParams{
                {
                    Name:      "Red Wine",
                    UnitPrice: 1000,
                    Quantity:  10,
                },
            },
            CustomerInfo: &CustomerParams{
                ID:  "cus_2oAokFrKM7CyVxGJm",
            },
        },
}

checkout.Create(checkoutParams)
try {
  Checkout checkout = Checkout.create(
      new JSONObject("{" +
                        "    'name': 'Payment Link Name'," +
                        "    'type': 'PaymentLink'," +
                        "    'recurrent': false," +
                        "    'expires_at': " + Long.toString(System.currentTimeMillis() / 1000L + 259200L) + "," +
                        "    'allowed_payment_methods': ['cash', 'card', 'bank_transfer']," +
                        "    'needs_shipping_contact': true," +
                        "    'monthly_installments_enabled': false," +
                        "    'monthly_installments_options': [3, 6, 9, 12]," +
                        "    'order_template': {" +
                        "      'line_items': [{" +
                        "        'name': 'Red Wine'," +
                        "        'unit_price': 1000," +
                        "        'quantity': 10" +
                        "      }]," +
                        "      'currency': 'MXN'," +
                        "      'customer_info': {" +
                        "        'customer_id': 'cus_2oAokFrKM7CyVxGJm'",
                        "      }," +
                        "      'metadata': {" +
                        "        'mycustomkey': '12345'",
                        "      }" +
                        "    }" +
                        "  }")
    );
} catch (Conekta::Error e) {
   System.out.println(e.details.get(0).message);
}

📘

Notas.

La fecha de expiración puede ser un timestamp comprendido entre 2 a 365 días (el rango válido se tomará a partir del siguiente día de fecha de creación a las 00:01 hrs)
El campo de metadata sirve para ingresar información custom. Máximo 100 elementos y permite caracteres especiales en el valor.

Link de múltiples pagos

Esto creará un link de pago que se puede utilizar solamente una vez, si deseas que el link pueda recibir múltiples pagos para múltiples usuarios, la bandera de recurrent debería estar en true y el número máximo de pagos permitidos. Como se muestra a continuación.

curl --request POST \
  --url https://api.conekta.io/checkouts \
  --header 'accept: application/vnd.conekta-v2.0.0+json' \
  -u key_eYvWV7gSDkNYXsmr: \
  --header 'content-type: application/json' \
  --data '{
    "name": "Payment Link Name",
    "type": "PaymentLink",
    "recurrent": true,
    "payments_limit_count": 3,
    "expired_at": 1590882634,
    "allowed_payment_methods": ["cash", "card", "bank_transfer"],
    "needs_shipping_contact": true,
    "monthly_installments_enabled": true,
    "monthly_installments_options": [3, 6, 9, 12],
    "order_template": {
        "line_items": [{
            "name": "Red Wine",
            "unit_price": 1000,
            "quantity": 10
        }],
        "metadata": {
          "mycustomkey": "12345",
          "othercustomkey": "abcd"
        },
        "currency": "MXN"
    }
 }'
<?php

$validCheckout = [
  'name' => "Payment Link Name",
  'type' => "PaymentLink",
  'recurrent' => true,
  'payments_limit_count' => 3,
  'expired_at' => 1600882634,
  'allowed_payment_methods' => ["cash", "card", "bank_transfer"],
  'needs_shipping_contact' => true,
  'monthly_installments_enabled' => true,
  'monthly_installments_options' => [3, 6, 9, 12],
  'order_template' => [
    'line_items' => [[
      'name' => "Red Wine",
      'unit_price' => 1000,
      'quantity' => 10
    ]],
    'metadata' => [
      'mycustomkey' => "12345",
      'othercustomkey' => "abcd"
    ],
    'currency' => "MXN",
    'customer_info' => [
      'name' => "Juan Perez",
      'email' => "[email protected]",
      'phone' => "5566982090"
    ]
  ]
];
$checkout = Checkout::create($validCheckout);
valid_checkout = {
  name: "Payment Link Name",
  type: "PaymentLink",
  recurrent: true,
  payments_limit_count: 3,
  expired_at: 1607848572,
  allowed_payment_methods: ["cash", "card", "bank_transfer"],
  needs_shipping_contact: true,
  monthly_installments_enabled: true,
  monthly_installments_options: [3, 6, 9, 12],
  order_template: {
    line_items: [{
      name: "Red Wine",
      unit_price: 200000,
      quantity: 1
    }],
    metadata: {
      mycustomkey: "12345",
      othercustomkey: "abcd"
    },
    currency: "MXN"  
  }
}
checkout = Conekta::Checkout.create(valid_checkout)
checkout = conekta.Checkout.create({
       "name": "Payment Link Name",
       "type": "PaymentLink",
       "recurrent": True,
       "expired_at": 1590882634,
       "payments_limit_count": 3,
       "allowed_payment_methods": ["cash", "card", "bank_transfer"],
       "needs_shipping_contact": True,
       "monthly_installments_enabled": False,
       "monthly_installments_options": [3, 6, 9, 12],
       "order_template": {
           "line_items": [{
               "name": "Red Wine",
               "unit_price": 1000,
               "quantity": 10
           }],
       "currency": "MXN",
       "customer_info": {
          "customer_id": "cus_2oAokFrKM7CyVxGJm"
       },
       "metadata": {
          "mycustomkey": "12345",
          "othercustomkey": "abcd"
       }
     }
   })
conekta.Checkout.create({
       "name": "Payment Link Name",
       "type": "PaymentLink",
       "recurrent": true,
       "expired_at": 1590882634,
       "payments_limit_count": 3,
       "allowed_payment_methods": ["cash", "card", "bank_transfer"],
       "needs_shipping_contact": true,
       "monthly_installments_enabled": false,
       "monthly_installments_options": [3, 6, 9, 12],
       "order_template": {
           "line_items": [{
               "name": "Red Wine",
               "unit_price": 1000,
               "quantity": 10
           }],
       "currency": "MXN",
       "customer_info": {
          "customer_id": "cus_2oAokFrKM7CyVxGJm"
       },
       "metadata": {
          "mycustomkey": "12345"
       }
     }
   }, function(err, res) {
     if(err){
       console.log(err);
       return;
     }
     console.log(res.toObject());
   });
using Newtonsoft.Json;

var validCheckout = new
  {
    checkout = new
      {
        name = "Payment Link Name",
        type = "PaymentLink",
        recurrent = true,
            expired_at = 1607848572,
        allowed_payment_methods = new string[] 
          {
            "cash", 
            "card", 
            "bank_transfer"
          },
        payments_limit_count = 3,
        needs_shipping_contact = true,
        monthly_installments_enabled = true,
        monthly_installments_options = new int[]
          {
            3, 
            6, 
            9, 
            12
          },
        order_template: new
          {
            line_items = new 
              [
                new
                {
                  name = "Red Wine",
                  unit_price = 200000,
                  quantity = 1
                }
              ],
            metadata: new 
              {
                mycustomkey = "12345",
                        othercustomkey = "abcd"
              },
            currency: "MXN",
            customer_info = new 
              {
                name = "Juan Perez",
                email = "[email protected]",
                phone = "5566982090"
              }
          }
      }
  };

var checkout = new Checkout()
  .create(JsonConvert.SerializeObject(validCheckout));
checkoutParams := &conekta.Checkout{
        AllowedPaymentMethods:      []string{"cash", "card", "bank_transfer"},
        ExpiredAt:                  time.Now().Unix() + int64(259200) + int64(rand.Float64()*3600),
        MonthlyInstallmentsEnabled: false,
        MonthlyInstallmentsOptions: []int64{3, 6, 9, 12},
        Name:                       "Payment Link Name",
        NeedsShippingContact:       true,
    OrderTemplate: &OrderParams{
            Currency: "MXN",
            LineItems: []*LineItemsParams{
                {
                    Name:      "Red Wine",
                    UnitPrice: 1000,
                    Quantity:  10,
                },
            },
            CustomerInfo: &CustomerParams{
                ID:  "cus_2oAokFrKM7CyVxGJm",
            },
        },
    PaymentsLimitCount:         3,
        Recurrent:                  true,
        Type:                       "PaymentLink",
}

checkout.Create(checkoutParams)
try {
  Checkout checkout = Checkout.create(
      new JSONObject("{" +
                        "    'name': 'Payment Link Name'," +
                        "    'type': 'PaymentLink'," +
                        "    'recurrent': true," +
                        "    'expired_at': " + Long.toString(System.currentTimeMillis() / 1000L + 259200L) + "," +
                        "    'allowed_payment_methods': ['cash', 'card', 'bank_transfer']," +
                        "    'monthly_installments_enabled': false," +
                        "    'monthly_installments_options': [3, 6, 9, 12]," +
                        "    'needs_shipping_contact': true," +
                        "    'order_template': {" +
                        "      'line_items': [{" +
                        "        'name': 'Red Wine'," +
                        "        'unit_price': 1000," +
                        "        'quantity': 10" +
                        "      }]," +
                        "      'currency': 'MXN'," +
                        "      'customer_info': {" +
                        "        'customer_id': 'cus_2oAokFrKM7CyVxGJm'",
                        "      }," +
                        "      'metadata': {" +
                        "        'mycustomkey': '12345'",
                        "      }" +
                        "    }," +
                        "    'payments_limit_count': 3" +
                        "  }")
    );
} catch (Conekta::Error e) {
   System.out.println(e.details.get(0).message);
}

Paso 1.1 - Asociar un customer con link de pago

Si quieres crear customers y asociarlos con el link de pago entonces puedes hacer las siguientes dos peticiones

Crear el customer

curl -H "Accept: application/vnd.conekta-v2.0.0+json"\
-H "Content-type: application/json" \
-u key_XXXXXXXXX: \
-X POST -d '{
    "name": "Juan Perez",
    "email": "[email protected]",
    "phone": "5566982093",
    "shipping_contacts": [{
        "phone": "+5566982090",
        "receiver": "Juan Perez",
        "address": {
            "street1": "Nuevo Leon 254",
            "country": "MX",
            "postal_code": "06100"
        }
    }]
}' https://api.conekta.io/customers
<?php

$customer = \Conekta\Customer::create(
  [
    'name'  => "Juan Perez",
    'email' => "[email protected]",
    'phone' => "5566982093",
    'shipping_contacts' => [
      [
        'phone' => "+5566982090",
        'receiver' => "Juan Perez",
        'address' => [
          'street1' => "Nuevo Leon 254",
          'country' => "MX",
          'postal_code' => "06100"
        ]
      ]
    ]
  ]
);
customer = Conekta::Customer.create(
  {
    name: "Juan Perez",
    email: "[email protected]",
    phone: "5566982093",
    shipping_contacts: [
      {
        phone: "+5566982090",
        receiver: "Juan Perez",
        address: {
          street1: "Nuevo Leon 254",
          country: "MX",
          postal_code: "06100"
        }
      }
    ]
  }
)
customer = Conekta.Customer.create(
 {
   name: "Juan Perez",
   email: "[email protected]",
   phone: "5566982093",
   shipping_contacts: [
     {
       phone: "+5566982090",
       receiver: "Juan Perez",
       address: {
         street1: "Nuevo Leon 254",
         country: "MX",
         postal_code: "06100"
       }
     }
   ]
 }
)
conekta.Customer.create(
 {
   name: "Juan Perez",
   email: "[email protected]",
   phone: "5566982093",
   shipping_contacts: [
     {
       phone: "+5566982090",
       receiver: "Juan Perez",
       address: {
         street1: "Nuevo Leon 254",
         country: "MX",
         postal_code: "06100"
       }
     }
   ]
 }, function(err, res) {
     if(err){
       console.log(err);
       return;
     }
     console.log(res.toObject());
   });
using Newtonsoft.Json;

var validCustomer = new 
  {
    name = "Payment Link Name",
    email = "[email protected]",
    phone = "5566982093",
    shipping_contacts: new
      [
         new
           {
              phone = "+5566982090",
              receiver = "Juan Perez",
              address = new 
                {
                  street1 = "Nuevo Leon 254",
                  country = "MX",
                  postal_code = "06100"
                }
            }
        ]
  };

var customer = new Customer().create(validCustomer);
customerParams := &conekta.CustomerParams{
    Name: "Juan Perez",
    Email: "[email protected]",
  Phone: "5566982093",
  ShippingContacts: [](*ShippingContactParams){
    {
      Phone: "5566982093",
      Receiver: "Juan Perez",
      Address: &Address{
         Street1: "Nuevo Leon 254",
         Country: "MX",
         PostalCode: "06100",
      },
    },
  }
}

customerResponse, err := customer.Create(customerParams)
Customer customer = Customer.create(
    new JSONObject("{"
      + "'name': 'Fulanito Pérez', "
      + "'email': '[email protected]'"
      + "}"
    )
  );

Crear link de pago asociado a ese customer

curl --request POST \
--url https://api.conekta.io/checkouts \
--header 'accept: application/vnd.conekta-v2.0.0+json' \
-u key_XXXXX: \
--header 'content-type: application/json' \
--data '{
    "name": "Payment Link Name",
    "type": "PaymentLink",
    "recurrent": false,
    "expired_at": 1597635007,
    "allowed_payment_methods": ["cash", "card", "bank_transfer"],
    "needs_shipping_contact": false,
    "monthly_installments_enabled": true,
    "monthly_installments_options": [3, 6, 9, 12],
    "order_template": {
        "line_items": [{
            "name": "Red Wine",
            "unit_price": 1000,
            "quantity": 10
        }],
        "currency": "MXN",
        "customer_info": {
            "customer_id": "cus_2nYSnP4EDiREgGte9"
        },
        "metadata": {
          "mycustomkey": "12345",
          "othercustomkey": "abcd"
        },
    }
}'
<?php

$validCheckout = [
  'name' => "Payment Link Name",
  'type' => "PaymentLink",
  'recurrent' => false,
  'expired_at' => 1600882634,
  'allowed_payment_methods' => ["cash", "card", "bank_transfer"],
  'needs_shipping_contact' => true,
  'monthly_installments_enabled' => true,
  'monthly_installments_options' => [3, 6, 9, 12],
  'order_template' => [
    'line_items' => [[
      'name' => "Red Wine",
      'unit_price' => 1000,
      'quantity' => 10
    ]],
    'metadata' => [
      'mycustomkey' => "12345",
      'othercustomkey' => "abcd"
    ],
    'currency' => "MXN",
    'customer_info' => [
      'customer_id' => "cus_2nYSnP4EDiREgGte9"
    ]
  ]
];
$checkout = Checkout::create($validCheckout);
valid_checkout = {
  name: "Payment Link Name",
  type: "PaymentLink",
  recurrent: false,
  expired_at: 1607848572,
  allowed_payment_methods: ["cash", "card", "bank_transfer"],
  needs_shipping_contact: true,
  monthly_installments_enabled: true,
  monthly_installments_options: [3, 6, 9, 12],
  order_template: {
    line_items: [{
      name: "Red Wine",
      unit_price: 200000,
      quantity: 1
    }],
    metadata: {
      mycustomkey: "12345",
      othercustomkey: "abcd"
    },
    currency: "MXN",
    customer_info: {
      customer_id: "cus_2oq2nDztVUnz6k2Y6"
    }
  }
}
checkout = Conekta::Checkout.create(valid_checkout)
checkout = conekta.Checkout.create({
       "name": "Payment Link Name",
       "type": "PaymentLink",
       "recurrent": False,
       "expired_at": 1590882634,
       "allowed_payment_methods": ["cash", "card", "bank_transfer"],
       "needs_shipping_contact": True,
       "monthly_installments_enabled": True,
       "monthly_installments_options": [3, 6, 9, 12],
       "order_template": {
           "line_items": [{
               "name": "Red Wine",
               "unit_price": 1000,
               "quantity": 10
           }],
       "currency": "MXN",
       "customer_info": {
           "customer_id": "cus_2oq2nDztVUnz6k2Y6"
           }
       },
       "metadata": {
          "mycustomkey": "12345",
          "othercustomkey": "abcd"
       }
   }
)
conekta.Checkout.create({
       "name": "Payment Link Name",
       "type": "PaymentLink",
       "recurrent": false,
       "expired_at": 1590882634,
       "allowed_payment_methods": ["cash", "card", "bank_transfer"],
       "needs_shipping_contact": true,
       "monthly_installments_enabled": true,
       "monthly_installments_options": [3, 6, 9, 12],
       "order_template": {
           "line_items": [{
               "name": "Red Wine",
               "unit_price": 1000,
               "quantity": 10
           }],
           "currency": "MXN",
           "customer_info": {
              "customer_id": "cus_2oq2nDztVUnz6k2Y6"
           },
           "metadata": {
              "mycustomkey": "12345"
           }
       }
   }, function(err, res) {
     if(err){
       console.log(err);
       return;
     }
     console.log(res.toObject());
   });
using Newtonsoft.Json;

var validCheckout = new
  {
    checkout = new
      {
        name = "Payment Link Name",
        type = "PaymentLink",
        recurrent = false,
            expired_at = 1607848572,
        allowed_payment_methods = new string[] 
          {
            "cash", 
            "card", 
            "bank_transfer"
          },
        needs_shipping_contact = true,
        monthly_installments_enabled = true,
        monthly_installments_options = new int[]
          {
            3, 
            6, 
            9, 
            12
          },
        order_template: new
          {
            line_items = new 
              [
                new
                {
                  name = "Red Wine",
                  unit_price = 200000,
                  quantity = 1
                }
              ],
            metadata: new 
              {
                mycustomkey = "12345",
                        othercustomkey = "abcd"
              },
            currency: "MXN",
            customer_info = new 
              {
                customer_id = "cus_2oq2nDztVUnz6k2Y6"
              }
          }
      }
  };

var checkout = new Checkout()
  .create(JsonConvert.SerializeObject(validCheckout));
checkoutParams := &conekta.Checkout{
        Name:                       "Payment Link Name",
        Type:                       "PaymentLink",
        Recurrent:                  false,
        ExpiredAt:                  time.Now().Unix() + int64(259200) + int64(rand.Float64()*3600),
        AllowedPaymentMethods:      []string{"cash", "card", "bank_transfer"},
        NeedsShippingContact:       true,
        MonthlyInstallmentsEnabled: true,
        MonthlyInstallmentsOptions: []int64{3, 6, 9, 12},
        OrderTemplate: &OrderParams{
            Currency: "MXN",
            LineItems: []*LineItemsParams{
                {
                    Name:      "Red Wine",
                    UnitPrice: 1000,
                    Quantity:  10,
                },
            },
            CustomerInfo: &CustomerParams{
                ID:  "cus_2oq2nDztVUnz6k2Y6",
            },
        },
}

checkoutResponse, err := checkout.Create(checkoutParams)
try {
  Checkout checkout = Checkout.create(
      new JSONObject("{" +
                        "    'name': 'Payment Link Name'," +
                        "    'type': 'PaymentLink'," +
                        "    'recurrent': false," +
                        "    'expired_at': " + Long.toString(System.currentTimeMillis() / 1000L + 259200L) + "," +
                        "    'allowed_payment_methods': ['cash', 'card', 'bank_transfer']," +
                        "    'needs_shipping_contact': true," +
                        "    'monthly_installments_enabled': true," +
                        "    'monthly_installments_options': [3, 6, 9, 12]," +
                        "    'order_template': {" +
                        "      'line_items': [{" +
                        "        'name': 'Red Wine'," +
                        "        'unit_price': 1000," +
                        "        'quantity': 10" +
                        "      }]," +
                        "      'currency': 'MXN'," +
                        "      'customer_info': {" +
                        "        'customer_id': 'cus_2oAokFrKM7CyVxGJm'",
                        "      }," +
                        "      'metadata': {" +
                        "        'mycustomkey': '12345'",
                        "      }" +
                        "    }" +
                        "  }")
    );
} catch (Conekta::Error e) {
   System.out.println(e.details.get(0).message);
}

Paso 1.2 - Compartir la url del link de pago con el customer.

Tienes dos opciones para compartir la url del link de pago, puedes hacerlo a través de sms o correo electrónico.

{
    "id": "42a4c95e-0db2-4ae8-9bb3-ea681acc8281",
    "object": "checkout",
    "name": "Payment Link Name",
    "url": "https://pay.conekta.com/link/42a4c95e0db24ae89bb3ea681acc8281",
    "slug": "42a4c95e0db24ae89bb3ea681acc8281",
    "status": "Issued",
    "type": "PaymentLink",
    "expired_at": 1590882634,
    "allowed_payment_methods": ["cash", "card", "bank_transfer"],
    "needs_shipping_contact": true,
    "monthly_installments_options": [3, 6, 9, 12],
    "monthly_installments_enabled": true,
    "livemode": true
}
<?Php

echo $checkout->id;
echo $checkout->object;
echo $checkout->name;
echo $checkout->url;
echo $checkout->slug;
echo $checkout->livemode;
echo $checkout->monthly_installments_enabled;
var_dump((array) $checkout->monthly_installments_options);
puts checkout.id
puts checkout.object
puts checkout.name
puts checkout.url
puts checkout.slug
puts checkout.livemode
puts checkout.monthly_installments_enabled
puts checkout.monthly_installments_options.inspect
print(checkout.id)
print(checkout.object)
print(checkout.name)
print(checkout.url)
print(checkout.slug)
print(checkout.livemode)
print(checkout.monthly_installments_enabled)
print(checkout.monthly_installments_options.inspect)
console.log(checkout.id)
console.log(checkout.object)
console.log(checkout.name)
console.log(checkout.url)
console.log(checkout.slug)
console.log(checkout.livemode)
console.log(checkout.monthly_installments_enabled)
console.log(checkout.monthly_installments_options)
Console.WriteLine(checkout.id);
Console.WriteLine(checkout._object);
Console.WriteLine(checkout.name);
Console.WriteLine(checkout.url);
Console.WriteLine(checkout.slug);
Console.WriteLine(checkout.livemode);
Console.WriteLine(checkout.monthly_installments_enabled);
Console.WriteLine(checkout.monthly_installments_options.Length);
fmt.Println("Id: %v\n", checkoutResponse.ID)
fmt.Println("Object: %v\n", checkoutResponse.Object)
fmt.Println("Name: %v\n", checkoutResponse.Name)
fmt.Println("Url: %v\n", checkoutResponse.Url)
fmt.Println("Slug: %v\n", checkoutResponse.Slug)
fmt.Println("Livemode: %v\n", checkoutResponse.Live)
fmt.Println("MonthlyInstallmentsEnabled: %v\n", checkoutResponse.MonthlyInstallmentsEnabled)
fmt.Println("MonthlyInstallmentOptions: %v\n", checkoutResponse.MonthlyInstallmentsOptions)
System.out.println(checkout.allowed_payment_methods);
System.out.println(checkout.monthly_installments_enabled);
System.out.println(checkout.monthly_installments_options);
System.out.println(checkout.object);
System.out.println(checkout.type);
System.out.println(checkout.slug);
System.out.println(checkout.url);

Paso 2 - Compartir el link de pago

Puedes compartir el link de pago con tu cliente mediante las siguientes opciones:

Paso 2.1 - Compartir el link de pago en un SMS.

Si lo prefieres puedes enviar un sms con el link de pago a través de nuestros sistemas.

curl --request POST \
  --url https://api.conekta.io/checkouts/42a4c95e-0db2-4ae8-9bb3-ea681acc8281/sms \
  --header 'accept: application/vnd.conekta-v2.0.0+json' \
  -u key_eYvWV7gSDkNYXsmr: \
  --header 'content-type: application/json' \
  --data '{
    "phonenumber": "5566982090"
  }'
<?php

$checkout->sendSms(['phone' => '555555555']);
checkout.send_sms(phone: '555555555')
Checkout.sendSms({
       "id": "05b25724-df59-4925-8762-105d627875fd"
       "name": "Payment Link Name",
       "type": "checkout",
       "recurrent": true,
       "expired_at": 1590882634,
       "allowed_payment_methods": ["cash", "card", "bank_transfer"],
       "needs_shipping_contact": true,
       "monthly_installments_enabled": true,
       "monthly_installments_options": [3, 6, 9, 12],
       "order_template": {
           "line_items": [{
               "name": "Red Wine",
               "unit_price": 1000,
               "quantity": 10
           }],
       "currency": "MXN",
       "customer_info": {
             "name": "Juan Perez",
             "email": "[email protected]",
             "phone": "5566982090"
       }
     }
   })
checkout.sendSms({phone: "555555555"}, function(err, res) {
     if(err){
       console.log(err);
       return;
     }
     console.log(res.toObject());
   });
using Newtonsoft.Json;

var parameters = new
                {
                    phone = "5555555555"
                };

checkout.send_sms(JsonConvert.SerializeObject(parameters));
checkout.SendSms(checkoutResponse.ID, "555555555")
checkout.send_sms('5555555555');

Paso 2.2 - Compartir el link de pago en un correo electrónico

Si lo prefieres puedes enviar un email con el link de pago a través de nuestros sistemas.

curl --request POST \
  --url https://api.conekta.io/checkouts/42a4c95e-0db2-4ae8-9bb3-ea681acc8281/email \
  --header 'accept: application/vnd.conekta-v2.0.0+json' \
  -u key_eYvWV7gSDkNYXsmr: \
  --header 'content-type: application/json' \
  --data '{
    "email": "[email protected]"
  }'
<?php

$checkout->sendEmail(['email' => '[email protected]']);
checkout.send_email(email: '[email protected]')
Checkout.sendEmail({
       "id": "05b25724-df59-4925-8762-105d627875fd"
       "name": "Payment Link Name",
       "type": "checkout",
       "recurrent": True,
       "expired_at": 1590882634,
       "allowed_payment_methods": ["cash", "card", "bank_transfer"],
       "needs_shipping_contact": True,
       "monthly_installments_enabled": True,
       "monthly_installments_options": [3, 6, 9, 12],
       "order_template": {
           "line_items": [{
               "name": "Red Wine",
               "unit_price": 1000,
               "quantity": 10
           }],
       "currency": "MXN",
       "customer_info": {
             "name": "Juan Perez",
             "email": "[email protected]",
             "phone": "5566982090"
       }
     }
   })
checkout.sendEmail({email: "[email protected]"}, function(err, res) {
     if(err){
       console.log(err);
       return;
     }
     console.log(res.toObject());
   });
using Newtonsoft.Json;

var parameters = new
                {
                    email = "[email protected]'"
                };

checkout.send_email(JsonConvert.SerializeObject(parameters));
checkout.SendEmail(checkoutResponse.ID, "[email protected]")
checkout.send_email('[email protected]');

Paso 3: Configurar meses sin intereses

Puedes configurar el checkout para que pueden funcionar con meses sin intereses si en las peticiones agregas estas dos variables: monthly_installments_enabled para activarlo y monthly_installments_options con los meses habilitados, dentro del objeto de "Checkout"


Ejemplo:

"monthly_installments_enabled": true,
"monthly_installments_options": [3, 6, 9, 12, 18]

Consideraciones para MSI.

* Monto mínimo para meses sin intereses es $300 MXN

Toma en cuenta la siguiente tabla:

Umbral de Monto (MXN)

MSI

$300-$599

Permite 3 MSI (todos los bancos)

$600-$899

Permite hasta 6 MSI (todos los bancos)

$900-$1199

Permite hasta 9 MSI (todos los bancos)

$1200-$1790

Permite hasta 12 MSI (todos los bancos)

$1800-En adelante

Permite hasta 18 MSI (Solo Citibanamex)

Paso 4 - Recibir la notificación de pago

Si tienes configurado un webhook tu puedes recibir el evento charge.paid cada que se reciba un pago exitoso.

# N/A
<?php

$body = @file_get_contents('php://input');
$data = json_decode($body);
http_response_code(200); // Return 200 OK 

if ($data->type == 'charge.paid'){
  $msg = "Tu pago ha sido comprobado.";
  mail("[email protected]","Pago confirmado",$msg);
}
//Using nodemailer
var data = typeof req.body == 'string' ? JSON.parse(req.body) : req.body; 

if (data.type == 'order.paid') {
  var mail = {
      from: me,
      to: you,
      subject: 'Pago comprobado',
      text: 'Tu pago ha sido confirmado.'
  };
  transporter.sendMail(mail, function(error, info){
      if(error){ return console.log(error); }
    });
}
import (
    "json"
    "log"
    "net/http"
)

func notificationHandler(w http.ResponseWriter, r *http.Request) {
  var objmap map[string]json.RawMessage
  err := json.Unmarshal(data, &objmap)
  if (objmap["type"] == "order.paid"){
    //Do something
  }
    w.Write([]byte("OK"))
}

func main() {
    http.HandleFunc("/my-notification-endpoint", notificationHandler)
    err := http.ListenAndServe(":9090", nil)
    if err != nil {
        log.Fatal("ListenAndServe: ", err)
    }
}
import org.json.JSONObject;
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
      BufferedReader get_body = request.getReader(); 

      //Parse JSON
    }

Cancelar el link

Si necesitas cancelar un link previamente creado, se puede hacer a través de nuestra API.

curl --request PUT \
  --url https://apipp.conekta.io/checkouts/019b2693-18e6-4094-8bd1-5530bcad5906/cancel \
  --header 'accept: application/vnd.conekta-v2.0.0+json' \
  -u key_eYvWV7gSDkNYXsmr: \
  --header 'content-type: application/json' \
  --data '{}'
<?php

$checkout->cancel();
checkout.cancel()
Checkout.cancel()
checkout.cancel(function(err, res) {
     if(err){
       console.log(err);
       return;
     }
     console.log(res.toObject());
   });
checkout.cancel();
checkout.Cancel(checkoutResponse.ID)
checkout.cancel();