What is the format for Stripe Connect access tokens? - stripe-payments

I'm trying to use stripe connect and I want to make sure that I'm receiving stripe access tokens that I can use to make charges on the behalf of Stripe users. The access token I'm getting in my test environment looks like this:
sk_test_VyqtfZ6IIPMR1dyY0Po9O29i
Is this how they are formatted? Is there a way I can do a test charge on this token?

That looks to me more like a Test Secret Key, an internal API key, rather than a card token. To generate a card token you should be using the createToken function from Stripe's JavaScript API. Once you've done that you can pass that token instead of credit card details when creating a charge. Here is the relevant documentation from the API, and the part of interest:
card: optional, either card or customer is required, but not both. A card to be charged. The card can either be a token, like the ones returned by Stripe.js, or a dictionary containing a user's credit card details
Depending on your specific needs you might consider taking a look at Temboo's Stripe SDK, it reduces the complexity of doing things like creating customers, charges, subscriptions, etc. The free Temboo SDK is available in many popular languages and is a drop-in solution.
Full disclosure: I'm a Temboo employee

Related

Stripe payment APIs -- without using Stripe UI

Can Stripe APIs be used without their client side UI ? For example, we already have credit card info and we want to pass it to Stripe to process charges ?
Yes, it's possible to use the Stripe API without Stripe Elements. I wouldn't personally recommend it since the handling your customers raw credit card information like you're describing has a host of regulatory implications which Stripe covers in-depth here:
https://stripe.com/docs/security/guide
That being said, if your business is prepared to assume that level of liability for your customer's credit card information, you can pass raw credit card information directly to the PaymentMethods API server-side as shown in the example on this page:
https://stripe.com/docs/api/payment_methods/create
Once you've created the payment method, you can use the payment method like any other throughout the rest of the API.

Stripe - Create a Source for a Credit Card using only Stripe API

I'm trying to register a user payment info by directly using fetch to Stripe's API (since it's a React Native app, I can't use Stripe Elements). It follows the usual concept: a user registers his credit card, which is then associated to his account so he can make payments in the app.
I tried to approach this problem by creating a credit card token with the info that the user provides on signup, but I've realized that that token is only worth for one payment, or for associating to a customer.
Meanwhile I saw that Sources are maybe what I need in my app, since we can get back to it and charge it multiple times. However, from what I see in the API docs there's no reference to the credit card info when creating the source.
What do I need to create to be able to do this (registering a card to be used several times) only through the API?
By creating a token previously, you can then use it as an argument to the creation of the source. Then, the token properties will override source parameters. Thanks to #Evgenii Malikov for the tip.
You need to create a token of your card previously. For that, you can use tipsi-stripe package.
Perfect package if you want to implement credit card, apple / google pay.

Is it possible to query Stripe for a credit card belonging to any customer?

I have a subscription service for which free trials are allowed before signing up for the full payed service. I want to ask the customer to provide credit card details before gaining access to the free trial, to prevent abuse of the trial.
I'm using Stripe to handle payments so that I don't have to deal with storage of any sensitive payment information. This free trial scenario would seem to be very common, so I assumed there would be some way to query a card to make sure that it hasn't been used to sign up already. Just some API call that would accept the card number etc. and return a boolean.
I haven't seen anything like in the API docs. I know that fingerprints of cards are accessible after creating a card source, so is it advisable to store them myself and query them? Or have I missed something in the docs?
Just to be clear... I'm not looking to search a card for a particular customer. I know I can iterate over the cards to do that, but I'd have to iterate over the cards of every customer to accomplish what I want, which is not feasible.
Here you probaly want to contact the support team and suggest this as a new feature.
A possibility is the fingerprint you mention, in my opinion this would be the way i would do it too.
One single card should never be associated with one customer in a platform.
No, there is no way to check whether a credit card is used for another customer or not. And there shouldn't be. Because a customer has right to use his/her single credit card to maintain more than accounts.
You can easily integrate trial feature of a Subscription in Stripe which is best way to implement Trial feature using Stripe. If any customer's payment failed after trial expired then you will be notified by Stripe.
And Stripe and any other payment gateway is not advise to store any card info due to security issue.

How do you authorize a credit card in Stripe, WITHOUT creating a customer or a card?

I want to make sure the card the customer has entered is actually a valid card. Stripe.js only validates its format, it doesn't ask for an authorization from the card issuer. But it seems Stripe requires you to create the customer to authorize the card, but this is a bit silly since the logical flow should be this:
Validate form input via stripe.js, and obtain token if format is valid
Authorize token via backend API (PHP/Ruby etc)
If authorized, create card + customer using token, add subscription/charge customer
If NOT authorized, return to form with appropriate error, and do not create the customer/charge.
How do you actually achieve this in Stripe? Is there a dedicated Stripe\Card::authorize($token) method or something similar that can be used?
When you save a card to a customer Stripe does a $0/$1 authorization on the card. You can pass the card when you create the customer, and the customer would only get created if the authorization succeeds. In addition, you can specify the plan and card when creating the customer, the customer and subscription would only get created if the card is valid AND the charge for the first period of the subscription goes through.
the scenario you describe is covered here:
https://stripe.com/docs/charges#auth-and-capture
api is here (also available in php/java/go/node/curl)
https://stripe.com/docs/api/ruby#create_charge

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.

Resources