Skip to main content
On this page

Generate your private key to operate CoDi via STP.

1. Review your credentials#

In the Admin, search for the STP Codi in the Connections option and add the following credentials:

  • Name: Connection name
  • Currency: For Codi, only MXN is available
  • Company: Company name registered with STP
  • Beneficiary Account: STP account number
  • Beneficiary Name: Beneficiary name registered with STP
  • Private Key: Private key that must be generated. You can find more details in the “Generate Private Key” section.
  • Time to Expire: Reference expiration time in minutes.

2. Generate your private key#

Create the private key in JKS format by executing the following command: Ejecutar el siguiente comando:

Shell
keytool -genkey -alias NombreDeLaEmpresa -keyalg RSA -keystore llavePrivada.jks -keysize 2048 -deststoretype jks -validity 370

3. Format the private key#

Use the following commands if you need the private key in other formats.

JKS to P12

Shell
keytool -importkeystore -srckeystore llavePrivada.jks -destkeystore llavePrivada.p12 -srcstoretype jks -deststoretype pkcs12 -validity 370

​

P12 to PEM

Shell
openssl pkcs12 -in llavePrivada.p12 -out llavePrivada.pem

​### De P12 to PEM (para uso en JavaScript)

Shell
openssl pkcs12 -in llavePrivada.p12 -out llavePrivada.pem -nodes

.cer private key#

Generate the private key in cer.

Use the following endpoints from CoDi:

EndpointMethodDescription
/paymentPOSTCreate a payment and generate QR code
/payment/{id}GETRetrieve payment status
/refundPOSTRequest refund
/webhookPOSTReceive payment status notifications

Purchase V2

Make a call to the V2 Purchase endpoint to generate and order in DEUNA.

  • Endpoint: post {{apigw-url}}/v2/merchants/orders/purchase
  • Headers:
    • Authorization: Bearer {{user-token}}
    • x-api-key: {{merchant-private-key}}
JSON
{
		"order_token":"{{order-token}}",
    "order_type": "DEUNA_CHECKOUT",
    "payer_info": {
        "email": "email1@email.com"
    },
    "payment_source": {
        "method_type": "bank_transfer",
        "processor": "stp_codi",
        "payment_method": "{{phone_number || empty}}", // Account number associated to STP account or empty to generate QR code
        "method_type_specific_fields": {
	          "description": "Test payment"
        }
    }
}

Response

JSON
{
    "order_type": "DEUNA_NOW",
    "order_token": "4598f493-de86-4fe0-b9fd-c4c6c9847e39",
    "order": {
        "order_id": "DEUNA_NOW_b6a5c0b6-3df9-4b3b-b778-7086c190062b",
        "store_code": "all",
        "currency": "MXN",
        "tax_amount": 10000,
        "display_tax_amount": "",
        "shipping_amount": 10000,
        "display_shipping_amount": "MXN 100,00",
        "items_total_amount": 10000,
        "display_items_total_amount": "MXN 100,00",
        "sub_total": 10000,
        "display_sub_total": "MXN 100,00",
        "total_amount": 10000,
        "display_total_amount": "MXN 100,00",
        "status": "pending",
        "payment": {
            "data": {
                "amount": {
                    "amount": 10000,
                    "currency": "MXN"
                },
                "metadata": {
                    "key1": "value1",
                    "key2": "value2"
                },
                "updated_at": "2024-12-05 18:28:14.726950103 +0000 UTC",
                "method_type": "bank_transfer",
                "merchant": {
                    "store_code": "all",
                    "id": "e25c4fff-ef50-498b-9a3c-5937d96280f7"
                },
                "created_at": "2024-12-05 18:28:14.725709716 +0000 UTC",
                "id": "DEUNA_NOW_b6a5c0b6-3df9-4b3b-b778-7086c190062b",
                "processor": "stp_codi",
                "payment_method_type": "push_notification",
                "customer": {
                    "email": "email@email.com",
                    "id": "ac434d25-1f42-44b5-883f-fa1b2a08eec6",
                    "first_name": "",
                    "last_name": ""
                },
                "status": "pending",
                "next_action": {
                    "action": "authorization_bank_transfer",
                    "authorization_bank_transfer": {
                        "reference": "{{folioCodi}}",
                        "expiration_date": "2025-05-05 14:20:50",
                        "qr": ""
                    }
                },
                "reason": "",
                "external_transaction_id": "{{folioCodi}}",
                "merchant_payment_processor_name": "",
                "authorization_code": "",
                "installment_interest_calculations": null
            }
        },
        ...
    }
}

Payment status

CoDI statusDEUNA statusDescription
pendingpendingPayment awaiting confirmation
completedprocessedPayment completed
faileddeniedPayment failed
expiredexpiredQR Code expired without payment