PHP code example of apihub-cdc / fico-extended-score-client-php
1. Go to this page and download the library: Download apihub-cdc/fico-extended-score-client-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/ */
apihub-cdc / fico-extended-score-client-php example snippets
$password = getenv('KEY_PASSWORD');
$this->signer = new \RCCFicoScorePLD\Client\Interceptor\KeyHandler(
"/example/route/keypair.p12",
"/example/route/cdc_cert.pem",
$password
);
$config = new \FicoEXTScored\Client\Configuration();
$config->setHost('the_url');
public function setUp(){
$password = getenv('KEY_PASSWORD');
$this->signer = new \FicoEXTScored\Client\Interceptor\KeyHandler(null, null, $password);
$events = new \FicoEXTScored\Client\Interceptor\MiddlewareEvents($this->signer);
$handler = handlerStack::create();
$handler->push($events->add_signature_header('x-signature'));
$handler->push($events->verify_signature_header('x-signature'));
$client = new \GuzzleHttp\Client(['handler' => $handler]);
$config = new \FicoEXTScored\Client\Configuration();
$config->setHost('the_url');
$this->apiInstance = new \FicoEXTScored\Client\Api\FicoEXTScoredApi($client, $config);
$this->x_api_key = "your_api_key";
$this->username = "your_username";
$this->password = "your_password";
}
public function testGetReporte(){
$request = new \FicoEXTScored\Client\Model\Peticion();
$persona = new \FicoEXTScored\Client\Model\Persona();
$domicilio = new \FicoEXTScored\Client\Model\Domicilio();
$estado = new \FicoEXTScored\Client\Model\CatalogoEstados();
$domicilio->setDireccion("CALVARIO");
$domicilio->setColoniaPoblacion("LOMA DE LA PALMA");
$domicilio->setDelegacionMunicipio("GUSTAVO A MADERO");
$domicilio->setCiudad("CIUDAD DE MEXICO");
$domicilio->setEstado($estado::DF);
$domicilio->setCP("07160");
$domicilio->setFechaResidencia(null);
$domicilio->setNumeroTelefono(null);
$domicilio->setTipoDomicilio(null);
$domicilio->setTipoAsentamiento(null);
$domicilio->setFechaRegistroDomicilio(null);
$domicilio->setTipoAltaDomicilio(null);
$domicilio->setIdDomicilio(null);
$persona->setApellidoPaterno("PATERNO");
$persona->setApellidoMaterno("MATERNO");
$persona->setApellidoAdicional(null);
$persona->setNombres("NOMBRES");
$persona->setFechaNacimiento("YYYY-MM-DD");
$persona->setRFC("PAMN800825569");
$persona->setCURP(null);
$persona->setNacionalidad("MX");
$persona->setResidencia(null);
$persona->setEstadoCivil(null);
$persona->setSexo(null);
$persona->setNumeroDependientes(null);
$persona->setFechaDefuncion(null);
$persona->setDomicilio($domicilio);
$request->setFolio("1235");
$request->setPersona($persona);
try {
$result = $this->apiInstance->getReporte($this->x_api_key, $this->username, $this->password, $request);
print_r($result);
$this->assertTrue($result->getFolioConsulta()!==null);
return $result->getFolioConsulta();
} catch (Exception $e) {
echo 'Exception when calling FicoEXTScoredApi->getReporte: ', $e->getMessage(), PHP_EOL;
}
}
sh
#ejemplo con php en versión 7.3 para otra versión colocar php{version}-curl
apt-get install php7.3-curl
apt-get install php7.3-mbstring
sh
export KEY_PASSWORD=your_password
sh
export PRIVATE_KEY_FILE=pri_key.pem
export CERTIFICATE_FILE=certificate.pem
export SUBJECT=/C=MX/ST=MX/L=MX/O=CDC/CN=CDC
export PKCS12_FILE=keypair.p12
export ALIAS=circulo_de_credito