-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(receipts): show receipt on checkout
Show receipt link from financial manager that is retrieved from ilink. fccn/nau-technical#25
- Loading branch information
Showing
1 changed file
with
15 additions
and
10 deletions.
There are no files selected for viewing
25 changes: 15 additions & 10 deletions
25
nau_extensions/templates/nau_extensions/checkout/receipt_partial.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |