Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dropzone.autoDiscover = false;
- document.addEventListener("DOMContentLoaded", function () {
- const myDropzone = new Dropzone("#receiptDropzone", {
- autoProcessQueue: false, // Disable auto-upload
- maxFiles: 1, // Allow only one file to be uploaded
- addRemoveLinks: true,
- renameFile: function(file) {
- var dt = new Date();
- var time = dt.getTime();
- return time + file.name;
- },
- // Other Dropzone options if needed
- init: function () {
- const submitButton = document.querySelector("#checkout");
- const form = this; // "this" refers to the dropzone instance
- submitButton.addEventListener("click", function (event) {
- event.preventDefault();
- event.stopPropagation();
- form.processQueue(); // Process the queue manually
- });
- // Listen for the success event when all files are uploaded
- this.on("success", function (file, response) {
- // Assuming the response contains the notification data
- const notification = response.notification;
- if (notification && notification.message) {
- // Display the notification message using your preferred method
- alert(notification.message);
- }
- // Redirect after successful checkout
- window.location.href = "{{ route('success.checkout') }}"; // Replace with your success page route
- });
- // Listen to the addedfile event to handle file upload and saving
- this.on("addedfile", function (file) {
- // Make sure to remove any previously uploaded file
- if (this.files.length > 1) {
- this.removeFile(this.files[0]);
- }
- });
- },
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement