Skip to content

Commit

Permalink
feat(receipts): show receipt on checkout
Browse files Browse the repository at this point in the history
Show receipt link from financial manager that is retrieved from ilink.

fccn/nau-technical#25
  • Loading branch information
igobranco committed Jun 14, 2024
1 parent 3ff6e34 commit 44f551f
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
{% load i18n %}

<a id="receiptLink" href="#" style="display: none;">
{% trans "Download receipt" as tmsg %}{{ tmsg | force_escape }}
</a>
<p id="receiptContainer" style="display: none;">
<br/>
<a id="receiptLink" href="#" target="_blank">
{% trans "Download receipt" as tmsg %}{{ tmsg | force_escape }}
</a>
</p>
<script>
function httpGetAsync(theUrl, callback) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}

httpGetAsync('/payment/nau_extensions/receipt-link/?order_id={{ order.id }}', function( data ) {
if (data) {
var receiptLink = document.getElementById("receiptLink");
var link = JSON.parse(data).response;
var receiptContainer = document.getElementById("receiptContainer");

// update the link to element
receiptLink.setAttribute('href', data);
receiptLink.setAttribute('href', link);

// make receipt link visible
receiptLink.style.display = 'block';
receiptContainer.style.display = 'block';

// Declare a fragment:
var fragment = document.createDocumentFragment();

// Append desired element to the fragment:
fragment.appendChild(receiptLink);
fragment.appendChild(receiptContainer);

// Append fragment to desired element:
document.getElementsByClassName('confirm-message')[0].appendChild(fragment);
}
});
</script>
</script>

0 comments on commit 44f551f

Please sign in to comment.