#developer.designer

1 messages · Page 1 of 1 (latest)

glad sageBOT
mental turtle
#

You can't access the card data, as that would then require you to be PCI compliant

strange solar
#

so how can I set the payment method on the stripe using API?

#

Anyone? @mental turtle @glad sage

mental turtle
#

Please don't @ us

mental turtle
strange solar
mental turtle
#

That Customer has no saved payment methods, no. What did you attempt to make you think it should?

strange solar
#

I have stripe element for the add the card. I want to add into the payment method that card details

mental turtle
#

You need to create a Setup Intent for your Customer, collect the card details (like you are), and then call confirmCardSetup in Stripe.js

glad sageBOT
strange solar
#

Hello

#

I've added the live keys for the create the stripe elements but still allow test cards. How to prevent that?

severe pagoda
#

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?

strange solar
#

Yes

severe pagoda
#

Can you share the PaymentIntent ID (pi_xxx)?

strange solar
#

I don't know where to find PaymentIntent

severe pagoda
#

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?

strange solar
#

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

severe pagoda
#

Can you share the PaymentIntent ID that was successful?

#

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.