javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Feature: Get boleto info

Open lucascarrias opened this issue 5 years ago • 5 comments

References

[Feature request] Get "boleto" information from digitable line #239

Objectives

Create getBoletoInfo function to get data from a valid boleto.

Usage example:

>> getBoletoInfo('23793381286006069409261000063307486470000004200');

>> {
    valueInCents: 4200,
    expirationDate: 2021-06-10T03:00:00.000Z,
    bankCode: '237'
   }

Changes

  • Create getValueInCents function
  • Create getExpirationDate function
  • Create getBankCode function
  • Create Boleto interface
  • Create getInfo function and export it as getBoletoInfo
  • Add getBoletoInfo to docs

Notes

The currency field mentioned at #239 hasn't been added because, most of cases, the brazilian payment method will be charged with BRL values.

lucascarrias avatar Jun 11 '21 00:06 lucascarrias

Nice job @LucasCarrias ! @all-contributors please add @LucasCarrias for docs, tests, and code.

hyanmandian avatar Jun 11 '21 14:06 hyanmandian

@hyanmandian

I've put up a pull request to add @LucasCarrias! :tada:

allcontributors[bot] avatar Jun 11 '21 14:06 allcontributors[bot]

@hyanmandian Thanks for the reviews! I'll follow your recommendations.

lucascarrias avatar Jun 11 '21 17:06 lucascarrias

@hyanmandian I've refactored the code following the changes requests, with some notes:

  • The substr method was replaced by slice as the substr is considered a legacy method (ref)
  • Negatives indexes were used instead of using the someString.length - reverveIndexPosition expression

lucascarrias avatar Jun 11 '21 18:06 lucascarrias

As soon I have time I will merge and publish your utility.

Thanks for your contribution and welcome aboard!

hyanmandian avatar Jun 11 '21 20:06 hyanmandian