pagarme-js icon indicating copy to clipboard operation
pagarme-js copied to clipboard

Expected format for card validation/card hash gen

Open filenda opened this issue 5 years ago • 4 comments

Description

According to https://docs.pagar.me/v2017-08-28/docs/obtendo-os-dados-do-cartao if you send an object you should get a validation object descriptive of whether your input info is valid or not.

Using the previous version (3.0) I was able to get a card_hash if i sent a valid credit card info, but couldn't get it to return proper when invalid data (eg. card number) was sent (it would cause an exception).

The above case was corrected in version 3.1 but now when I input a valid credit card info it says both card_expiration_month and card_expiration_year are invalid. What is the expected format then?

eg.: "01/2025", "01/25", "01-2025", "01-25"

My Setup

  • Operating System: Win 10
  • Project Version: https://assets.pagar.me/pagarme-js/3.1/pagarme.min.js
  • [x] I have tested with the latest version
  • [x] I can simulate the issue easily

Current Behavior

SDK validate function acuses wrong expiration year

Expected Behavior

Valid input should only return a card_hash

filenda avatar Nov 12 '18 13:11 filenda

@vfilenga can you please try to update your library? 😬 we're currently at version 3.8.0 =S (ref)

lucianopf avatar Nov 12 '18 20:11 lucianopf

@lucianopf Thanks!

Do you know how to use this newer version in the browser? The official guideline (https://unpkg.com/[email protected]/README.md) is still referencing version 3.1.

Using the below implementation just didn't work. <script src="https://unpkg.com/[email protected]/pagarme.min.js"></script>

I'm getting Uncaught ReferenceError: module is not defined at pagarme.min.js:1

filenda avatar Nov 12 '18 23:11 filenda

Can you please try using this source instead? https://unpkg.com/[email protected]/browser/pagarme.min.js

Sorry for the inconvenience @vfilenga =/

lucianopf avatar Nov 13 '18 12:11 lucianopf

@lucianopf my bad I didn't check this folder. Didn't work though.

This is how I'm calling the validate function:

var cardValidations = pagarme.validate({ card: card })

Object passed to be validated (data ofuscated): {"card_holder_name":"xxxx r xxx","card_expiration_date":"0125","card_number":"5209999999996030","card_cvv":"021"}

I think that this specific function might be deprecated

filenda avatar Nov 13 '18 13:11 filenda