#sweetpotato8776
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- sweetpotato8776, 51 minutes ago, 34 messages
Yes initialize stripe once, but the elements needs to be separated as I believe their options are different
one stripe object and two elements object ( payment elements object, express checkout element objects) is it right??
Yeah I think so but please try it
I tried to it, what the error means : Uncaught (in promise) IntegrationError: Unexpected property: elements2. Put additional API properties in params. ?
Sorry that lacks a lot of details. Can you share the whole code block where you initialized 2 elements?
stripe = Stripe(Rdata.config("payment.stripe.api.key.public"));
const totalOrderAmt = Number(Rdata.get("totalOrderCentAmt"));
const options = {
mode: 'payment',
amount: totalOrderAmt,
currency: 'usd',
paymentMethodCreation: 'manual',
appearance: {
theme: 'stripe'
}
};
elements = stripe.elements(options);
const paymentElement = elements.create("payment",
{
paymentMethodOrder: [ 'card','apple_pay', 'google_pay', 'klarna']
, layout: {
type: 'tabs',
}
,fields : { "billingDetails" : 'never'}
,wallets : {
applePay : 'auto'
,googlePay : 'never'
}
}
);
paymentElement.mount("#div-stripe");
//GOOGLE PAY
const googleElementOption = {
mode: 'payment',
amount: totalOrderAmt, //google/app pay 표시용
currency: 'usd',
};
elements2 = stripe.elements(googleElementOption);
const appearance2 = { /* appearance */ }
const options2 = {
wallets : {
applePay : 'never'
,googlePay : 'always'
}
}
expreeCheckoutElements = stripe.elements({
mode: 'payment',
amount: totalOrderAmt,
currency: 'usd',
appearance2,
})
expreeCheckoutElements = expreeCheckoutElements.create('expressCheckout', options2);
expreeCheckoutElements.mount('#express-checkout-element');
This is the part that mounts the button.
expreeCheckoutElements.on('confirm', async (event) => {
const {error: submitError} = await elements2.submit();
if (submitError) {
handleError(submitError);
return;
}
// Create the PaymentIntent and obtain clientSecret
const {error, paymentMethod} = await stripe.createPaymentMethod({
elements2,
params: {
billing_details: billingDetail
}
});
billingInfo.paymentMethodId = paymentMethod.id;
const stripeVO = {};
stripeVO.customerId = Rdata.get("stripeCustId");
billingInfo.stripeVO = stripeVO;
// Create the PaymentIntent
const response = await RestClient.post("/api/stripe/payment-intent")
.data(billingInfo)
.silence()
.run()
.then(response => {
return response;
})
.catch(err => {
location.href="/errors/orderError.html";
});
if (response) {
if (response.error) {
location.href="/errors/orderError.html";
} else if (response.status === "requires_action") {
// Use Stripe.js to handle the required next action
const {error, paymentIntent} = await stripe.handleNextAction({
clientSecret: response.clientSecret
});
if (error) {
location.href="/errors/orderError.html";
}
} else {
// No actions needed, show success message
const ordNo = response.ordNo;
if(ordNo){
location.replace("/checkout/complete/" + ordNo + ".html");
}else{
location.href="/errors/orderError.html";
}
}
}
});
oh ..
https://api.hcaptcha.com/authenticate 401 (Unauthorized)
Uncaught (in promise) IntegrationError: Unexpected property: elements2. Put additional API properties in params.
Is this an error related to Google Pay?
Not sure. So that error is on the api.hcaptcha.com?
They are 2 different errors
You would want to fix them one by one
elements2 where do you use this variable?
Seem you haven't mounted it
expreeCheckoutElements = elements2.create('expressCheckout', options2);
Does this code mean mount?
No. You have multiple other mount method
expreeCheckoutElements.mount('#express-checkout-element');
is this??
I guess the button is exposed because there is no problem with the mount?
I think that error occurs in the confirm method.
This mounts the expressCheckoutElements, not elements2
Looks like you created multiple Elements but lost track of them
In this document, elements are not mounted.
you mean elements2.mount( options )
is this code?
expressCheckoutElement.mount('#express-checkout-element');
This, for each of expressCheckoutElement. I can see you have both elements2 and another expreeCheckoutElements from 2 separated line
elements2 = stripe.elements(googleElementOption);
expreeCheckoutElements = stripe.elements({....
So you probably want to mount them to 2 separated divs? For example #element2 and #express-checkout-element?
no
elements2 is Stripe object
you mean
expreeCheckoutElements = expreeCheckoutElements.create('expressCheckout', options2);
expreeCheckoutElements.mount('#express-checkout-element');
this code?
Yep
to be fair this code is also confusing since you are using the same name for 2 objects
checkout.jsx:601 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'create')
it should be something like expreeCheckoutElements = {{some_different_name}}.create('expressCheckout', options2);
I didn't understand what you said.
I think you want to reorganize your code a little
Is there a reason why element2 object should have a different name?
No I didn't say that, I meant expreeCheckoutElements should have a different name with the Elements created it
but that's a different issue with your elements2
I would recommend write into Support and we can spend more time to help. Also attach your full code and a public accessible URL
Since the site has not been opened yet, it seems impossible to provide the URL...
Your code has multiple elements and they are a bit messy. You would want to have only one Payment Element page, working first, then add the additional Element Checkout Element, working
I see you have at least 3 stripe.elements(....
That's 3 different Elements
I think there is a problem with createPaymentMethod.
But you told me to create the payment element and express checkout element separately, right?
element, paymentElement : payment element
element2 , expreeCheckoutElements : express checkout element
This is what drawing on the screen looks like.
What part do you find strange?
From
expreeCheckoutElements = expreeCheckoutElements.create('expressCheckout', options2);
change to
expreeCheckoutElements = elements2.create('expressCheckout', options2);
I tried that too and it's the same
Uncaught (in promise) IntegrationError: Unexpected property: elements2. Put additional API properties in params.
this error occured..
i think submit is not working.
When submitting, the payment method ID should come as a response, but it doesn't seem to be the case.
Why calling createPaymentMethod there? I don't see that step in https://stripe.com/docs/elements/express-checkout-element/accept-a-payment
You can see the steps here.
I followed the instructions here, but why doesn't it work?
I see. Where did the error come from? I see you put there 3 breakpoints
where?
Here
The error comes from the createPaymentMethod line, correct?
At this state I would recommend making it publicly accessible, and then we can open and help you debug from our side