#steven_charge-paymentintent
1 messages ยท Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- steven-gauerke_code, 4 hours ago, 7 messages
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1255953117409710152
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
Hello! That might be normal and expected. What browser are you using?
Chrome
Is that error preventing something from working?
I think so. I'm trying to run stripe.createPaymentMethod
and its not throwing any errors other than that
Can you link me to the page where this is happening so I can investigate?
its behind a paywall.
Can you create a minimal public test case that reproduces the issue?
yes give me a minute
Well ...I would have except we just lost power .....again ....so I will have to get back to you
Ah, that's unfortunate! Hope your power comes back soon. If this thread is closed when you return use the buttons in #help to create a new one. ๐
ok Rubeus.....i found out the call IS runniing but herre's what I'm gettinig now:
IntegrationError: Unexpected property: stripeElements
`client_secret = data.stripeClientKey;
stripe = Stripe(data.stripePublicKey);
stripeElements = stripe.elements(client_secret);
stripeCard = stripeElements.create("cardNumber", {classes: {base: 'form-set-input'}});
stripeExpire = stripeElements.create("cardExpiry", {classes: {base: 'form-set-input'}});
stripeCvc = stripeElements.create("cardCvc", {classes: {base: 'form-set-input'}});
stripeCard.mount("#cardnumber");
stripeExpire.mount("#expiration");
stripeCvc.mount("#cvc");`
I take it I can't use it like that?
Hey there ๐ jumping in as Rubeus needed to step away. Please bear with me a moment while I catch up here.
Basically, we already have a card on file fron when they first signed up. I'm trying to let them add a new payment method.
Do you know which line of that code is throwing that error?
stripe.createPaymentMethod({stripeElements, params: { "billing_details": { "name": $('#billing-first-name').val() + ' ' + $('#billing-last-name').val(), "address_zip": $('#billing-zip').val() } } })
Ah, since your variable isn't named the same thing as the parameter you're passing it to, you have to specify what parameter it's for.
I think changing this:
stripe.createPaymentMethod({stripeElements,
to this:
stripe.createPaymentMethod({elements: stripeElements,
will help avoid that error.
ok now II get
IntegrationError: Found multiple payment method elements: [object Object], [object Object], [object Object]. Pass in a single element instead.
Hm, I didn't expect that, but maybe I'm forgetting something about how that works since you're using split card elements. Are you by chance creating any other Elements, such as the Payment Element, using stripeElements as well?
no. heres the first thing I do:
`$.ajax({
url: "/ajax/getSetupIntent.php",
type: 'POST',
data: {"office": OFFICE, "customer" : _OFFICE.stripeCustomerID},
dataType: "json",
success: function(data) {
if(data.status == 1) {
$('#stripePaymentForm').attr("data-secret", data.stripeClientKey);
client_secret = data.stripeClientKey;
stripe = Stripe(data.stripePublicKey);
stripeElements = stripe.elements(client_secret);
stripeCard = stripeElements.create("cardNumber", {classes: {base: 'form-set-input'}});
stripeExpire = stripeElements.create("cardExpiry", {classes: {base: 'form-set-input'}});
stripeCvc = stripeElements.create("cardCvc", {classes: {base: 'form-set-input'}});
stripeCard.mount("#cardnumber");
stripeExpire.mount("#expiration");
stripeCvc.mount("#cvc");
} else {
alert(data.msg);
}
}
});`
Then the click functioni for the button is:
$('#updateBtn').prop("disabled", true); stripe.createPaymentMethod({ stripeElements, params: { "billing_details": { "name": $('#billing-first-name').val() + ' ' + $('#billing-last-name').val(), "address": { "postal_code": $('#billing-zip').val() } } } }) .then(function(result) { console.log(result) });
Okay, maybe it just doesn't work with the split card Element. Can you try the syntax shown here instead, where you use the card parameter and pass it the cardNumber Element instance instead of the entire Elements instance?
https://docs.stripe.com/js/payment_methods/create_payment_method
ok but the responde has customer as null.
how do I make sure it gets attached to the right customer?
Did you attach the Payment Method to the Customer? Or are you using Setup Intents to finish setting up the Payment Method you just created?
Taking a step back, I'm not sure this is how I would approach collecting new payment method details for future usage. If you're maintaining an existing integration, that's one thing, but if you're building a new integration, I'd be more inclined to suggest you use our Setup Intent flow to collect and prepare payment methods for future usage.
https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements
oh......silly me. thats done from my end.
I was doing using CreateSource
I already am doing this actually.
for the client side
I think my issue is that I was I'm not saving the PM stripeJS just created, and adding it to the customer. I have to do othat via PHP.
Ah, yeah, that sounds like it could be it! Creating a Payment Method doesn't automatically attach it to a Customer, that has to be triggered from backend code.
ok now this creates a PM id....my exisiting iintegratiion has stored card_ ID's
will they still work with billing them via the API?
Probably, that answer may change depending on how exactly you plan to use the API to charge them though.
$response = $pg->stripe->charges->create([ 'amount' => $payment['Payment'] * 100, 'currency' => 'usd', 'customer' => $payment['stripeCustomerId'], 'source' => $payment['VaultId'], 'description' => 'RIDA Subscription', ], [ 'idempotency_key' => $payment['idempotency'] ]);
right now, the VaultId is something like card_1Ot8JNA4M1Qr14F68sP14DKu
Offhand, I don't think that will work, but testmode can be used to confirm that. I'm pretty sure the Charge API endpoints are expecting Source objects rather than Payment Method objects.
If that request does indeed error, you'll want to look at using a Payment Intent instead of a Charge. Those I know will accept and work with Payment Methods.
https://docs.stripe.com/api/payment_intents/create
ok so on the payment intent, I can use a PM or a card right?
Yup, that should work.