CoDi private keys
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:
keytool -genkey -alias NombreDeLaEmpresa -keyalg RSA -keystore llavePrivada.jks -keysize 2048 -deststoretype jks -validity 3703. Format the private key
Use the following commands if you need the private key in other formats.
JKS to P12
keytool -importkeystore -srckeystore llavePrivada.jks -destkeystore llavePrivada.p12 -srcstoretype jks -deststoretype pkcs12 -validity 370
P12 to PEM
openssl pkcs12 -in llavePrivada.p12 -out llavePrivada.pem### De P12 to PEM (para uso en JavaScript)
openssl pkcs12 -in llavePrivada.p12 -out llavePrivada.pem -nodes.cer private key
Generate the private key in cer.
Use the following endpoints:
| Endpoint | Method | Description |
|---|---|---|
/payment | POST | Create payment and generate QR code |
/payment/{id} | GET | Retrieve payment status |
/refund | POST | Request refund |
/webhook | POST | Receive payment status notifications |
Purchase V2
- Endpoint:
post {{apigw-url}}/v2/merchants/orders/purchase - Headers:
Authorization: Bearer {{user-token}}x-api-key: {{merchant-private-key}}
{
"order_token":"{{order-token}}",
"order_type": "DEUNA_CHECKOUT",
"payer_info": {
"email": "[email protected]"
},
"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"
}
}
}Purchase V1
= Endpoint: post {{apigw-url}}/merchants/orders/purchase
- Headers:
Authorization: Bearer {{user-token}}x-api-key: {{merchant-private-key}}
{
"order_token":"{{order-token}}",
"billing_address": {
"address_type": "home",
"country": "ECU",
"is_default": false
},
"method_type": "bank_transfer",
"processor_name": "stp_codi",
"shipping_address": {
"is_default": false
},
"specific_fields": {
"description": "Test payment"
},
"payment_method": "{{phone_number || empty}}" // Account number associated to STP account or empty to generate QR code
}Response
{
"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 protected]",
"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
| Status | Description |
|---|---|
pending | Payment awaiting confirmation |
completed | Payment successfully completed |
failed | Payment failed |
expired | QR Code expired without payment |
Updated about 16 hours ago