#sergx_error
1 messages Ā· Page 1 of 1 (latest)
š 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/1246076099419705386
š Have more to share? Add details, code, screenshots, videos, etc. below.
@push('scripts_body')
<script src="{{ asset('js/checkout/subscription.js?v=' . rand(1, 999)) }}"></script>
<script>
const stripe = Stripe("{{ config('app.stripe_key') }}");
const options = {
mode: 'subscription',
amount: 2420,
currency: 'eur',
}
const elements = stripe.elements(options);
const paymentElement = elements.create('payment');
paymentElement.mount('#payment-element');
</script>
<script src="{{ asset('js/checkout/subscription-setup.js?v=' . rand(1, 999)) }}"></script>
@endpush
@push('scripts_head')
<script src="https://js.stripe.com/v3/"></script>
@endpush
I don't know if it could it be because this amount quantity of 24,20ā¬
Hi, let me help you with this.
thank you!
The parameters you use to create the Payment Element and that you send to create a PaymentIntent are different, hence the error.
The thing is that the checkout is really interactive
Why are you setting off_session: "true" when creating the Subscription?
I don't know why is that parameter
async function handleSubscriptionCreation() {
const businessQuantityValue = document.querySelector('[name="business_quantity"]');
const employeesQuantityValue = document.querySelector('[name="employees_quantity"]');
const periodValue = document.querySelector('[name="period"]');
// Call elements submit
const {error: submitError} = await elements.submit();
if (submitError) {
handleError(submitError);
return;
}
updateCustomerBillingDetails();
const subscriptionEndpoint = `/checkout/subscription/create`;
const subscriptionResponse = await fetch(subscriptionEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-CSRF-TOKEN': document.querySelector('[name="_token"]').value
},
body: JSON.stringify({
business_quantity: businessQuantityValue.value,
employees_quantity: employeesQuantityValue.value,
period: periodValue.value,
coupon: coupon
})
});
const { type, clientSecretStripe, succesUrl, error: subError } = await subscriptionResponse.json();
if (subError) {
errorMessage.textContent = subError;
updateButtonLoadingState(false);
return;
}
const confirmIntent = type === "setup" ? stripe.confirmSetup : stripe.confirmPayment;
stopPreventingPageUnload();
// Confirmamos el intento utilizando los datos del formulario
paymentMethodData = {
billing_details: {
name: name.value,
address: { city: city.value, line1: line1.value, postal_code: postalCode.value, state: state.value }
}
}
console.log(paymentMethodData)
const {error} = await confirmIntent({
elements,
clientSecret: clientSecretStripe,
confirmParams: {
payment_method_data: {
billing_details: {
name: name.value,
address: { city: city.value, line1: line1.value, postal_code: postalCode.value, state: state.value }
}
},
return_url: succesUrl,
},
});
if (error) {
console.log(error)
errorMessage.textContent = error.message;
updateButtonLoadingState(false);
}
}
The problem is that the checkout is really interactive, depends on what quantity of business and employees you choose
The amoun that's going to be charged will be different
I set 24,20⬠that was like an estimation
Is it a requirement for you to show the Payment Element before creating the PaymentIntent?
Because you could allow the customer to select the quantity, and only the create the Subscription and show the Payment Element. That would be much easier to implement.
In this case I think it would be possible to show the payment element after the creation of the paymentIntent
But it's weird this was working perfectly last week
You can follow this guide: https://docs.stripe.com/billing/subscriptions/build-subscriptions?ui=elements
Did you change anything?
nope
I've checking and I think
it would be neccesary to collect the payment details before creating an Intent
It might be easier then to use SetupIntents to create the Payment Method for future usage, and then attach it to a Subscription: https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements
it wouldn't be possible to fix this error using the code I pasted? Is that all the implementation was built and tested, was working perfectly don't know what could happen
the wird thing is that the amount is 42,35⬠I don't know why, it should be 24,20ā¬
"error": {
"message": "The provided setup_future_usage (null) does not match the expected setup_future_usage (off_session). Try confirming with a Payment Intent that is configured to use the same parameters as Stripe Elements.",
"param": "setup_future_usage",
"payment_intent": {
"id": "pi_3PEoJgKYINwhn6n411CyrEut",
"object": "payment_intent",
"amount": 4235,
"amount_details": {
"tip": {
}
},
okay the problem I think is that I use the same user and email for testing in Stripe
And each test I do it creates a customer
For some reason is trying to charge an amount of a previous testing, weird
nope it wasn't that š¦
Is that I don't understand the error
Request: req_rRGdtgo7kCeBTx
What's the problem?
Looks like you passed off_session: true when creating the subscription: https://dashboard.stripe.com/test/logs/req_JPe1XyEO31g7JA
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
You shouldn't do that
That looks fine, but that's not what you did with the above one
See the link I shared
looking for it
okay it seems it's a problem of logic implementation to detect if the subscription is being created or it's being updated, fixing it
fixed it, thank you very much!
No problem
the doubt I have
@push('scripts_body')
<script src="{{ asset('js/checkout/subscription.js?v=' . rand(1, 999)) }}"></script>
<script>
const stripe = Stripe("{{ config('app.stripe_key') }}");
const options = {
mode: 'subscription',
amount: 2420,
currency: 'eur',
}
const elements = stripe.elements(options);
const paymentElement = elements.create('payment');
paymentElement.mount('#payment-element');
</script>
<script src="{{ asset('js/checkout/subscription-setup.js?v=' . rand(1, 999)) }}"></script>
@endpush
@push('scripts_head')
<script src="https://js.stripe.com/v3/"></script>
@endpush
it's mandatory that the payment has to be 24,20� Or for example if the payment is 50⬠there's no problem?