CoDi®. payments
The objective of this guide is to explain step by step how to generate payment references with CoDi®.
CoDi® is a platform developed by Banco de México to facilitate payment and collection transactions through electronic transfers quickly, safely and efficiently, through mobile phones.
CoDi® uses the technology of QR Codes, they are free-to-use two-dimensional barcodes, they are easy to implement and to read through any mobile device and NFC which is a technology based on the creation of an electromagnetic field in which, by induction, an information exchange is generated between devices (terminal and mobile). This in order to facilitate that both businesses and users can carry out transactions without cash.
For more information see the CoDi® official site.
Charges with QR
Following is the flow for generating charges with a dynamic QR code, which has a life time of five minutes.
Steps:
The merchant requests the generation of a QR code to charge.
From the Openpay API, the QR code is returned to the merchant so that it can make the charge.
The merchant exposes the QR code through the medium of its choice (Print, Screen, etc.) so that its customer can make the payment.
The client scans the QR code from the mobile app of his bank.
The client confirms the payment from the mobile app of his bank.
The bank where the customer's account is located sends the payment notification to Banxico.
Banxico notifies Openpay that the charge was successful.
Openpay confirms the charge to trade.
In this guide we will see steps number 1 and 2.
Generate QR code (Step 1 and 2)
To generate a QR code it is necessary to create a charge indicating in the field
method
the type codi
and the option codi_options
with the attribute mode
the value QR_CODE
as follows:
@openpay = OpenpayApi . new ( "mzdtln0bmtms6o3kck8f" , "sk_e568c42a6c384b7ab02cd47d2e407cab" )
@charges = @openpay . create ( :charges )
request_hash = {
"method" => "codi" ,
"amount" => 200 . 00 ,
"description" => "Cargo con código QR" ,
"order_id" => "codi-00051" ,
"due_date" => "2020-12-20T13:45:00" ,
"codi_options" => {
"mode" : "QR_CODE"
},
"customer" => {
"name" : "Ricardo" ,
"last_name" : "Martinez" ,
"email" : "this.is.a@customer.test" ,
"phone_number" : "4421217210"
}
}
response_hash = @charges . create ( request_hash . to_hash )
<?php
$openpay = Openpay :: getInstance ( 'mzdtln0bmtms6o3kck8f' ,
'sk_e568c42a6c384b7ab02cd47d2e407cab' );
$chargeData = array (
'method' => 'codi' ,
'amount' => 200.00 ,
'description' => 'Cargo con código QR' ,
'order_id' => 'codi-00051' ,
'codi_options' => ''
'due_date' => '2020-12-20T13:45:00' ,
'codi_options' => {
'mode' : 'QR_CODE'
},
'customer' => {
'name' : 'Ricardo' ,
'last_name' : 'Martinez' ,
'email' : 'this.is.a@customer.test' ,
'phone_number' : '4421217210'
}
);
$charge = $openpay -> charges -> create ( $chargeData );
?>
OpenpayAPI api = new OpenpayAPI ( "https://sandbox-api.openpay.mx" ,
"sk_e568c42a6c384b7ab02cd47d2e407cab" , "mzdtln0bmtms6o3kck8f" );
Charge charge = api . charges (). create ( new CreateBankChargeParams ()
. method ( "codi" )
. description ( "Cargo con código QR" )
. amount ( new BigDecimal ( "200.00" )) // Amount is in MXN
. orderId ( "codi-00051" )) // Optional transaction identifier
. dueDate ( "2020-12-20T13:45:00" )
. codiOptions (). mode ( "QR_CODE" )
. customer (). name ( "Ricardo" )
. customer (). lastName ( "Martinez" )
. customer (). email ( "this.is.a@customer.test" )
. customer (). phoneNumber ( "4421217210" );
OpenpayAPI api = new OpenpayAPI ( "sk_e568c42a6c384b7ab02cd47d2e407cab" , "mzdtln0bmtms6o3kck8f" );
ChargeRequest request = new ChargeRequest ();
request . Method = "codi" ;
request . Amount = new Decimal ( 200.00 );
request . Description = "Cargo con código QR" ;
request . OrderId = "codi-00051" ;
request . DueDate = "" 2020 - 12 - 20 T13 : 45 : 00 "" ;
request . CodiOptions . Mode = "QR_CODE" ;
request . Customer . Name = "Ricardo" ;
request . Customer . LastName = "Martinez" ;
request . Customer . Email = "this.is.a@customer.test" ;
request . Customer . PhoneNumber = "4421217210" ;
Charge charge = api . ChargeService . Create ( request );
var openpay = new Openpay ( 'gdntnaxvkcdviesgaxem' , 'sk_b97e606487d34b44ab66e03d5bd14747' );
var bankChargeRequest = {
'method' : 'codi' ,
'amount' : 200 ,
'description' : 'Cargo con código QR' ,
'order_id' : 'codi-00051' ,
'due_date' : '2020-12-20T13:45:00' ,
'codi_options' : {
'mode' : "QR_CODE"
},
'customer' => {
'name' : "Ricardo" ,
'last_name' : "Martinez" ,
'email' : "this.is.a@customer.test" ,
'phone_number' : "4421217210"
}
};
openpay . customers . charges . create ( customerId , bankChargeRequest , function ( error , charge ) {
// ...
});
import openpay
openpay . api_key = "sk_e568c42a6c384b7ab02cd47d2e407cab"
openpay . merchant_id = "mzdtln0bmtms6o3kck8f"
charge = openpay . Charge . create (
method = "codi" ,
amount = 200.00 ,
description = "Cargo con código QR" ,
order_id = "codi-00051" ,
due_date = "2020-12-20T13:45:00" ,
codi_options = {
"mode" : "QR_CODE"
},
customer = {
"name" : "Ricardo" ,
"last_name" : "Martinez" ,
"email" : "this.is.a@customer.test" ,
"phone_number" : "4421217210"
}
);
At the time the charge is created, a transaction object is returned.
Response:
{
"id" : "tr47lahm4etz1rqz1nbs" ,
"authorization" : null ,
"operation_type" : "in" ,
"transaction_type" : "charge" ,
"status" : "charge_pending" ,
"conciliated" : false ,
"creation_date" : "2020-07-15T16:58:16-05:00" ,
"operation_date" : "2020-07-15T16:58:16-05:00" ,
"description" : "PUSH_NOTIFICATION" ,
"error_message" : null ,
"order_id" : "codi-929678" ,
"due_date" : "2020-07-20T13:45:00-05:00" ,
"amount" : 76.99 ,
"customer" : {
"name" : "Ricardo" ,
"last_name" : "Martinez" ,
"email" : "this.is.a@customer.test" ,
"phone_number" : "4421217210" ,
"address" : null ,
"creation_date" : "2020-07-15T16:58:15-05:00" ,
"external_id" : null ,
"clabe" : null
},
"payment_method" : {
"type" : "codi" ,
"barcode_url" : "https://dev-api.openpay.mx/codi-qrcode/tr47lahm4etz1rqz1nbs" ,
"barcode_base64" : "iVBORw0KGgoAAAANSUhEUgAAAdEAAAHRCAAAAAAQqNxHAAALsklEQVR42u3c0XLjOBJE0fn/n9593xjLNwFSPbNx8OS2LYrEgSNSVRX913+s/6/1ly0gahG1iFpELaJELaIWUYuoRZSoRdQiahG1iBK1iFpEre+I/vX7+p9f/rvX/t2v/M9P/+6rv7uXH6/842t/vOf6RuHZfvznjy8Lr/jxp58ViBIlSpQoUaLviv4cpn4nrBaff/nzxoQd+2zx+SxP73u4a+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HV8Zg6sVugeHEILZtMpnLI4UaJEiRIlSvQN0dqODD3EWgCsjxSeMNQrD/lDcj2Mr7UrWpquRIkSJUqUKNFnReuqt3DYiazxetqx0I4M/DcVyf3Z6tAYUaJEiRIlSvQN0Wmue2ozXhfEpgJguPHPcXNK0YdR9fB5rzreRIkSJUqUKNFnu2l79gsBdc+c0yumJ3pwJm0/JvXPgihRokSJEiX6VdGbDDYlzcMEuXUO51xb+6PPUD/zEYMoUaJEiRIl+idFK1co4v34e1MhLpT4porkg63b2nl9sQpIlChRokSJEv1HiP4y7xQdb0Lh3iSd3jzo7Xs1zakRJUqUKFGiRN8VraWs+u6fY2loGk4ZNrxlQK83WS0Opb7S8SZKlChRokSJ/lqxCt3EPZFO97sfogfLbzeZfS8Uhkz8SzomSpQoUaJEiT4rav2LF1GiFlGLqEXUIkrUImoRtYhaRIlaRC2iFlGLKFGLqEXUen79F/Lsh0S2EJI2AAAAAElFTkSuQmCC" ,
"mode" : "qr_code"
},
"currency" : "MXN" ,
"method" : "codi"
}
With this QR code, your customer can make the payment by scanning it from their bank's mobile app.
Charges with static QR
Below is the flow for generating charges with a static QR code which has a longer life time than the dynamic one.
Steps:
The merchant requests the generation of a static QR code to carry out the charge.
From the Openpay API the QR code is sent to the merchant so that it can make the charge, this code is valid for one month.
The merchant exposes the QR code through the medium of its choice (Print, Screen, etc.) so that its customer can make the payment.
The client scans the QR code from the mobile app of his bank.
The client confirms the payment from the mobile app of his bank.
The bank where the customer's account is located sends the payment notification to Banxico
Banxico notifies Openpay that the charge was successful.
Openpay confirms the charge to the merchant.
In this guide we will see steps number 1 and 2.
Generate static QR code (Step 1 and 2)
To generate a QR code it is necessary to create a charge indicating the product data as follows:
@openpay = OpenpayApi . new ( "mzdtln0bmtms6o3kck8f" , "sk_e568c42a6c384b7ab02cd47d2e407cab" )
@charges = @openpay . create ( :charges )
request_hash = {
"amount" => 200 . 00 ,
"description" => "Cargo con código QR Estático" ,
"external_id" => "codi-00051" ,
"due_date" => "2020-07-20T13:45:00"
}
response_hash = @charges . create ( request_hash . to_hash )
<?php
$openpay = Openpay :: getInstance ( 'mzdtln0bmtms6o3kck8f' ,
'sk_e568c42a6c384b7ab02cd47d2e407cab' );
$chargeData = array (
'amount' => 200.00 ,
'description' => 'Cargo con código QR Estático' ,
'external_id' => 'codi-00051' ,
'due_date' => '2020-07-20T13:45:00'
);
$charge = $openpay -> charges -> create ( $chargeData );
?>
OpenpayAPI api = new OpenpayAPI ( "https://sandbox-api.openpay.mx" ,
"sk_e568c42a6c384b7ab02cd47d2e407cab" , "mzdtln0bmtms6o3kck8f" );
Charge charge = api . charges (). create ( new CreateBankChargeParams ()
. description ( "Cargo con código QR Estático" )
. amount ( new BigDecimal ( "200.00" )) // Amount is in MXN
. externalId ( "codi-00051" )) // Optional transaction identifier
. dueDate ( "2020-07-20T13:45:00" );
}
OpenpayAPI api = new OpenpayAPI ( "sk_e568c42a6c384b7ab02cd47d2e407cab" , "mzdtln0bmtms6o3kck8f" );
ChargeRequest request = new ChargeRequest ();
request . Amount = new Decimal ( 200.00 );
request . Description = "Cargo con código QR Estático" ;
request . ExternalId = "codi-00051" ;
request . DueDate = "2020-07-20T13:45:00" ;
Charge charge = api . ChargeService . Create ( request );
var openpay = new Openpay ( 'gdntnaxvkcdviesgaxem' , 'sk_b97e606487d34b44ab66e03d5bd14747' );
var bankChargeRequest = {
'amount' : 200 ,
'description' : 'Cargo con código QR Estático' ,
'external_id' : 'codi-00051' ,
'due_date' : '2020-07-20T13:45:00'
};
openpay . customers . charges . create ( customerId , bankChargeRequest , function ( error , charge ) {
// ...
});
import openpay
openpay . api_key = "sk_e568c42a6c384b7ab02cd47d2e407cab"
openpay . merchant_id = "mzdtln0bmtms6o3kck8f"
charge = openpay . Charge . create (
amount = 200.00 ,
description = "Cargo con código QR Estático" ,
external_id = "codi-00051" ,
due_date = "2020-07-20T13:45:00"
);
At the time the charge is created, a transaction object is returned.
Response:
{
"id" : 54 ,
"amount" : 6999.99 ,
"due_date" : "2020-07-20T13:45:00-05:00" ,
"description" : "Product X99" ,
"external_id" : "Store-1003" ,
"metadata" : "{"param1":"val1","param2":"val2"}" ,
"barcode" : null ,
"barcode_url" : "https://dev-api.openpay.mx/codi/open_codes/54/qr_code" ,
"barcode_base64" : "iVBORw0KGgoAAAANSUhEUgAAAdEAAAHRCAAAAAAQqNxHAAALnUlEQVR42u3d0Y7cNhqEUb//S2fvF5n2V6TUToKjKwfjUUs8NFBdP7H76y/Xf+v6ZQmIuoi6iLqIuogSdRF1EXURdREl6iLqIuoi6iJK1EXURdT1HdFfv79+/LVwg7/7oL/7z3D7//tBfYUfb/rjXfb/DJ/xdz+oi/jzMhElSpQoUaJEXxD9OUydqUy2E+bnD/9xicIb7Qvx+S4/bsXwVNWIKFGiRIkSJfqa6I+PdWg7xdLPb/P5r4SVqLE0vFF985CndwWiRIkSJUqU6D9I9PMb1uD5eWGC3uGW2C1CKg/rXsMyUaJEiRIlSvRfKFoHfyHY1dng4RpPSbN++M2n/UOzLlGiRIkSJUp0ncyFOeX1+a7KX5ftJqXWw2UhXk9Z93sTb6JEiRIlSpRoK8nqpNSfHv1TUCBKlChRfyLqT++KTqew6kC0Bt6aL6cSb68067my8B61Jw0Jt6AQJUqUKFGiRJ8VDXnr+jfqIkyHy26qu+k6rPimo3bTShIlSpQoUaJEXxOt5532c1GfJ6rhMWrgDaPbm7Ac9vI0Wv78LPX2RIkSJUqUKNE3RGveyvHrLDeWY1Kxh6wFZSWcsulhE7rvQqJEiRIlSpToa6J7apummBPrMyPUz0kzJOuAVMeq04YOz0eUKFGiRIkSfU30mUXdW8Xrhm7/tOvxZgjfhzu9/gZRokSJEiVK9F3RKesGkLqeU2tXo+Bk8WBXV1+1Vpp1lkyUKFGiRIkSfVj08x2qVH2vvY2rQ9ypnHtmnjld4QWnupEoUaJEiRIl+i3RKaDup6tqmbYfp5rmvIeDyT3Sfv7dw4BPlChRokSJEn1DNGS/UFFNr1TLyPBANTbfTCxvQKZ/FmEPECVK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wuxfprf3lSVVy0gUaJEiRIlSnQVDctxGGTreh6CTJPXKaTX5nLaA/s6EyVKlChRokS/L3pTuk3d2mEhFjrCOrANjlNPOn3aNKat/w6IEiVKlChRog+LflapldwkUCeHe5bcQ2Z9guu+sjaNW59KlChRokSJEn1W9GaoOV3TDDEMCKdnmULm4cgz6E278OrkGFGiRIkSJUr01TP1u1nNl2ER6pLXMm061RWe/jDrHs6ciRIlSpQoUaKvid6EuIOB3lIUTpPXg2NXv3/w/alKQF02zNXJMaJEiRIlSpTokWgNvNND11Fr7dtuEu7hxHd/y6kUfHE+SpQoUaJEiRK9FN3XJLzS1MbtLWUYOE40IdZP4XvvP6fdRZQoUaJEiRJ9QzQEwAdHqHtXt2NOneMUc6fjbWFdaptJlChRokSJEv2CaCWcxqB1jT+/Vz2ttR9WCwxTXr2B29eUKFGiRIkSJfqa6PRKUyL9fL8Hx4f77Q8/d1qcwxtsh9CIEiVKlChRos+K7qF1nz8ejgUPR6h7gL6ZB3/+3MNNef/thShRokSJEiV63hlNIXOKllOqfHpCO01yp4nqZFantmFXEyVKlChRokS/ILonyKnxe8ZsWp1wjKtmzjpqrR8epqxEiRIlSpQo0T8uWtf9psk7TNuhb6sLczMkneao9WvC/hWDKFGiRIkSJfrPED18m/f2T02z9THqUtZqsS4TUaJEiRIlSvRfKDqduJqOSYV+8SoU/j6VT6PW/bUC8LQpiRIlSpQoUaLvitaf1pXYM+Leyx0OK8OU9WY8HO5S4zBRokSJEiVK9Pui+0wydHVVNOTkmxt8ftUwON0372EM31tPokSJEiVKlOjDoq5/8UWUqIuoi6iLqIsoURdRF1EXURdRoi6iLqIuoi6iRF1EXURdz1//A/5LuRLh2rsyAAAAAElFTkSuQmCC"
}
With this QR code, your customer can make the payment by scanning it from their bank's mobile app.
Payment notification
Below is the flow for the generation of charges for payment notification.
Steps:
The user requests the merchant to make the payment request.
The merchant requests Openpay to make the payment request to Banxico.
Banxico makes the payment request to the corresponding bank.
The bank to which the user's account belongs makes the payment request to the customer and requests confirmation.
The client authorizes or declines the charge requested by the bank.
In this guide we will see steps number 1 and 2.
Payment Notification Sending (Step 1 and 2)
To make a payment notification notification it is necessary to create a charge indicating in the field method
the type codi
and the option codi_options
with the following attributes mode
the value PUSH_NOTIFICATION
, use_customer_phone
the value false
, phone_number
the customer phone number, as follows:
@openpay = OpenpayApi . new ( "mzdtln0bmtms6o3kck8f" , "sk_e568c42a6c384b7ab02cd47d2e407cab" )
@charges = @openpay . create ( :charges )
request_hash = {
"method" => "codi" ,
"amount" => 200 . 00 ,
"description" => "Cargo por Notificación de Pago" ,
"order_id" => "codi-00051" ,
"due_date" => "2020-12-20T13:45:00" ,
"codi_options" => {
"mode" : "PUSH_NOTIFICATION" ,
"use_customer_phone" : false ,
"phone_number" : "4421217210"
},
"customer" => {
"name" : "Ricardo" ,
"last_name" : "Martinez" ,
"email" : "this.is.a@customer.test" ,
"phone_number" : "4421217210"
}
}
response_hash = @charges . create ( request_hash . to_hash )
<?php
$openpay = Openpay :: getInstance ( 'mzdtln0bmtms6o3kck8f' ,
'sk_e568c42a6c384b7ab02cd47d2e407cab' );
$chargeData = array (
'method' => 'codi' ,
'amount' => 200.00 ,
'description' => 'Cargo por Notificación de Pago' ,
'order_id' => 'codi-00051' ,
'codi_options' => ''
'due_date' => '2020-12-20T13:45:00' ,
'codi_options' => {
'mode' : 'PUSH_NOTIFICATION' ,
'use_customer_phone' : false ,
'phone_number' : '4421217210'
},
'customer' => {
'name' : 'Ricardo' ,
'last_name' : 'Martinez' ,
'email' : 'this.is.a@customer.test' ,
'phone_number' : '4421217210'
}
);
$charge = $openpay -> charges -> create ( $chargeData );
?>
OpenpayAPI api = new OpenpayAPI ( "https://sandbox-api.openpay.mx" ,
"sk_e568c42a6c384b7ab02cd47d2e407cab" , "mzdtln0bmtms6o3kck8f" );
Charge charge = api . charges (). create ( new CreateBankChargeParams ()
. method ( "codi" );
. description ( "Cargo por Notificación de Pago" )
. amount ( new BigDecimal ( "200.00" )) // Amount is in MXN
. orderId ( "codi-00051" )) // Optional transaction identifier
. dueDate ( "2020-12-20T13:45:00" )
. codiOptions (). mode ( "PUSH_NOTIFICATION" );
. codiOptions (). useCustomerPhone ( false );
. codiOptions (). phoneNumber ( 4421217210 );
. customer (). name ( "Ricardo" )
. customer (). lastName ( "Martinez" )
. customer (). email ( "this.is.a@customer.test" )
. customer (). phoneNumber ( "4421217210" );
OpenpayAPI api = new OpenpayAPI ( "sk_e568c42a6c384b7ab02cd47d2e407cab" , "mzdtln0bmtms6o3kck8f" );
ChargeRequest request = new ChargeRequest ();
request . Method = "codi" ;
request . Amount = new Decimal ( 200.00 );
request . Description = "Cargo por Notificación de Pago" ;
request . OrderId = "codi-00051" ;
request . DueDate = "" 2020 - 12 - 20 T13 : 45 : 00 "" ;
request . CodiOptions . Mode = "PUSH_NOTIFICATION" ;
request . CodiOptions . UseCustomerPhone ( false );
request . CodiOptions . PhoneNumber ( 4421217210 );
request . Customer . Name = "Ricardo" ;
request . Customer . LastName = "Martinez" ;
request . Customer . Email = "this.is.a@customer.test" ;
request . Customer . PhoneNumber = "4421217210" ;
Charge charge = api . ChargeService . Create ( request );
var openpay = new Openpay ( 'gdntnaxvkcdviesgaxem' , 'sk_b97e606487d34b44ab66e03d5bd14747' );
var bankChargeRequest = {
'method' : 'codi' ,
'amount' : 200 ,
'description' : 'Cargo por Notificación de Pago' ,
'order_id' : 'codi-00051' ,
'due_date' : '2020-12-20T13:45:00' ,
'codi_options' : {
'mode' : "QR_CODE"
},
'customer' => {
'name' : "Ricardo" ,
'last_name' : "Martinez" ,
'email' : "this.is.a@customer.test" ,
'phone_number' : "4421217210"
}
};
openpay . customers . charges . create ( customerId , bankChargeRequest , function ( error , charge ) {
// ...
});
import openpay
openpay . api_key = "sk_e568c42a6c384b7ab02cd47d2e407cab"
openpay . merchant_id = "mzdtln0bmtms6o3kck8f"
charge = openpay . Charge . create (
method = "codi" ,
amount = 200.00 ,
description = "Cargo por Notificación de Pago" ,
order_id = "codi-00051" ,
due_date = "2020-12-20T13:45:00" ,
codi_options = {
"mode" : "PUSH_NOTIFICATION" ,
"use_customer_phone" : false ,
"phone_number" : "4421217210"
},
customer = {
"name" : "Ricardo" ,
"last_name" : "Martinez" ,
"email" : "this.is.a@customer.test" ,
"phone_number" : "4421217210"
}
);
At the time the charge is created, a transaction object is returned.
Response:
{
"id" : "trs1clzwqweqwznutfmt" ,
"authorization" : null ,
"operation_type" : "in" ,
"transaction_type" : "charge" ,
"status" : "charge_pending" ,
"conciliated" : false ,
"creation_date" : "2020-07-15T16:58:33-05:00" ,
"operation_date" : "2020-07-15T16:58:33-05:00" ,
"description" : "PUSH_NOTIFICATION" ,
"error_message" : null ,
"order_id" : "codi-121795" ,
"due_date" : "2020-07-20T13:45:00-05:00" ,
"amount" : 76.99 ,
"customer" : {
"name" : "Ricardo" ,
"last_name" : "Martinez" ,
"email" : "this.is.a@customer.test" ,
"phone_number" : "4421217210" ,
"address" : null ,
"creation_date" : "2020-07-15T16:58:33-05:00" ,
"external_id" : null ,
"clabe" : null
},
"payment_method" : {
"type" : "codi" ,
"mode" : "push_notification" ,
"phone_number" : "4421217210"
},
"currency" : "MXN" ,
"method" : "codi"
}
With this payment notification, your customer can make the payment from their bank's mobile app.