#meesterdjango_api
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.
- meesterdjango_api, 1 hour ago, 18 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/1260293832755511408
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
log stripe dashboard :
What are you using to accept a Payment Method?
Payment Element? Checkout?
i use a checkout page for that im pretty sure
No, that looks like the Card Element, which is deprecated, but should still function if setup properly. Any reason you're using that over the Payment Element?
flow is as follows : shopping cart -> checkout_page -> 'payment_method'_setup.html -> checkout_success_page or checkout_failed_page depending on answer
to be fair im working on a project that i didnt build. The person who build it used alot of old apis and packages but the webshop is accually pretty huge so they wanted to add some payment methods
im simply working with what i have got
so i can use payment element rather then card-element? this should fix the issue u think ?
never ever have i worked with stripe so hence the unfamiliarity with its way of working
So, if you want to take new Payment Method types other than cards, you'll need to use the Payment Element. The Payment Element replaces the Card Element (which you're already using).
You can look at the comparison here: https://docs.stripe.com/payments/payment-card-element-comparison
There will be a lot of refactoring in your code, but at the end of it, you'll have something that can accept other payment methods and which is a bit more future-proof
doesnt seem a valid option for me to be honest. It doesnt fit in the way the checkout flows. I will have to do alot more than just refactoring. The way my intents are being created after the form is submitted makes it almost impossible to even start with integrating the payment element since i need a client_secret. im still not getting my head around the fact that even the card-element doesnt work at all
You don't have to have a client-secret if you use the deferred intent workflow that we document here: https://docs.stripe.com/payments/accept-a-payment-deferred
Not sure if that helps at all, but figured I'd mention it
because for payment element i need to update the submit handler so that it works totally different but i handle all of this on the backend view for the checkout page and a seperate .py file to create the intents when the form is submitted
and in documentation its client sided ?
Hi there
Taking over here as two-shoes needs to step away
What sort of PaymentMethods are you trying to integrate?
i will send you a screen shot wait
at the screen shot u see i integrated the different methods in radio buttons. this is all backend nothing client side
this is my checkout_page.html (django/template)
this is an example of a bancontact_setup.html wich processes the payment and redirects a user to the payment page of bacontact.
so i never created this payment flow to begin with and to just change it completely kinda scares me alot because this is a live webshop
So what two-shoes recommended above is that you use PaymentElement which allows you to support as many as payment methods possible.
The other option you have is to integrate each PaymentMethod separately by following Direct API integration flow, for example:
Bancontact - https://docs.stripe.com/payments/bancontact/accept-a-payment?web-or-mobile=web&payments-ui-type=direct-api
iDEAL - https://docs.stripe.com/payments/ideal/accept-a-payment?web-or-mobile=web&payments-ui-type=elements
For both bancontact and ideal the integration works as it is
its just for card that im having trouble
Are you trying to integrate Card Element or is this an existing integration that used CardElement?
so to clarify i have two working methods : bancontact and ideal wich both redirect and complete payments correctly on there bancontact_setup.html and ideal_setup.html
this is what i added to it yes
i just followed a old guide i guess
Gotcha. Do you have a link to the guide you followed?
We generally recommend using the latest elements for security as well as scalability reasons.
configuration wise and server sided everything should be correct the main issue im facing is : completing the card payment and redirecting the user to the payment page on the card_setup.html
and yeah i do understand that and i am of the same believe. However the person who owns the webshop isnt really that mindfull about all the trouble older integrations bring with them.
money money money
thats all they can see
they never intented to go international
but all of a sudden they just did
and now they are pushing me to add these payment methods in the existing code
almost impossible tbh
here is the link i followed : https://docs.stripe.com/payments/payment-methods/integration-options
What happens if you change confirmPayment to confirmCardPayment and call something like
payment_method: {
card: elements.getElement(CardElement)
}
});```
im confused where should i call the await ? in the card_setup.html or checkout?
It should be in your JS code...
yeah but even that is not the way the previous person worked. They added inline scripts in different pages ...
im losing more hair the more im understanding that the last person just freestyled a little and im stuck with this mess
<script>
var stripe = Stripe('{{ stripe_public_key }}');
// Redirects to Bancontact website or app
stripe.confirmBancontactPayment(
'{{ payment_intent }}',
{
payment_method: {
billing_details: {
name: "{{ name }}"
}
},
return_url: '{{ root_url }}/shop/checkout/processing/?order={{ order.id }}',
}
).then(function(result) {
if (result.error) {
}
});
</script>
thats the js for bancontact_setup
so you have an idea on how i confirm it
because i just think you dont get how the code is build
<script>
document.addEventListener("DOMContentLoaded", function() {
var stripe = window.stripeInstance;
var elements = window.elementsInstance;
stripe.confirmPayment({
elements: elements,
clientSecret: "{{ payment_intent }}",
confirmParams: {
return_url: '{{ root_url }}/shop/checkout/processing/?order={{ order.id }}',
},
}).then(function(result) {
if (result.error) {
console.error("Error code:", result.error.code);
console.error("Error message:", result.error.message);
console.error("Error type:", result.error.type);
console.error("Error payment_intent:", result.error.payment_intent);
alert(result.error.message); // Display the error to the user
}
});
});
</script>
this is js for card_setup
and this is wrong
i dont seem to find a working way for : confirmCardPayment()
If i would change it to for example this : <script>
document.addEventListener("DOMContentLoaded", function() {
var stripe = Stripe('{{ stripe_public_key }}');
var elements = window.elementsInstance;
stripe.confirmCardPayment("{{ payment_intent }}",
{
payment_method: {
billing_details: {
name: "{{ name }}"
}
},
return_url: '{{ root_url }}/shop/checkout/processing/?order={{ order.id }}',
}
).then(function(result) {
if (result.error) {
console.error("Error code:", result.error.code);
console.error("Error message:", result.error.message);
console.error("Error type:", result.error.type);
console.error("Error payment_intent:", result.error.payment_intent);
alert(result.error.message); // Display the error to the user
}
});
});
</script>
then i get an error that looks like this : Uncaught IntegrationError: Missing value for confirmCardPayment: payment_method.card should be an object or element.
but then comes the main issue i cannot pass the card-element instance to the setup page. Objet keeps coming up as empty or null
that's where you'd set following inside confirmCardPayment
payment_method: {
card: elements.getElement(CardElement)
}
elements.getElement(CardElement) = null
Ah that's because CardElement in that example is a variable..
Try printing: https://docs.stripe.com/js/elements_object/get_element
elements.getElement('card');
like i said i dont think u get the way the good is setup. Ill just wait for stripe support to finish there code review because im losing it slowly ... Thanks for the help !
Your code sets var elements = window.elementsInstance;
So running above line should get you the card element instance on the page unless every reference to it keeps getting destoryed..
its not youre traditional code
its django
wich is python
front and backend
with html templates
yeah still it gives me null
var elemets = window.elementsInstance = null on the setup page
eventhough i set it globally on the checkout
thats why it makes no sense to me
im trying to access this simple object and its just gone
and i cannot declare variables globally in html templates
so i have to make them in the backend
and pass them to the template
wich is not possible for the card-element
and it bugs me because for ideal i have for example this js : <script>
var stripe = Stripe('{{ stripe_public_key }}');
// Redirects to iDEAL website or app
stripe.confirmIdealPayment(
'{{ payment_intent }}',
{
payment_method: {
ideal: {},
billing_details: {
name: "{{ name }}"
}
},
return_url: '{{ root_url }}/shop/checkout/processing/?order={{ order.id }}',
}
).then(function(result) {
if (result.error) {
console.error(result.error.message);
// Handle error here
}
});
</script>
and that does work and redirect me to ideal payment page etc
Because iDEAL doesn't really add any elements to the page.. It just redirects to third-party page where payment information is provided. Card Element is injected on the same page
jup exactly
thats why i have an issue with confirming card payments
because i have no access to the card elements
Let me see if anyone on my team is familiar with persisting elements object over embedded html
i understand how stripe works and what every different methods expects but this small thing keeps preventing me from accepting the card payments.
and its just bcs its django with html templating
if it was for example
dajngo backend
and react frontend
i would have no issue
but its a pretty old school vanilla django webshop fully build in python / html and plain js
but its build this way because the webshop itself is build modulair so i can create multiple webshops with specific frontend and backend configurations
through wagtail
wich is a cms
thats why i cannot just start changing a huge part of the way the webshop works
this affects like 100+ webshops
because they are build modulair so this gives me less space to do special adjustmants or adaptations
I've asked a teammate to take a look, we will respond as soon as we have something