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

createToken seems to return different object response according to Platform #344

Closed
adrien-may opened this issue Jun 15, 2021 · 1 comment · Fixed by #394
Closed

createToken seems to return different object response according to Platform #344

adrien-may opened this issue Jun 15, 2021 · 1 comment · Fixed by #394
Labels
bug Something isn't working P0 Address these issues first

Comments

@adrien-may
Copy link
Collaborator

Describe the bug
I'm using the createToken method introduced in 0.1.3 and I'm retrieving the token id (tok_xxxxx) in the response.

To Reproduce
Steps to reproduce the behaviour:

Hypothesis: card is valid Card object obtained from a stripe CardField component. I used a setState on the cardField handleChange to set this card object.

Using the following code :

if (Platform.OS === 'android') {
    const { token } = await stripe.createToken(card)
} else {
    const { token: { token } } = await stripe.createToken(card)
}

I get the expected result I want but this implementation is surprising.

Expected behaviour
Response should be formatted the same on both platform.

Also, on the documentation website, createToken seems to expect parameter CreateTokenParams but it does not make a lot of sense to me, I guess typing is wrong here too ? (I'm expecting the type to be like this one: https://stripe.dev/stripe-react-native/api-reference/interfaces/card.params.html)

Thanks in advance for your consideration.

@stripe/stripe-react-native : Version 0.1.3

@thorsten-stripe
Copy link
Contributor

Yes, sorry about that, and thank you for flagging!

AndroidiOS
{
  "livemode": false,
  "bankAccount": null,
  "card": {
    "address": {
      "postalCode": "77063",
      "country": null,
      "line2": null,
      "state": null,
      "line1": "1459  Circle Drive",
      "city": null
    },
    "name": "Testr Test",
    "last4": "4242",
    "funding": "Credit",
    "expMonth": 12,
    "currency": null,
    "expYear": 2022,
    "brand": "Visa",
    "country": "US"
  },
  "type": "Card",
  "created": "1624010380000",
  "id": "tok_1J3eUCG7gfqYEkPOLi2ETY8a"
}
{
  "token": {
    "type": "Card",
    "bankAccount": null,
    "livemode": false,
    "created": "1624010564000.0",
    "id": "tok_1J3eXAG7gfqYEkPOjL44VjTm",
    "card": {
      "funding": "Credit",
      "address": {
        "postalCode": "77063",
        "city": null,
        "country": null,
        "line1": "1459  Circle Drive",
        "line2": null,
        "state": null
      },
      "country": "US",
      "last4": "4242",
      "expMonth": 12,
      "currency": null,
      "name": "Testr Test",
      "brand": "Visa",
      "expYear": 2022
    }
  }
}

@thorsten-stripe thorsten-stripe added the bug Something isn't working label Jun 18, 2021
@thorsten-stripe thorsten-stripe added the P0 Address these issues first label Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 Address these issues first
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants