Comments (12)
@ptaking:
If you're using the stripe={...}
prop on StripeProvider (which means you're using one of the advanced loading strategies), your code would look like this:
Another thing is that you're missing a call to injectStripe
. You won't be able to do this unless you've called injectStripe
on your checkout form:
https://github.com/stripe/react-stripe-elements#setting-up-your-payment-form-injectstripe
from react-stripe-elements.
In the official docs, it's documented that you can use bank_account
[0] or pii
[1] as string arguments to createToken
.
So if I were to be using individual *Element components, what type would I specify? cardNumber perhaps? Is this what is being set implicitly if I pass in no arguments?
If you were using Element instances, you can specify the Element as the first argument. However, if you're using this library, you can omit the first argument and just call props.stripe.createToken()
directly within a component that has stripe
injected.
[0] https://stripe.com/docs/stripe.js#collecting-bank-account-details
[1] https://stripe.com/docs/stripe.js#collecting-pii-data
from react-stripe-elements.
Ah, re: black box, you can use it like this if you want to explicitly specify the type:
stripe.createToken({type: 'card'})
from react-stripe-elements.
For additional clarification: you would never use cardNumber
because that's an Element type, but not a token type. I definitely see the confusion with card
being both an Element type and a Token type!
Please let us know if this clarifies things!
from react-stripe-elements.
I definitely see the confusion with card being both an Element type and a Token type!
Yeah, this is what was tripping me up at first.
I appreciate y'all trying to explain this to me. I'm still a bit confused by the ostensibly conflicting nature of these two comments
If you were using Element instances, you can specify the Element as the first argument.
you would never use
cardNumber
because that's an Element type, but not atoken
type.
It isn't a token itself that we pass, it's "the Element you wish to tokenize data from", right? And since cardNumber
is a type of element, very similar to the card
element, I guess I had figured that cardNumber
would also have been tokenizable.
I think I'm square on how it works now, it was just the ability to call props.stripe.createToken()
and have the element be passed implicitly that was mysterious to me since it doesn't work this way in the official Elements docs. And then having to pass an object, {type: 'card'}
, was also tripping me up since I wasn't sure what this was doing.
from react-stripe-elements.
All said, I don't know what an alternative solution would be for this. I think what y'all have created is great considering the limitations at hand.
Doing something like the docs would be hard
const card = elements.create('card')
// …later
const {token, error} = await stripe.createToken(card)
Since the <*Element>
components are already created for us, there is never a point in time where we as developers call something like elements.create()
(in fact, elements.create()
isn't even exposed publicly). Using something like {type: 'card'}
feels like an okay solution, I just imagine it may confuse other people the way it initially confused me.
from react-stripe-elements.
@indiesquidge Sorry, I made it more confusing! :) What I meant was you would never pass the string 'cardNumber'
to createToken
. You could pass a cardNumber
-type Element (and that is in fact how you tokenize using the split fields). Does that help?
from react-stripe-elements.
You could pass a
cardNumber
-type Element (and that is in fact how you tokenize using the split fields).
But this is not the case with this repository, right? You cant't pass in the CardNumberElement
component as an argument to stripe.createToken()
. The actual element isn't exposed publicly.
Based on the signature it seems like something of type ElementShape
could be passed in, but I get an error any way I attempt to do this.
But you do pass in the element when you use the Stripe API in vanilla JS.
This is kind of the essence of my confusion here: You never actually pass an element type into stripe.createToken()
—it seems to be implicitly derived, but I'm not entirely sure I understand why.
from react-stripe-elements.
@indiesquidge Right! In react-stripe-elements
, you're not calling elements.create()
directly, so it would be awkward to require users to pass the Element to createToken
.
from react-stripe-elements.
@indiesquidge So what will be passed to stripe.createToken()
if my form rendered as below?
return (
<div id="wrapper">
<HeaderComponent />
<main>
<StripeProvider stripe={this.state.stripe}>
<Elements>
<label>
Card details
<CardElement/>
</label>
</Elements>
</StripeProvider>
</main>
</div>
);
from react-stripe-elements.
Where in the process is the payment made to Stripe?
I've been able to setup my form component using individual form components CardElement, CardNumberElement, CardExpiryElement, CardCVCElement) and I'm getting back the strip token.
What I don't understand is where the payment (amount, currency, stripe token, etc) is supposed to occur?
from react-stripe-elements.
@rdalfonso You need to send the token to your backend server, and use your Stripe API secret key to POST to the /v1/charges endpoint:
https://stripe.com/docs/charges
from react-stripe-elements.
Related Issues (20)
- CardNumberElement Placeholder Not Working HOT 1
- CardCvcElement onComplete fires after three digits for AMEX card HOT 2
- docs: confirmCardPayment with split card elements needs a docs update HOT 1
- Payment Fields are not clickable in Samsung device HOT 2
- My Stripe promise with React never resolves even after trying a timeout HOT 1
- 3D Secure Test Payment Screen iFrame - Any way to preview or control width/height? HOT 1
- Not able to customize CSS of CardElement HOT 1
- Split Card Number Not Inserted with 1Password Autofill HOT 1
- Elements locale option not localizing HOT 5
- When click on stripe element its getting blur HOT 1
- About scan card feature in mobile device HOT 1
- PaymentRequestButton Does Not Load On Safari PWA HOT 1
- Stripe console message : parameter: betas is not a recognized parameter. HOT 2
- Connection Failure text in CardNumberElement HOT 3
- loadStripe does not seem to work
- styling CardElement HOT 1
- Add support for extra types of buttons for Apple Pay HOT 1
- Elements tag doesn't accept locale HOT 2
- Add a full stripe elements integration example HOT 1
- PaymentRequestButtonElement Integration Error with saved browser card HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-stripe-elements.