1. Go to this page and download the library: Download wire4/wire4-api-sdk-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wire4 / wire4-api-sdk-php example snippets
essToken= "";
try {
// Create the authenticator to obtain access token
$oauth = new \mx\wire4\auth\OAuthWire4 (
'YOUR_OAUTH_CONSUMER_KEY', //REPLACE THIS WITH YOUR DATA
'YOUR_OAUTH_CONSUMER_SECRET', //REPLACE THIS WITH YOUR DATA
\mx\wire4\auth\Environment::SANDBOX); // O \mx\wire4\auth\Environment::PRODUCTION
// Obtain an access token use application flow and scope "general"
$accessToken= $oauth->obtainAccessTokenApp("general");
} catch(OAuthException $e) {
echo "Respuesta: ". $e->lastResponse . "\n";
}
$apiInstance = new \mx\wire4\client\api\ComprobanteElectrnicoDePagoCEPApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$body = new \mx\wire4\client\model\CepSearchBanxico(); // \mx\wire4\client\model\CepSearchBanxico | Información para buscar un CEP
try {
$result = $apiInstance->obtainTransactionCepUsingPOST($body,$accessToken);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ComprobanteElectrnicoDePagoCEPApi->obtainTransactionCepUsingPOST: ', $e->getMessage(), PHP_EOL;
}
$message = "{\"id\":\"evt_641296342fdbf2db40ce674dde4881b87ada81b1695ae1c54666578272c1cd10\",\"object\":\"spid_outgoing\",\"api_version\":\"1.0.0\",\"created\":\"2019-12-05T11:55:10.058-06:00\",\"data\":{\"account\":\"8999998\",\"amount\":120.25,\"currency_code\":\"USD\",\"monex_description\":\"Nombre Receptor: BANAMEX | Monto Pago: 120.25 | Cuenta beneficiaria: 112680000189999984 | Nombre Beneficiario: [email protected] | Clave de Rastreo: | Referencia Numerica: 1234567 | Concepto del pago: Transfer out test 1 | Fecha Confirmacion de Liquidacion: 05-12-2019 11:55:10\",\"detention_message\":\"Cuenta de beneficiario, no existe\",\"payment_order_id\":1427991983,\"status_code\":\"FAILED\",\"transaction_id\":704814938,\"beneficiary_account\":\"112680000189999984\",\"beneficiary_bank\":{\"key\":\"40112\",\"name\":\"BMONEX\",\"company_name\":\"BANCO MONEX S.A. INSTITUCION DE BANCA MULTIPLE, MONEX GRUPO FINANCIERO\",\"rfc\":\"BMI9704113PA\"},\"beneficiary_name\":\"[email protected]\",\"concept\":\"Transfer out test 1\",\"order_id\":\"8A736A1D-ECA6-4959-93FE-794365F53E24\",\"reference\":1234567,\"request_id\":\"7dbf528d-b395-4779-924e-b182a4de17a5\",\"cep\":{}},\"livemode\":false,\"pending_webhooks\":0,\"request\":\"8A736A1D-ECA6-4959-93FE-794365F53E24\",\"type\":\"TRANSACTION.OUTGOING.SPID.RECEIVED\"}";
$referenceString = "7c088d16a8a25f1640e95dfdce65770cb0a31dc0e71a9749bba1e4e114201efb6e78c50bea3d8d9337b8ea63b2a8abf5b1e03d0cf9dda6f8e83a509d1ac11908";
$key = "wh_6b5cb70ab7fd489a8bd0c9d06513008"; //Lo encontraras en la consola de administracion de wire4.mx una vez que estes registrado y hayas dado de alta un webhook, reemplaza este valor
$signResult = \mx\wire4\webhooks\sign\UtilsCompute::toExadecimal(
\mx\wire4\webhooks\sign\UtilsCompute::computeHmacSha512($message, $key));
var_dump($signResult);
if( ! \mx\wire4\webhooks\sign\UtilsCompute::compareSignatures($referenceString,$signResult) ) {
echo "Las firmas no son iguales:";
} else {
echo "Las validacion de firmas es correcta";
}
echo "\noriginal:".$referenceString;
echo "\nresultado:".$signResult;