Activar 3DS - Checkout
En esta sección se describe cómo realizar la integración para utilizar 3D Secure 2 a través de Checkout. Es aconsejable que previamente se haya leído y/o implementado la guía para Integrar Checkout
Para integrar una orden con 3DS2 es necesario realizar los siguientes pasos:
1. Crear orden con modalidad 3DS2.
En la creación de la orden que usará checkout deberás enviar el atributo de three_ds_mode en alguna de sus modalidades (smart/strict):
curl -H "Accept: application/vnd.conekta-v2.3.0+json" \
-H "Content-type: application/json" \
-u YOUR_ACCESS_TOKEN: \
-X POST -d '{
"three_ds_mode": "strict",
"currency": "MXN",
"customer_info": {
"customer_id": "cus_2nHprwaWFn7QJ21Lj"
},
"line_items": [{
"name": "Box of Cohiba S1s",
"unit_price": 35000,
"quantity": 1
}],
"shipping_lines": [{
"amount": 0
}],
"checkout": {
"type": "HostedPayment",
"success_url": "https://www.mysite.com/payment/confirmation",
"failure_url": "https://www.mysite.com/payment/failure",
"monthly_installments_enabled": true,
"monthly_installments_options": [3, 6, 9, 12],
"redirection_time": 4
},
"shipping_contact": {
"phone": "+5215555555555",
"receiver": "Marvin Fuller",
"address": {
"street1": "Nuevo Leon 4",
"country": "MX",
"postal_code": "06100"
}
}
}' https://api.conekta.io/ordersNotas de los campos:
redirection_time: Tiempo de Redirección al Success-Failure URL, umbrales de 4 a 120 seg.
<?php
$validOrderWithCheckout = array(
'three_ds_mode': "strict",
'line_items'=> array(
array(
'name'=> 'Box of Cohiba S1s',
'description'=> 'Imported From Mex.',
'unit_price'=> 120000,
'quantity'=> 1,
'sku'=> 'cohbs1',
'category'=> 'food',
'tags' => array('food', 'mexican food')
)
),
'checkout' => array(
'type' => 'HostedPayment',
'success_url' => 'https://www.mysite.com/payment/confirmation',
'failure_url' => 'https://www.mysite.com/payment/failure',
'monthly_installments_enabled' => true,
'monthly_installments_options' => array(3, 6, 9, 12),
"redirection_time": 4 //Tiempo de Redirección al Success/Failure URL, umbrales de 4 a 120 seg.
),
'customer_info' => array(
'customer_id' => 'cus_2nHprwaWFn7QJ21Lj'
),
'currency' => 'mxn',
'metadata' => array('test' => 'extra info')
);
$order = Order::create($validOrderWithCheckout);valid_order_with_checkout = {
three_ds_mode: "strict",
line_items: [
{
name: 'Box of Cohiba S1s',
description: 'Imported From Mex.',
unit_price: 120000,
quantity: 1,
sku: 'cohbs1',
category: 'food',
tags: ['food', 'mexican food']
}
],
checkout: {
expires_at: Time.now.to_i + 259200,
failure_url: "testredirect.com",
force_2fa_flow: true,
success_url: "testredirect.com",
monthly_installments_enabled: true,
monthly_installments_options: [3, 6, 9, 12],
type: "HostedPayment",
redirection_time: 4 # Tiempo de Redirección al Success/Failure URL, umbrales de 4 a 120 seg.
},
customer_info: {
customer_id: customer.id
},
currency: 'mxn',
metadata: {test: 'extra info'}
}
order = Conekta::Order.create(valid_order_with_checkout)
puts order.inspectorder = self.client.Order.create(order)
checkout = order.createCheckout({
"three_ds_mode": "strict",
"currency": "MXN",
"customer_info": {
"customer_id": "cus_2o3FvMEBiKitVK1vQ"
},
"line_items": [{
"name": "Box of Cohiba S1s",
"unit_price": 300000,
"quantity": 1
}],
"shipping_lines": [{
"amount": 0
}],
"checkout": {
"type":"HostedPayment",
"success_url": "testredirect.com",
"failure_url": "testredirect.com",
"multifactor_authentication": False,
"monthly_installments_enabled": True,
"monthly_installments_options": [3,6,9,12,18],
"expires_at": 1609891200,
"redirection_time": 4 //Tiempo de Redirección al Success/Failure URL, umbrales de 4 a 120 seg.
},
"shipping_contact": {
"phone": "+5215555555555",
"receiver": "Marvin Fuller",
"address": {
"street1": "Nuevo Leon 4",
"country": "MX",
"postal_code": "06100"
}
}
})conekta.Order.create({
"three_ds_mode": "strict",
"currency": "MXN",
"customer_info": {
"customer_id": customer.id
},
"line_items": [{
"name": "Box of Cohiba S1s",
"unit_price": 300000,
"quantity": 1
}],
"shipping_lines": [{
"amount": 0
}],
"checkout": {
"type":"HostedPayment",
"success_url": "testredirect.com",
"failure_url": "testredirect.com",
"multifactor_authentication": False,
"monthly_installments_enabled": True,
"monthly_installments_options": [3,6,9,12,18],
"expires_at": 1609891200,
"redirection_time": 4 //Tiempo de Redirección al Success/Failure URL, umbrales de 4 a 120 seg.
},
"shipping_contact": {
"phone": "+5215555555555",
"receiver": "Marvin Fuller",
"address": {
"street1": "Nuevo Leon 4",
"country": "MX",
"postal_code": "06100"
}
}
}, function(err, res) {
if(err){
console.log(err);
return;
}
console.log(res.toObject());
});using Newtonsoft.Json;
var validOrderWithCheckout = new
{
three_ds_mode: "strict",
currency: "MXN",
customer_info = new
{
customer_id = "cus_2o3FvMEBiKitVK1vQ"
},
line_items = new
[
new
{
name = "Box of Cohiba S1s",
unit_price = 300000,
quantity = 1
}
],
shipping_lines = new
[
new
{
"amount" = 0
}
],
checkout = new
{
type = "HostedPayment",
success_url = "testredirect.com",
failure_url = "testredirect.com",
multifactor_authentication = false,
monthly_installments_enabled = true,
monthly_installments_options = new int[]
{
3,
6,
9,
12
},
expires_at = 1609891200,
redirection_time= 4 //Tiempo de Redirección al Success/Failure URL, umbrales de 4 a 120 seg.
},
shipping_contact = new
{
phone = "+5215555555555",
receiver = "Marvin Fuller",
address = new
{
street1 = "Nuevo Leon 4",
country = "MX",
postal_code = "06100"
}
}
};
var order = new Order()
.create(JsonConvert.SerializeObject(validOrderWithCheckout));package main
import (
"context"
"fmt"
"io"
"net/http"
"github.com/conekta/conekta-go"
)
func main() {
const acceptLanguage = "es"
cfg := conekta.NewConfiguration()
client := conekta.NewAPIClient(cfg)
ctx := context.WithValue(context.TODO(), conekta.ContextAccessToken, "key_DwaOLXoX6YCGGvfNifZ3IPwi")
rq := conekta.OrderRequest{
Checkout: &conekta.CheckoutRequest{
FailureUrl: conekta.PtrString("https://www.mysite.com/payment/failure"),
MonthlyInstallmentsEnabled: conekta.PtrBool(true),
MonthlyInstallmentsOptions: []int32{3, 6, 9, 12},
SuccessUrl: conekta.PtrString("https://www.mysite.com/payment/confirmation"),
Type: conekta.PtrString("HostedPayment"),
},
ThreeDsMode:"strict",
Currency: "MXN",
CustomerInfo: conekta.OrderRequestCustomerInfo{
CustomerInfoJustCustomerId: conekta.NewCustomerInfoJustCustomerId("cus_2nHprwaWFn7QJ21Lj"),
},
LineItems: []conekta.Product{
{
Name: "Box of Cohiba S1s",
UnitPrice: 35000,
Quantity: 1,
},
},
ShippingContact: &conekta.CustomerShippingContacts{
Phone: conekta.PtrString("+5215555555555"),
Receiver: conekta.PtrString("Marvin Fuller"),
Address: conekta.CustomerShippingContactsAddress{
Street1: conekta.PtrString("Nuevo Leon 4"),
PostalCode: conekta.PtrString("06100"),
Country: conekta.PtrString("MX"),
},
},
ShippingLines: []conekta.ShippingRequest{{Amount: 0}},
}
order, response, err := client.OrdersApi.CreateOrder(ctx).
OrderRequest(rq).
AcceptLanguage(acceptLanguage).
Execute()
if err != nil {
panic(err)
}
if response.StatusCode != http.StatusCreated {
responseBody, err := io.ReadAll(response.Body)
if err != nil {
panic(err)
}
panic(fmt.Sprintf("response body: %s", responseBody))
}
fmt.Printf("order: %v", order)
}
try {
Order order = Order.create(
new JSONObject("{ 'currency': 'mxn'," +
"'three_ds_mode': 'strict'," +
" 'customer_info': {" +
" 'customer_id': 'cus_2o3FvMEBiKitVK1vQ'" +
" }," +
" 'line_items': [{" +
" 'name': 'Box of Cohiba S1s'," +
" 'unit_price': 300000," +
" 'quantity': 1," +
" }]," +
" 'checkout': {" +
" 'expired_at': " + (System.currentTimeMillis() / 1000L) + 259200 + "," +
" 'failure_url': 'testredirect.com'," +
" 'force_3ds_flow': false," +
" 'monthly_installments_enabled': true," +
" 'monthly_installments_options': [3,6,9,12,18]," +
" 'success_url': 'testredirect.com'," +
" 'type': 'HostedPayment'" +
" 'redirection_time': 4," +
" }," +
" 'shipping_contact': {" +
" 'phone': '5555555555'," +
" 'receiver': 'Marvin Fuller'" +
" }" +
"}")
);
} catch (Conekta::Error e) {
System.out.println(e.details.get(0).message);
}
AtenciónA diferencia de la creación de cargos por Direct API, aquí NO debes enviar el atributo
return_url
2. Redireccionar al Checkout.
Redireccionar al checkout como indica aquí
3. Capturar eventos.
Recibir notificaciones de pago como indica aquí
Personalizar métodos de pago (opcional)
Por defecto, todos los métodos de pago disponibles en tu cuenta se habilitan automáticamente. Si necesitas personalizarlos:
Usa excluded_payment_methods para ocultar métodos específicos del flujo de pago.
"excluded_payment_methods": ["cash", "bnpl"]Usa allowed_payment_methods para listar únicamente los métodos a habilitar.
"allowed_payment_methods": ["card", "bank_transfer"]Valores posibles:
card,cash,bank_transfer,bnpl,pay_by_bank,apple.
Updated about 1 month ago

