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

[Stripe-v3] Allow Implicit Elements Resolution #40470

Closed
wants to merge 1 commit into from

Conversation

JakeCooper
Copy link

@JakeCooper JakeCooper commented Nov 18, 2019

Stripe supports implicit elements resolution through createToken.

If only options are passed, it will attempt to resolve the element from Stripe.js.

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If adding a new definition:

  • The package does not already provide its own types, or cannot have its .d.ts files generated via --declaration
  • If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
  • Represents shape of module/library correctly
  • tslint.json should be present and it shouldn't have any additional or disabling of rules. Just content as { "extends": "dtslint/dt.json" }. If for reason the some rule need to be disabled, disable it for that line using // tslint:disable-next-line [ruleName] and not for whole package so that the need for disabling can be reviewed.
  • tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: <>
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }. If for reason the any rule need to be disabled, disable it for that line using // tslint:disable-next-line [ruleName] and not for whole package so that the need for disabling can be reviewed.

If removing a declaration:

  • If a package was never on DefinitelyTyped, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.)
  • Delete the package's directory.
  • Add it to notNeededPackages.json.

Stripe supports implicit elements resolution through createToken. 

If only options are passed, it will attempt to resolve the element from Stripe.js.
@typescript-bot typescript-bot added this to Waiting for Reviewers in Pull Request Status Board Nov 18, 2019
@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Awaiting reviewer feedback labels Nov 18, 2019
@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 18, 2019

@JakeCooper Thank you for submitting this PR!

🔔 @ejsmith @amritk @AdamCmiel @jleider @galuszkak @slangeder @marlosin @ttmarek @kimehrenpohl @KrishnaPravin @hirochachacha - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot
Copy link
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

Comparison details 📊
master #40470 diff
Batch compilation
Memory usage (MiB) 80.5 80.0 -0.6%
Type count 11317 11317 0%
Assignability cache size 34676 34676 0%
Language service
Samples taken 433 433 0%
Identifiers in tests 433 433 0%
getCompletionsAtPosition
    Mean duration (ms) 365.9 365.3 -0.2%
    Mean CV 9.6% 10.0%
    Worst duration (ms) 474.7 468.6 -1.3%
    Worst identifier threeDSource paymentMethod
getQuickInfoAtPosition
    Mean duration (ms) 368.0 362.9 -1.4%
    Mean CV 10.4% 10.3% -0.9%
    Worst duration (ms) 473.8 460.6 -2.8%
    Worst identifier id style

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label Nov 18, 2019
@KrishnaPravin
Copy link
Contributor

KrishnaPravin commented Nov 19, 2019

@JakeCooper
stripe.createToken({ name: 'customer name' }).then((result) => console.log(result))
When I tried using this snippet, I got the error from Stripe saying "You must provide a Stripe Element or a valid token type to create a Token.".

I guess we need to pass at least any 1 element to the createToken method. eg: a CVV element can resolve other elements like card number, expiry, etc

@JakeCooper
Copy link
Author

https://github.com/stripe/react-stripe-elements/blob/master/README.md#server-side-rendering-ssr

Did you try it with server side rendering? I'm running that exact code on a new project and it doesn't seem to error.

@typescript-bot typescript-bot moved this from Waiting for Reviewers to Review in Pull Request Status Board Nov 23, 2019
@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Nov 23, 2019
@typescript-bot
Copy link
Contributor

After 5 days, no one has reviewed the PR 😞. A maintainer will be reviewing the PR in the next few days and will either merge it or request revisions. Thank you for your patience!

@KrishnaPravin
Copy link
Contributor

https://github.com/stripe/react-stripe-elements/blob/master/README.md#server-side-rendering-ssr

Did you try it with server side rendering? I'm running that exact code on a new project and it doesn't seem to error.

If possible can you please send a small working snippet. So that I can run it.

@amcasey
Copy link
Contributor

amcasey commented Nov 26, 2019

Sounds like we should hold off on merging until we hear back from @KrishnaPravin?

@KrishnaPravin
Copy link
Contributor

Sounds like we should hold off on merging until we hear back from @KrishnaPravin?

If someone else can verify if Stripe supports implicit elements resolution through createToken without at least one stripe element you can definitely merge it.

It is just I'm not able to replicate from my side.

@amritk
Copy link
Contributor

amritk commented Nov 26, 2019

Isn't it about time stripe starts managing these themselves? Can we tag a stripe engineer?

@KrishnaPravin
Copy link
Contributor

Isn't it about time stripe starts managing these themselves? Can we tag a stripe engineer?

It will definitely help. Please do it.

@orta
Copy link
Collaborator

orta commented Dec 10, 2019

They will be: stripe/stripe-node#736

Not sure what to do with this PR yet, so will hold off on merging.

@rattrayalex-stripe
Copy link

@orta that PR is for a different library than this one is; they're orthogonal.
However, I'll bump this PR to the relevant internal team...

@mbarrett-stripe
Copy link

mbarrett-stripe commented Dec 11, 2019

Hi, I work on Stripe.js

I think there's been a bit of a misconception here. This version of createToken is available only in react-stripe-elements and is not a native capability of Stripe.js v3's createToken(). You can see the function being wrapped for React application convenience here

I'd recommend taking a look at the DefinitelyTyped defs for React-Stripe-Elements and seeing if that satisfies the need here, looks like it might.

@sandersn
Copy link
Contributor

Sounds like this can be closed then.

@sandersn sandersn closed this Dec 17, 2019
Pull Request Status Board automation moved this from Review to Done Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Popular package This PR affects a popular package (as counted by NPM download counts). Unmerged The author did not merge the PR when it was ready.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants