Added sepa-CORE.js; started PAIN implementation.
authorAndreas Schiermeier <andreas@schiermeier.name>
Sun, 12 Jan 2014 16:11:14 +0000 (17:11 +0100)
committerAndreas Schiermeier <andreas@schiermeier.name>
Sun, 12 Jan 2014 16:11:14 +0000 (17:11 +0100)
index.php
js/sepa-CORE.js [new file with mode: 0644]

index 3e64fee..1fbec1d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -134,7 +134,9 @@ try {
         <script type="text/javascript" src="js/crypto-js/pbkdf2/pbkdf2-min.js"></script>
         <script type="text/javascript" src="js/crypto-js/ofb/ofb-min.js"></script>
         <script type="text/javascript" src="js/crypto-js/aes/aes_modified.js"></script>
+        <script type="text/javascript" src="js/utils.js"></script>
         <script type="text/javascript" src="js/dtaus.js"></script>
+        <script type="text/javascript" src="js/sepa-CORE.js"></script>
     </head>
     <body>
     <div id="header"><div class="content"><h1>Mitgliedsverwaltung</h1></div></div>
diff --git a/js/sepa-CORE.js b/js/sepa-CORE.js
new file mode 100644 (file)
index 0000000..ed8374f
--- /dev/null
@@ -0,0 +1,79 @@
+// stolen from https://gist.github.com/panzi/1857360
+
+var XML_CHAR_MAP = {
+  '<': '&lt;',
+  '>': '&gt;',
+  '&': '&amp;',
+  '"': '&quot;',
+  "'": '&apos;'
+};
+function escapeXml (s) {
+  return s.replace(/[<>&"']/g, function (ch) {
+    return XML_CHAR_MAP[ch];
+  });
+}
+
+var SEPACORE = {
+
+  creditorname: null,
+  creditoridentifier: null,
+  creditoriban: null,
+  creditorbic: null,
+  
+  frstcnt: 0,
+  frstsum: 0,
+  
+  rcurcnt: 0,
+  rcursum: 0,
+  
+  collectiondate: new Date(), // null,
+  creationdate: new Date(),
+  
+  errormsg: '',
+  
+  getPaymentInformationHeaderBlock: function() {
+    
+    // Localtime or UTC???
+    collectiondatestr = [ this.collectiondate.getFullYear(),
+                          this.collectiondate.getMonth()+1,
+                          this.collectiondate.getDate()
+                          ].join('-');
+
+    
+    return [
+      '      <PmtInfId>Payment-ID</PmtInfId>',
+      '      <PmtMtd>DD</PmtMtd>',
+      '      <NbOfTxs><!-- TBD --></NbOfTxs>',
+      '      <CtrlSum><!-- TBD --></CtrlSum>',
+      '      <PmtTpInf><SvcLvl><Cd>SEPA</Cd></SvcLvl>',
+      '        <LclInstrm><Cd>CORE</Cd></LclInstrm>',
+      '        <SeqTp><!-- FRST / RCUR --></SeqTp>',
+      '      </PmtTpInf>',
+      '      <ReqdColltnDt>' + collectiondatestr + '</ReqdColltnDt>'
+      ].join('\n');
+  },
+  
+  getCreditorBlock: function() {
+    if (this.creditorbic != null) {
+      bicstr = '<CdtrAgt><FinInstnId><BIC>' + this.creditorbic + '</BIC></FinInstnId></CdtrAgt>';
+    } else {
+      bicstr = '<!-- no BIC for CdtrAgt supplied -->';
+    }
+    return [
+      '      <Cdtr><Nm>' + this.creditorname + '</Nm> </Cdtr>',
+      '      <CdtrAcct><Id><IBAN>' + this.creditoriban + '</IBAN></Id></CdtrAcct>',
+      '      ' + bicstr        ,
+      '      <ChrgBr>SLEV</ChrgBr>',
+      '      <CdtrSchmeId><Id><PrvtId><Othr>',
+      '        <Id>' + this.creditoridentifier + '</Id>',
+      '        <SchmeNm><Prtry>SEPA</Prtry></SchmeNm>',
+      '      </Othr></PrvtId></Id></CdtrSchmeId>'
+      ].join('\n');
+  },
+  
+  
+  
+  
+  
+}
\ No newline at end of file