#developer.designer
1 messages · Page 1 of 1 (latest)
You can't access the card data, as that would then require you to be PCI compliant
so how can I set the payment method on the stripe using API?
Anyone? @mental turtle @glad sage
Please don't @ us
I'm not sure what you mean by 'set the payment method'. What are you trying to do exactly?
Can you please check is this have payment method?
https://dashboard.stripe.com/customers/cus_Nx3itdvwyAUG2b
That Customer has no saved payment methods, no. What did you attempt to make you think it should?
I have stripe element for the add the card. I want to add into the payment method that card details
You should be following this guide: https://stripe.com/docs/payments/save-and-reuse?platform=web
You need to create a Setup Intent for your Customer, collect the card details (like you are), and then call confirmCardSetup in Stripe.js
Hello
I've added the live keys for the create the stripe elements but still allow test cards. How to prevent that?
Hi! I'm taking over this thread.
If you use live keys you can't use test cards.
Are you use you changed the keys on both your frontend and your backend?
Yes
Can you share the PaymentIntent ID (pi_xxx)?
This customer has no payment made.
the stripe elements but still allow test cards. How to prevent that?
Can you clarify what you mean by this? You managed to make a succesful payment with a test card in live mode?
yes correct
let STRIPE_PUBLISHABLE_KEY = 'pk_live_51IC***';
// Create an instance of the Stripe object and set your publishable API key
const stripe = Stripe(STRIPE_PUBLISHABLE_KEY);
// Select subscription form element
const subscrFrm = document.querySelector("#subscrFrm");
// Attach an event handler to subscription form
subscrFrm.addEventListener("submit", handleSubscrSubmit);
let elements = stripe.elements();
var style = {
base: {
lineHeight: "30px",
fontSize: "16px",
border: "1px solid #ced4da",
}
};
let cardElement = elements.create('card', {hidePostalCode: true, style: style});
cardElement.mount('#card-element');
cardElement.on('change', function (event) {
displayError(event);
});
function displayError(event) {
if (event.error) {
showMessage(event.error.message);
}
}
I'm using this code for the create the stripe element
Can you share the PaymentIntent ID that was successful?
You can see all your succesfull payments here: https://dashboard-admin.stripe.com/payments
The user can enter any card details in the Payment Element, but if they enter a test card (like 4242), then when you confirm the payment it will be declined.