[php] minw
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- <?php
- $var = 'const KycGenerateURL = async function(req, res) {
- var { name, surname, doc_number, doc_type, birthdate, country } = req.body;
- if (!name || !surname || !doc_number || !doc_type || !birthdate || !country) {
- return res.status(200).send({ code: 409,
- message: "Envie los campos requeridos",
- required_fields: [
- "name",
- "surname",
- "doc_number",
- "doc_type",
- "birthdate",
- "country",
- ]
- });
- }
- if (!Validator.isIn(doc_type, [\'DNI\', \'NIE\', \'Pasaporte\', \'docidentidad\'])) {
- return res.status(200).send({
- code: 409,
- message: "doc_type (\'DNI\', \'NIE\', \'Pasaporte\', \'docidentidad\')"
- });
- }
- var birthdateFormat = birthdate.replace(/^(\\d{4})-(\\d{2})-(\\d{2})$/g,\'$3/$2/$1\');
- try{
- let foundKYC = await UsersKyc.findOne({ where: { doc_number: doc_number, status: 1 } });
- if (foundKYC) {
- return res.status(200).send({
- code: 409,
- message: "Ya existe un proceso pendiente para doc_number: "+doc_number,
- pending: foundKYC
- });
- }
- var kycDDBB = await UsersKyc.create({
- name: name,
- surname: surname,
- doc_type: doc_type,
- doc_number: doc_number,
- birthdate: birthdate,
- country: country,
- });
- var parametros = {
- "variables": {
- "Token": process.env.ADDALIA_TOKEN,
- "OperationType": "Operation_Identity_MindCapital",
- "OperationNumber": kycDDBB.id,
- "Country": country,
- "Doc_type": doc_type,
- "Name": name,
- "Surname": surname,
- "Doc_number": doc_number,
- "B_Date": birthdateFormat,
- "PPV_OK": "SI"
- }
- }
- var param = new Buffer.from(JSON.stringify(parametros)).toString("base64");
- await UsersKyc.update({
- url: `${process.env.ADDALIA_URL}?param=${param}`,
- }, { where: { id: kycDDBB.id} });
- return res.status(200).send({
- code: 201,
- message: "URL generada exitosamente",
- operation_number: kycDDBB.id,
- url: `${process.env.ADDALIA_URL}?param=${param}`,
- });
- }
- catch (error) {
- console.log(error);
- return res.status(500).send(error);
- }
- };';
Editor
You can edit this paste and save as new: