Incluir Botón de Apple Pay en mi sitio Web
Puedes integrar Apple Pay en tu sitio de dos formas:
Opción A – Con cuenta de Apple
- Requiere que tengas una cuenta de Apple.
- Debes integrar el botón de Apple Pay en tu sitio
- Apple devuelve un objeto
pk_paymentcon la tarjeta tokenizada. - Es necesario realizar un cruce de certificados para que Conekta pueda descifrar la tarjeta tokenizada. 👉 Ver guía para generar el certificado de Apple Pay
- Luego de obtener el token de Apple, envíalo desde tu backend hacia Conekta de la siguiente forma:
curl --location 'https://api.conekta.io/orders' \
--header 'Accept: application/vnd.conekta-v2.0.0+json' \
--header 'Content-type: application/json' \
--header 'Authorization: Bearer key_XXXXXXX' \
--data '{
"currency": "MXN",
"customer_info": {
"customer_id": "cus_2yYDbYkcDCB5queoa"
},
"line_items": [
{
"name": "Vasija de Cerámica",
"unit_price": 20000,
"quantity": 1,
"description": "Description",
"sku": "SKU",
"tags": [
"tag1",
"tag2"
],
"brand": "Brand",
"metadata": {
"Valor3": "South#23"
}
}
],
"shipping_lines": [
{
"amount": 0,
"carrier": "Fedex",
"method": "Airplane",
"tracking_number": "TRACK000000000123",
"object": "shipping_line"
}
],
"charges": [
{
"payment_method": {
"type": "apple",
"pk_payment": {
"paymentData": {
"data": "E+xNEXPJEvqr3GwOhhHZ6f/w9wGx6+enZxCK9AnbyTefRq8Ujopfn2hXCHIwpYAU/IkLENqfEihT4yczNBqlxZoKl1NsCYh425d1rZAcaz7KsyzBUcpR47x8ADc61pjFegCxUjuEKHOM318aahN8wd5MwVFG6XLuzkNcF304Np2OQWhOHFe6z+jqjVdNrWzWMvziZ4HJswVrHw195zo0BIUrYVnGaGhvO3Hey/Pt9wU5D05Bv/Cxz0X8MepF8ws8/ps3eIQaDPcYwExqM1f9UHrhucs/YadlQgNn8jODVNAfC8lhGyjzNax5eamV0mPcufiJjDy9CZtR32xB4J1UlLEYI3W+0rpPBJhmSlN9DHe3bLOm0sT5pRhM/+/KT+z2yX+uNigTq3xg28r68HXip4n1xsp/zuCzBmN0rx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c3bd450fcb8431d3a8d4be73f2f01"
},
"version": "EC_v1"
},
"paymentMethod": {
"displayName": "Visa 0121",
"network": "Visa",
"type": "credit"
},
"transactionIdentifier": "610c88f19c8d43e289fd1f15bee320d5440c3bd450fcb8431d3a8d4be73f2f01"
}
}
}
],
"shipping_contact": {
"receiver": "Mario perez",
"phone": "+5215555555555",
"between_streets": "Campeche y Morelos",
"address": {
"street1": "Nuevo Leon 4",
"city": "Ciudad de Mexico",
"state": "Ciudad de Mexico",
"country": "MX",
"postal_code": "78215"
}
}
}'<?php
require __DIR__ . '/../../vendor/autoload.php';
use Conekta\Api\OrdersApi;
use Conekta\ApiException;
use Conekta\Configuration;
use Conekta\Model\OrderRequest;
$apiKey = getenv("CONEKTA_API_KEY");
$config = Configuration::getDefaultConfiguration()->setAccessToken($apiKey);
$apiInstance = new OrdersApi(null, $config);
$accept_language = 'es';
$rq = new OrderRequest([
'currency' => 'MXN',
'customer_info' => [
'name' => 'fran carrero',
'email'=> '[email protected]',
'phone' => '+5218181818181'
],
'line_items' => [
[
'name' => 'Box of Cohiba S1s',
'unit_price' => 35000,
'quantity' => 1
]
],
'shipping_lines' => [
[
'amount' => 1500,
'carrier' => 'FEDEX'
]
],
'checkout' => [
'allowed_payment_methods' => [
'bank_transfer',
'card',
'cash'
],
'monthly_installments_enabled' => true,
'type' => 'HostedPayment',
'success_url' => 'https://www.example.com/success',
'failure_url' => 'https://www.example.com/failure',
'monthly_installments_options' => [3, 6, 12],
'redirection_time' => 4 //Redirect time to Success-Failure URL, thresholds 4 to 120 sec.
],
'shipping_contact' =>[
'phone' => '+5218181818181',
'receiver' => 'Marvin Fuller',
'address' => [
'street1' => '250 Alexis St',
'city' => 'Red Deer',
'state' => 'Alberta',
'country' => 'CA',
'postal_code' => '01000'
]
]
]);
try {
$result = $apiInstance->createOrder($rq, $accept_language);
$json_string = json_encode($result, JSON_PRETTY_PRINT);
print_r($json_string);
echo $result ->getCheckout()->getUrl();
} catch (ApiException $e) {
echo 'Exception when calling OrdersApi->createOrder: ', $e->getMessage(), PHP_EOL;
}
valid_order_with_checkout = {
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: {
allowed_payment_methods: ["cash", "card", "bank_transfer"],
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({
"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",
"allowed_payment_methods": ["cash", "card", "bank_transfer"],
"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({
"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",
"allowed_payment_methods": ["cash", "card", "bank_transfer"],
"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
{
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",
allowed_payment_methods = new string[]
{
"cash",
"card",
"bank_transfer"
},
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{
AllowedPaymentMethods: []string{"cash", "card", "bank_transfer"},
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"),
},
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'," +
" 'customer_info': {" +
" 'customer_id': 'cus_2o3FvMEBiKitVK1vQ'" +
" }," +
" 'line_items': [{" +
" 'name': 'Box of Cohiba S1s'," +
" 'unit_price': 300000," +
" 'quantity': 1," +
" }]," +
" 'checkout': {" +
" 'allowed_payment_methods': ['cash','card','bank_transfer']," +
" '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);
}Esto regresa una respuesta como la siguiente:
{
"livemode": false,
"amount": 20000,
"currency": "MXN",
"payment_status": "paid",
"amount_refunded": 0,
"customer_info": {
"email": "[email protected]",
"name": "andrea delgado",
"corporate": false,
"customer_id": "cus_2yYDbYkcDCB5queoa",
"object": "customer_info"
},
"shipping_contact": {
"receiver": "Mario perez",
"phone": "+5215555555555",
"between_streets": "Campeche y Morelos",
"address": {
"street1": "Nuevo Leon 4",
"city": "Ciudad de Mexico",
"state": "Ciudad de Mexico",
"country": "mx",
"residential": true,
"object": "shipping_address",
"postal_code": "78215"
},
"id": "ship_cont_2yYE5xyYQaJ8YRAG8",
"object": "shipping_contact",
"created_at": 1755703558
},
"object": "order",
"id": "ord_2yYE5xyYQaJ8YRAG9",
"metadata": {},
"is_refundable": true,
"created_at": 1755703558,
"updated_at": 1755703558,
"line_items": {
"object": "list",
"has_more": false,
"total": 1,
"data": [
{
"name": "Vasija de Cerámica",
"description": "Description",
"unit_price": 20000,
"quantity": 1,
"sku": "SKU",
"tags": [
"tag1",
"tag2"
],
"brand": "Brand",
"object": "line_item",
"id": "line_item_2yYE5xyYQaJ8YRAG5",
"parent_id": "ord_2yYE5xyYQaJ8YRAG9",
"metadata": {
"Valor3": "South#23"
},
"antifraud_info": {}
}
]
},
"shipping_lines": {
"object": "list",
"has_more": false,
"total": 1,
"data": [
{
"amount": 0,
"carrier": "Fedex",
"method": "Airplane",
"tracking_number": "TRACK000000000123",
"object": "shipping_line",
"id": "ship_lin_2yYE5xyYQaJ8YRAG6",
"parent_id": "ord_2yYE5xyYQaJ8YRAG9"
}
]
},
"charges": {
"object": "list",
"has_more": false,
"total": 1,
"data": [
{
"id": "68a5e90679fcdd001abab388",
"livemode": false,
"created_at": 1755703558,
"currency": "MXN",
"payment_method": {
"auth_code": "976866",
"object": "card_payment",
"type": "credit",
"last4": "0121",
"brand": "visa",
"issuer": "",
"account_type": "",
"country": "MX",
"fraud_indicators": [],
"antifraud_flag": "",
"three_ds_flow_required": false,
"product_type": "apple_pay"
},
"object": "charge",
"description": "Payment from order",
"status": "paid",
"amount": 20000,
"paid_at": 1755703558,
"fee": 2785,
"customer_id": "cus_2yYDbYkcDCB5queoa",
"order_id": "ord_2yYE5xyYQaJ8YRAG9"
}
]
}
} echo $result ->getCheckout()->getUrl();
puts order.checkout.allowed_payment_methods.inspect
puts order.checkout.monthly_installments_enabled
puts order.checkout.monthly_installments_options.inspect
puts order.checkout.object
puts order.checkout.url
puts order.checkout.typeconsole.log(stringify(order.checkout.allowed_payment_methods)); // [cash, card, bank_transfer]
console.log(stringify(order.checkout.monthly_installments_enabled)); // true
console.log(stringify(order.checkout.monthly_installments_options)); // [3, 6, 9, 12]
console.log(stringify(order.checkout.url)); // 'https://pay.conektame.io/link/964b5bdfe557467d9e02469e89b48e19
console.log(strinfiy(order.checkout.type)); // 'HostedPayment'Console.WriteLine("[{0}]", string.Join(", ", order.checkout.allowed_payment_methods)); // [cash, card, bank_transfer]
Console.WriteLine(order.checkout.monthly_installments_enabled); // true
Console.WriteLine("[{0}]", string.Join(", ", order.checkout.monthly_installments_options)); // [3, 6, 9, 12]
Console.WriteLine(order.checkout._object); // 'checkout'
Console.WriteLine(order.checkout.url); // 'https://pay.conektame.io/link/964b5bdfe557467d9e02469e89b48e19
Console.WriteLine(order.checkout.type); // 'HostedPayment' fmt.Println("AllowedPaymentMethod: %v\n", order.Checkout.AllowedPaymentMethods)
fmt.Println("MonthlyInstallmentsEnabled: %v\n", order.Checkout.MonthlyInstallmentsEnabled)
fmt.Println("MonthlyInstallmentOptions: %v\n", order.Checkout.MonthlyInstallmentsOptions)
fmt.Println("Url: %v\n", order.Checkout.Url)
fmt.Println("Type: %v\n", order.Checkout.Type)System.out.println(order.checkout.allowed_payment_methods);
System.out.println(order.checkout.monthly_installments_enabled);
System.out.println(order.checkout.monthly_installments_options);
System.out.println(order.checkout.object);
System.out.println(order.checkout.type);WIPOpción B – Sin cuenta de Apple
- Conekta realiza el whitelist de los dominios de tu comercio en los certificados de Conekta 👉 Ver guía para la verificación de dominio
- No es necesario que tengas cuenta de Apple.
- Debes integrar el botón de Apple Pay generando la sesión por el endpoint provisto por conekta:
curl --location --request POST 'https://api.conekta.com/apple_pay/session' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer key_XXXXXXX' \
--data-raw '{
"isTrusted": true,
"methodName": "https://apple.com/apple-pay",
"validationURL": "https://apple-pay-gateway.apple.com/paymentservices/startSession"
}'<?php
require __DIR__ . '/../../vendor/autoload.php';
use Conekta\Api\OrdersApi;
use Conekta\ApiException;
use Conekta\Configuration;
use Conekta\Model\OrderRequest;
$apiKey = getenv("CONEKTA_API_KEY");
$config = Configuration::getDefaultConfiguration()->setAccessToken($apiKey);
$apiInstance = new OrdersApi(null, $config);
$accept_language = 'es';
$rq = new OrderRequest([
'currency' => 'MXN',
'customer_info' => [
'name' => 'fran carrero',
'email'=> '[email protected]',
'phone' => '+5218181818181'
],
'line_items' => [
[
'name' => 'Box of Cohiba S1s',
'unit_price' => 35000,
'quantity' => 1
]
],
'shipping_lines' => [
[
'amount' => 1500,
'carrier' => 'FEDEX'
]
],
'checkout' => [
'allowed_payment_methods' => [
'bank_transfer',
'card',
'cash'
],
'monthly_installments_enabled' => true,
'type' => 'HostedPayment',
'success_url' => 'https://www.example.com/success',
'failure_url' => 'https://www.example.com/failure',
'monthly_installments_options' => [3, 6, 12],
'redirection_time' => 4 //Redirect time to Success-Failure URL, thresholds 4 to 120 sec.
],
'shipping_contact' =>[
'phone' => '+5218181818181',
'receiver' => 'Marvin Fuller',
'address' => [
'street1' => '250 Alexis St',
'city' => 'Red Deer',
'state' => 'Alberta',
'country' => 'CA',
'postal_code' => '01000'
]
]
]);
try {
$result = $apiInstance->createOrder($rq, $accept_language);
$json_string = json_encode($result, JSON_PRETTY_PRINT);
print_r($json_string);
echo $result ->getCheckout()->getUrl();
} catch (ApiException $e) {
echo 'Exception when calling OrdersApi->createOrder: ', $e->getMessage(), PHP_EOL;
}
valid_order_with_checkout = {
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: {
allowed_payment_methods: ["cash", "card", "bank_transfer"],
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({
"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",
"allowed_payment_methods": ["cash", "card", "bank_transfer"],
"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({
"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",
"allowed_payment_methods": ["cash", "card", "bank_transfer"],
"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
{
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",
allowed_payment_methods = new string[]
{
"cash",
"card",
"bank_transfer"
},
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{
AllowedPaymentMethods: []string{"cash", "card", "bank_transfer"},
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"),
},
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'," +
" 'customer_info': {" +
" 'customer_id': 'cus_2o3FvMEBiKitVK1vQ'" +
" }," +
" 'line_items': [{" +
" 'name': 'Box of Cohiba S1s'," +
" 'unit_price': 300000," +
" 'quantity': 1," +
" }]," +
" 'checkout': {" +
" 'allowed_payment_methods': ['cash','card','bank_transfer']," +
" '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);
}- Luego, envía el objeto
pk_paymentdesde tu backend hacia conekta de la siguiente forma:
curl --location 'https://api.conekta.io/orders' \
--header 'Accept: application/vnd.conekta-v2.0.0+json' \
--header 'Content-type: application/json' \
--header 'Authorization: Bearer key_XXXXXXX' \
--data '{
"currency": "MXN",
"customer_info": {
"customer_id": "cus_2yYDbYkcDCB5queoa"
},
"line_items": [
{
"name": "Vasija de Cerámica",
"unit_price": 20000,
"quantity": 1,
"description": "Description",
"sku": "SKU",
"tags": [
"tag1",
"tag2"
],
"brand": "Brand",
"metadata": {
"Valor3": "South#23"
}
}
],
"shipping_lines": [
{
"amount": 0,
"carrier": "Fedex",
"method": "Airplane",
"tracking_number": "TRACK000000000123",
"object": "shipping_line"
}
],
"charges": [
{
"payment_method": {
"type": "apple",
"pk_payment": {
"paymentData": {
"data": "E+xNEXPJEvqr3GwOhhHZ6f/w9wGx6+enZxCK9AnbyTefRq8Ujopfn2hXCHIwpYAU/IkLENqfEihT4yczNBqlxZoKl1NsCYh425d1rZAcaz7KsyzBUcpR47x8ADc61pjFegCxUjuEKHOM318aahN8wd5MwVFG6XLuzkNcF304Np2OQWhOHFe6z+jqjVdNrWzWMvziZ4HJswVrHw195zo0BIUrYVnGaGhvO3Hey/Pt9wU5D05Bv/Cxz0X8MepF8ws8/ps3eIQaDPcYwExqM1f9UHrhucs/YadlQgNn8jODVNAfC8lhGyjzNax5eamV0mPcufiJjDy9CZtR32xB4J1UlLEYI3W+0rpPBJhmSlN9DHe3bLOm0sT5pRhM/+/KT+z2yX+uNigTq3xg28r68HXip4n1xsp/zuCzBmN0rx1KzKlM",
"signature": "MIAGCSqGSIb3DQEHAqCAMIACAQExDTALBglghkgBZQMEAgEwgAYJKoZIhvcNAQcBAACggDCCA+QwggOLoAMCAQICCFnYobyq9OPNMAoGCCqGSM49BAMCMHoxLjAsBgNVBAMMJUFwcGxlIEFwcGxpY2F0aW9uIEludGVncmF0aW9uIENBIC0gRzMxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMwEQ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PxnJpghJvVPh6fRuZy5sJiSFhBpkPCZIdAAAxggGIMIIBhAIBATCBhjB6MS4wLAYDVQQDDCVBcHBsZSBBcHBsaWNhdGlvbiBJbnRlZ3JhdGlvbiBDQSAtIEczMSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMCCFnYobyq9OPNMAsGCWCGSAFlAwQCAaCBkzAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0yNTA4MjAxNTIxNDFaMCgGCSqGSIb3DQEJNDEbMBkwCwYJYIZIAWUDBAIBoQoGCCqGSM49BAMCMC8GCSqGSIb3DQEJBDEiBCBEGdsZtjYjUvkjsgna+Sh4jCl6ob2DF1TSaPrr7IFaNjAKBggqhkjOPQQDAgRHMEUCIE9Ljr5vWYqimMC4lwYjQ49VU2fZfZiIOW+/vGOtXbEyAiEA1R4VwA49S4RB73jfuNmCRKldFzBxqKcwtatUd1GurXIAAAAAAAA=",
"header": {
"publicKeyHash": "MSfGt2ohTwbP4bRZXB+NI/GRFnq4hDyht3hQ5OXBP+U=",
"ephemeralPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEP0W0W6TBGpPWERtz+nD5fI67+5JgOtzXyJgcjj9rByZHG1Hqwk3N74LpKy1O/rR4L4nFyHBH9n6ueQJ2/U3WhA==",
"transactionId": "610c88f19c8d43e289fd1f15bee320d5440c3bd450fcb8431d3a8d4be73f2f01"
},
"version": "EC_v1"
},
"paymentMethod": {
"displayName": "Visa 0121",
"network": "Visa",
"type": "credit"
},
"transactionIdentifier": "610c88f19c8d43e289fd1f15bee320d5440c3bd450fcb8431d3a8d4be73f2f01"
}
}
}
],
"shipping_contact": {
"receiver": "Mario perez",
"phone": "+5215555555555",
"between_streets": "Campeche y Morelos",
"address": {
"street1": "Nuevo Leon 4",
"city": "Ciudad de Mexico",
"state": "Ciudad de Mexico",
"country": "MX",
"postal_code": "78215"
}
}
}'<?php
require __DIR__ . '/../../vendor/autoload.php';
use Conekta\Api\OrdersApi;
use Conekta\ApiException;
use Conekta\Configuration;
use Conekta\Model\OrderRequest;
$apiKey = getenv("CONEKTA_API_KEY");
$config = Configuration::getDefaultConfiguration()->setAccessToken($apiKey);
$apiInstance = new OrdersApi(null, $config);
$accept_language = 'es';
$rq = new OrderRequest([
'currency' => 'MXN',
'customer_info' => [
'name' => 'fran carrero',
'email'=> '[email protected]',
'phone' => '+5218181818181'
],
'line_items' => [
[
'name' => 'Box of Cohiba S1s',
'unit_price' => 35000,
'quantity' => 1
]
],
'shipping_lines' => [
[
'amount' => 1500,
'carrier' => 'FEDEX'
]
],
'checkout' => [
'allowed_payment_methods' => [
'bank_transfer',
'card',
'cash'
],
'monthly_installments_enabled' => true,
'type' => 'HostedPayment',
'success_url' => 'https://www.example.com/success',
'failure_url' => 'https://www.example.com/failure',
'monthly_installments_options' => [3, 6, 12],
'redirection_time' => 4 //Redirect time to Success-Failure URL, thresholds 4 to 120 sec.
],
'shipping_contact' =>[
'phone' => '+5218181818181',
'receiver' => 'Marvin Fuller',
'address' => [
'street1' => '250 Alexis St',
'city' => 'Red Deer',
'state' => 'Alberta',
'country' => 'CA',
'postal_code' => '01000'
]
]
]);
try {
$result = $apiInstance->createOrder($rq, $accept_language);
$json_string = json_encode($result, JSON_PRETTY_PRINT);
print_r($json_string);
echo $result ->getCheckout()->getUrl();
} catch (ApiException $e) {
echo 'Exception when calling OrdersApi->createOrder: ', $e->getMessage(), PHP_EOL;
}
valid_order_with_checkout = {
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: {
allowed_payment_methods: ["cash", "card", "bank_transfer"],
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({
"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",
"allowed_payment_methods": ["cash", "card", "bank_transfer"],
"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({
"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",
"allowed_payment_methods": ["cash", "card", "bank_transfer"],
"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
{
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",
allowed_payment_methods = new string[]
{
"cash",
"card",
"bank_transfer"
},
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{
AllowedPaymentMethods: []string{"cash", "card", "bank_transfer"},
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"),
},
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'," +
" 'customer_info': {" +
" 'customer_id': 'cus_2o3FvMEBiKitVK1vQ'" +
" }," +
" 'line_items': [{" +
" 'name': 'Box of Cohiba S1s'," +
" 'unit_price': 300000," +
" 'quantity': 1," +
" }]," +
" 'checkout': {" +
" 'allowed_payment_methods': ['cash','card','bank_transfer']," +
" '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);
}Esto regresa una respuesta como la siguiente:
{
"livemode": false,
"amount": 20000,
"currency": "MXN",
"payment_status": "paid",
"amount_refunded": 0,
"customer_info": {
"email": "[email protected]",
"name": "andrea delgado",
"corporate": false,
"customer_id": "cus_2yYDbYkcDCB5queoa",
"object": "customer_info"
},
"shipping_contact": {
"receiver": "Mario perez",
"phone": "+5215555555555",
"between_streets": "Campeche y Morelos",
"address": {
"street1": "Nuevo Leon 4",
"city": "Ciudad de Mexico",
"state": "Ciudad de Mexico",
"country": "mx",
"residential": true,
"object": "shipping_address",
"postal_code": "78215"
},
"id": "ship_cont_2yYE5xyYQaJ8YRAG8",
"object": "shipping_contact",
"created_at": 1755703558
},
"object": "order",
"id": "ord_2yYE5xyYQaJ8YRAG9",
"metadata": {},
"is_refundable": true,
"created_at": 1755703558,
"updated_at": 1755703558,
"line_items": {
"object": "list",
"has_more": false,
"total": 1,
"data": [
{
"name": "Vasija de Cerámica",
"description": "Description",
"unit_price": 20000,
"quantity": 1,
"sku": "SKU",
"tags": [
"tag1",
"tag2"
],
"brand": "Brand",
"object": "line_item",
"id": "line_item_2yYE5xyYQaJ8YRAG5",
"parent_id": "ord_2yYE5xyYQaJ8YRAG9",
"metadata": {
"Valor3": "South#23"
},
"antifraud_info": {}
}
]
},
"shipping_lines": {
"object": "list",
"has_more": false,
"total": 1,
"data": [
{
"amount": 0,
"carrier": "Fedex",
"method": "Airplane",
"tracking_number": "TRACK000000000123",
"object": "shipping_line",
"id": "ship_lin_2yYE5xyYQaJ8YRAG6",
"parent_id": "ord_2yYE5xyYQaJ8YRAG9"
}
]
},
"charges": {
"object": "list",
"has_more": false,
"total": 1,
"data": [
{
"id": "68a5e90679fcdd001abab388",
"livemode": false,
"created_at": 1755703558,
"currency": "MXN",
"payment_method": {
"auth_code": "976866",
"object": "card_payment",
"type": "credit",
"last4": "0121",
"brand": "visa",
"issuer": "",
"account_type": "",
"country": "MX",
"fraud_indicators": [],
"antifraud_flag": "",
"three_ds_flow_required": false,
"product_type": "apple_pay"
},
"object": "charge",
"description": "Payment from order",
"status": "paid",
"amount": 20000,
"paid_at": 1755703558,
"fee": 2785,
"customer_id": "cus_2yYDbYkcDCB5queoa",
"order_id": "ord_2yYE5xyYQaJ8YRAG9"
}
]
}
} echo $result ->getCheckout()->getUrl();
puts order.checkout.allowed_payment_methods.inspect
puts order.checkout.monthly_installments_enabled
puts order.checkout.monthly_installments_options.inspect
puts order.checkout.object
puts order.checkout.url
puts order.checkout.typeconsole.log(stringify(order.checkout.allowed_payment_methods)); // [cash, card, bank_transfer]
console.log(stringify(order.checkout.monthly_installments_enabled)); // true
console.log(stringify(order.checkout.monthly_installments_options)); // [3, 6, 9, 12]
console.log(stringify(order.checkout.url)); // 'https://pay.conektame.io/link/964b5bdfe557467d9e02469e89b48e19
console.log(strinfiy(order.checkout.type)); // 'HostedPayment'Console.WriteLine("[{0}]", string.Join(", ", order.checkout.allowed_payment_methods)); // [cash, card, bank_transfer]
Console.WriteLine(order.checkout.monthly_installments_enabled); // true
Console.WriteLine("[{0}]", string.Join(", ", order.checkout.monthly_installments_options)); // [3, 6, 9, 12]
Console.WriteLine(order.checkout._object); // 'checkout'
Console.WriteLine(order.checkout.url); // 'https://pay.conektame.io/link/964b5bdfe557467d9e02469e89b48e19
Console.WriteLine(order.checkout.type); // 'HostedPayment' fmt.Println("AllowedPaymentMethod: %v\n", order.Checkout.AllowedPaymentMethods)
fmt.Println("MonthlyInstallmentsEnabled: %v\n", order.Checkout.MonthlyInstallmentsEnabled)
fmt.Println("MonthlyInstallmentOptions: %v\n", order.Checkout.MonthlyInstallmentsOptions)
fmt.Println("Url: %v\n", order.Checkout.Url)
fmt.Println("Type: %v\n", order.Checkout.Type)System.out.println(order.checkout.allowed_payment_methods);
System.out.println(order.checkout.monthly_installments_enabled);
System.out.println(order.checkout.monthly_installments_options);
System.out.println(order.checkout.object);
System.out.println(order.checkout.type);Updated about 13 hours ago
