Reputation: 563
I wanted to check if the Credit card details are valid or not. Precisely not just the format but if at all that these details are valid or not. Is there a way to check that through Stripe API.
If no, is there a way to make a payment of zero dollars. Does Stripe deduct any payment charges (any additional charges) in that case?
I prefer doing this through Stripe Javascript(Node js) SDK.
Upvotes: 0
Views: 2990
Reputation: 1
Creating a Payment Method (or legacy Token) on Stripe does not validate the card. Tokenization simply takes raw card details and converts them to a Payment Method/Token, it mostly just runs a Luhn check to verify if the card number is valid.
Validation occurs when you:
1. attach a Payment Method to a Customer
2. confirm a SetupIntent
After creating a Payment Method, you should attach the Payment Method to a Customer (server-side) which will validate the card immediately, and if it does not validate, throw an error, in which case you can prompt your customer to enter a new card in your mobile app. You can get a clear idea from here.
Upvotes: 0
Reputation: 31
You can try "stripe.tokens.create" to create a credit card token. The code for creating the token is shown below:
'use strict';
const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
const token = await stripe.tokens.create({
card: {
number: '4242424242424242',
exp_month: 4,
exp_year: 2022,
cvc: '314',
},
});
This code returns the created card token if successful. Otherwise, this call raises an error. You can read about this method at this link.
Upvotes: 3