Stripe usage with token - stripe-payments

I am using Stripe for payment for the first time. While clicking on Pay button when we enter email, card number, date and cvc, I get an error message which asks me to activate my account. I learned that it takes all this information and returns a token which we can save in the database. How do I get a token in return?

thanks for thinking of using Stripe! I work on Support there and can help.
If you're getting that error message about activating your account, it's probably because you're using live keys but don't have a live, active account yet. If you email into Stripe support using the email address associated with your Stripe account, I could look into this for you further (e.g., looking at your logs and status).
As for the token, the token is a short-term representation of the customer's credit card information. You wouldn't need to store the token in your database. You should instead use it to process a charge, or create a customer, and then ignore it (because, at that point, the token will have been consumed).
For more, see this page in our docs:
https://stripe.com/docs/tutorials/charges
Cheers,
Larry

Related

Plaid + Stripe ACH (Developer Mode): Do I need to use a stripe production key

Short story, I am able to successfully use the Plaid API (connected to my stripe account) to get a stripe bank token in sandbox mode.
From there, I can add that bank token to a customers profile in my stripe account (again in test mode).
Now I'm trying to use the plaid developer key instead of sandbox. I'm able to verify my real world bank account via plaid and get a bank token back, but when i try to add that token to my stripe account I get the following error:
Invalid Request: No such token: 'btok_xxxxxxxxxxxDequ'; a similar object exists in live mode, but a test mode key was used to make this request.
This seems to indicate when calling the Stripe API I need to use the production stripe key instead of the test key.
Since stripe doesn't have a "developer" mode like plaid, my question is what happens if I do this? Does the bank account get added to a real customer account (I assume it does).
AND if I attempt to make a charge using this bank token I got back from plaid via developer mode, will this make an actual charge in stripe? or does stripe know the difference and not make an actual charge (withdrawal) for my bank account?
I tried to go through plaid documentation, but there is very little information I could extract about the developer mode.
Thank you for any help you guys can provide.

Is this an acceptable way to accept a one-time payment?

On my site I'm giving users the option to save their card or not. If they choose to save it, I'm creating a Stripe customer object, and if not, I'm just saving the card token, and when it comes time to pay, if they have a Stripe Customer id then I charge that way, and if not, I charge the tokenized card.
There could be cases where a week or so passes before I would charge the card token. Would it still work, and is there anything else wrong with this setup?
Thanks for any advice.
Stripe Tokens are meant to be used within a short period of time from when they are created and should not be stored.
https://stripe.com/docs/api/tokens
If you are not charging the token immediately, I would recommend attaching it to a Customer in that scenario as well.

How to send Billing information with Stripe token for validation checks

I have got a stripe token from stripe js, Now I want to charge the customer. How do I send the billing address along with the stripe token for charging. My objective is to validate zip code and address_line1 which I have enabled at the stripe dashboard.
Note:- I can send the billing info without using a stripe token, by using the card details entered. I want to do it using the token received. Is it possible?
The best solution is to send the billing address details when creating the token with Stripe.js This is covered in the createToken() documentation where it lists all the fields you can provide.
Otherwise, you would save the card on a customer first and then use the Update Card API on the server to provide the billing address.

save card to customer with Stripe.js

How do I save a card to a customer with Stripe.js?
I don't want to change them at this point. I just want to save the credit card info to their stripe account so I can use it later.
It seems like I'd need to use createToken from Stipe.js. But my understanding is that this is a one time use token. I want to save the credit card info for later use.
This seems to be a similar question: Stripe Payment: Save token and customer and make payment later from token
but the solution isn't clear. I'm not sure if it means for the customer I need to save card=token and everything will work fine.
Though the question is an old one and solution of this problem is now pretty straightforward in the current Stripe API, I'm just answering for those who accidentally reached or will reach here without reading the Official Stripe Doc properly(like me) searching for this question.
To make a stripe payment You first need to make a call to the Stripe API(Using Stripe's Checkout widget, Elements or Mobile SDKs) with the User's card information. As a response, you will get a token. Then you can charge your customer immediately using Stripe's Charge API. This is for just one-time payment. You will find an example here.
If you want to save customer's information for later payment, you need to create a 'Customer' first using Stripe's API and then using that customer's ID (returned as a response from the previous API call) you can charge this customer. Example here.
I just described the process briefly to show the idea at a glance. But you should really need to read this quickstart guide in Stripe's documentation. This explains the process very well.
I just want to save the credit card info to their stripe account so I
can use it later.
Then that's exactly what you can do!
If you're already passing the token back into your server-side code, you just need to update that server-side code to retrieve the customer and create the card on that customer record using the token.
Not knowing what language you're using I can't provide relevant sample code, but the Stripe API reference has functional examples for Ruby, Python, PHP, Java, and Node.js.
Note that if the customer has any outstanding invoices, this card will be used the next time they attempt to settleā€”so while simply adding the card won't create a charge by itself, it's possible the card may still be billed.
A key point that the prior answers seems to dance around but do not explicitly state is that you can't simply save the credit card (token) in Stripe. Stripe's API's don't save credit cards per se, however, they can save a customer and attached to the customer you can save one more credit cards (or payment sources). So a credit card (or payment source) is not a stand alone entity in the Stripe storage system, it's a child entity of a Customer.

User to user payment on stripe

My requirement is, from my application I want my user to transfer the amount to another user of my application. Assume that both user have stripe account. I have gone through stripe docs, and I understood that in order to do transfer from one user account to another I need to use stripe connect. I could able to do authentication and I'm getting access token successfully for the sender. How can I make a transfer to a recipient ? I have only recipient's email id with me. Should I need to create a recipient through code and do the transfer using that recipient id returns from stripe ?
Im using php. Please help me.
Stripe Connect doesn't work like that. Instead, Connect allows an application to make card charges on behalf of a user and take a portion of the amount. The rest is automatically and immediately put into the user's Stripe account, where it's subject to the normal bank account transfer rules (2-7 day rolling transfers or API-driven manual transfers).
Another way to do this is using Stripe Recipients and Transfers. For example, your application charges a customer $10. You create a Recipient for your user using their bank account information (account number and routing number). Then, you can create a Transfer from your Stripe account to their bank account. Note that this only works for US bank accounts as of today.
If you really want to do user to user transfers, unfortunately Stripe isn't the platform for you. You could use PayPal or you could possibly use Balanced Payments, although again you can only transfer money to and from US bank accounts.

Resources