#steven_charge-paymentintent

1 messages ยท Page 1 of 1 (latest)

viscid eagleBOT
forest owlBOT
#

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.

viscid eagleBOT
#

๐Ÿ‘‹ 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.

spiral fern
#

Hello! That might be normal and expected. What browser are you using?

atomic crescent
#

Chrome

spiral fern
#

Is that error preventing something from working?

atomic crescent
#

I think so. I'm trying to run stripe.createPaymentMethod

#

and its not throwing any errors other than that

spiral fern
#

Can you link me to the page where this is happening so I can investigate?

atomic crescent
#

its behind a paywall.

spiral fern
#

Can you create a minimal public test case that reproduces the issue?

atomic crescent
#

yes give me a minute

#

Well ...I would have except we just lost power .....again ....so I will have to get back to you

spiral fern
#

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. ๐Ÿ™‚

atomic crescent
#

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?

amber tulip
#

Hey there ๐Ÿ‘‹ jumping in as Rubeus needed to step away. Please bear with me a moment while I catch up here.

atomic crescent
#

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.

amber tulip
#

Do you know which line of that code is throwing that error?

atomic crescent
#

stripe.createPaymentMethod({stripeElements, params: { "billing_details": { "name": $('#billing-first-name').val() + ' ' + $('#billing-last-name').val(), "address_zip": $('#billing-zip').val() } } })

amber tulip
#

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.

atomic crescent
#

ok now II get
IntegrationError: Found multiple payment method elements: [object Object], [object Object], [object Object]. Pass in a single element instead.

amber tulip
#

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?

atomic crescent
#

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) });

amber tulip
atomic crescent
#

ok but the responde has customer as null.

#

how do I make sure it gets attached to the right customer?

amber tulip
#

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

atomic crescent
#

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.

amber tulip
#

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.

atomic crescent
#

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?

amber tulip
#

Probably, that answer may change depending on how exactly you plan to use the API to charge them though.

atomic crescent
#

$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

amber tulip
#

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

atomic crescent
#

ok so on the payment intent, I can use a PM or a card right?

amber tulip
#

Yup, that should work.

viscid eagleBOT