Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Node #10

Open
angelhdzmultimedia opened this issue Apr 30, 2023 · 1 comment
Open

API Node #10

angelhdzmultimedia opened this issue Apr 30, 2023 · 1 comment

Comments

@angelhdzmultimedia
Copy link

Buenas. Estoy implementando esta API https://github.com/EstebanFuentealba/flowcl-node-api-client

Tuve que hacerle un fork local porque no soporta ESM.

Tambien reemplace CryptoJS con createHmac de node:crypto obviamente usando sha256.

El payload se imprime en consola, la apiKey, el s (payload firmado), paymentMethod, currency, commerceOrder, email, amount, subject, urlConfirmation y urlReturn.

Las URLs estan bien, el baseUrl es https://sandbox.flow.cl/api y pues tengo estas constantes para los endpoints:

const PaymentUrl = {
  create: 'payment/create',
  createEmail: 'payment/createEmail',
  getStatus: 'payment/getStatus',
}

Estoy haciendo una peticion POST a payment/create pasandole los datos:

 const _params = {
        apiKey: this.apiKey,
        ...params,
      }
      let sign = this.sign(_params)
      _params.s = sign

Y me arroja error:

ERROR [ExceptionsHandler] There's some missing params Error: There's some missing params

mi funcion para firmar es:

sign(params) {
    const keys = Object.keys(params)
      .map((key) => key)
      .sort((a, b) => {
        if (a > b) return 1
        else if (a < b) return -1
        return 0
      })

    let toSign: string = keys
      .map((key) => {
        return key + params[key]
      })
      .join('')

    return createHmac('sha256', this.secretKey).update(toSign).digest('hex')
  }

y la cadena que retorna sigue el formato mostrado en la documentacion:

image

Cualquier informacion brindada sera agradecida.

@angelhdzmultimedia
Copy link
Author

Actualización

Vi los cambios en https://www.flow.cl/docs/api_changelog.txt, y añadi el payment_currency. El error continua.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant