mirror of
				https://github.com/node-ebics/node-ebics-client.git
				synced 2025-11-04 07:00:44 +00:00 
			
		
		
		
	
							
								
								
									
										31
									
								
								examples/bankLetter.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								examples/bankLetter.js
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					#! /usr/bin/env node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const ebics = require('../index');
 | 
				
			||||||
 | 
					const path = require('path');
 | 
				
			||||||
 | 
					const fs = require('fs');
 | 
				
			||||||
 | 
					const os = require('os');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const client = new ebics.Client({
 | 
				
			||||||
 | 
						url: 'https://ebics.server',
 | 
				
			||||||
 | 
						partnerId: '',
 | 
				
			||||||
 | 
						userId: '',
 | 
				
			||||||
 | 
						hostId: '',
 | 
				
			||||||
 | 
						passphrase: 'test', // keys-test will be decrypted with this passphrase
 | 
				
			||||||
 | 
						keyStorage: ebics.fsKeysStorage('./keys-test'),
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const bankName = 'Bank name';
 | 
				
			||||||
 | 
					const template = fs.readFileSync('./templates/ini.hbs').toString();
 | 
				
			||||||
 | 
					const letter = new ebics.BankLetter({ client, bankName, template });
 | 
				
			||||||
 | 
					const bankLetterFile = path.join(os.homedir(), 'bankLetter.html');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					letter.serialize(bankLetterFile)
 | 
				
			||||||
 | 
						.then(() => {
 | 
				
			||||||
 | 
							console.log('Send your bank the letter (%s)', bankLetterFile);
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						.catch((err) => {
 | 
				
			||||||
 | 
							console.error(err);
 | 
				
			||||||
 | 
							process.exit(1);
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
							
								
								
									
										32
									
								
								examples/initialize.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										32
									
								
								examples/initialize.js
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					#! /usr/bin/env node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const ebics = require('../index');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const client = new ebics.Client({
 | 
				
			||||||
 | 
						url: 'https://ebics.server',
 | 
				
			||||||
 | 
						partnerId: 'PARTNER',
 | 
				
			||||||
 | 
						userId: 'USER',
 | 
				
			||||||
 | 
						hostId: 'HOST',
 | 
				
			||||||
 | 
						passphrase: 'test', // keys-test will be encrypted with this passphrase
 | 
				
			||||||
 | 
						keyStorage: ebics.fsKeysStorage('./keys-test'),
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// New keys will be generated and saved in ./keys-test
 | 
				
			||||||
 | 
					client.send(ebics.Orders.INI)
 | 
				
			||||||
 | 
						.then((resp) => {
 | 
				
			||||||
 | 
							console.log('Respose for INI order %j', resp);
 | 
				
			||||||
 | 
							return client.send(ebics.Orders.HIA);
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						.then((resp) => {
 | 
				
			||||||
 | 
							console.log('Reponse for HIA order %j', resp);
 | 
				
			||||||
 | 
							if (resp.technicalCode !== '000000')
 | 
				
			||||||
 | 
								throw new Error('Something might went wrong');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							console.log('Public keys should be sent to bank now. See examples/bankLetter.js');
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						.catch((err) => {
 | 
				
			||||||
 | 
							console.error(err);
 | 
				
			||||||
 | 
							process.exit(1);
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
							
								
								
									
										30
									
								
								examples/save-bank-kesy.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										30
									
								
								examples/save-bank-kesy.js
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					#! /usr/bin/env node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const ebics = require('../index');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const client = new ebics.Client({
 | 
				
			||||||
 | 
						url: 'https://ebics.server',
 | 
				
			||||||
 | 
						partnerId: '',
 | 
				
			||||||
 | 
						userId: '',
 | 
				
			||||||
 | 
						hostId: '',
 | 
				
			||||||
 | 
						passphrase: 'test', // keys-test will be decrypted with this passphrase
 | 
				
			||||||
 | 
						keyStorage: ebics.fsKeysStorage('./keys-test'),
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Client keys must be already generated and send by letter.
 | 
				
			||||||
 | 
					// The bank should have enabled the user
 | 
				
			||||||
 | 
					client.send(ebics.Orders.HPB)
 | 
				
			||||||
 | 
						.then((resp) => {
 | 
				
			||||||
 | 
							console.log('Respose for HPB order %j', resp);
 | 
				
			||||||
 | 
							if (resp.technicalCode !== '000000')
 | 
				
			||||||
 | 
								throw new Error('Something went wrong');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							console.log('Received bank keys: %j', resp.bankKeys);
 | 
				
			||||||
 | 
							return client.setBankKeys(resp.bankKeys);
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						.catch((err) => {
 | 
				
			||||||
 | 
							console.error(err);
 | 
				
			||||||
 | 
							process.exit(1);
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
							
								
								
									
										29
									
								
								examples/send-hbt-order.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										29
									
								
								examples/send-hbt-order.js
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					#! /usr/bin/env node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const ebics = require('../index');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const client = new ebics.Client({
 | 
				
			||||||
 | 
						url: 'https://ebics.server',
 | 
				
			||||||
 | 
						partnerId: '',
 | 
				
			||||||
 | 
						userId: '',
 | 
				
			||||||
 | 
						hostId: '',
 | 
				
			||||||
 | 
						passphrase: 'test', // keys-test will be decrypted with this passphrase
 | 
				
			||||||
 | 
						keyStorage: ebics.fsKeysStorage('./keys-test'),
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// The bank keys must have been already saved
 | 
				
			||||||
 | 
					client.send(ebics.Orders.HTD)
 | 
				
			||||||
 | 
						.then((resp) => {
 | 
				
			||||||
 | 
							console.log('Respose for HTD order %j', resp);
 | 
				
			||||||
 | 
							if (resp.technicalCode !== '000000')
 | 
				
			||||||
 | 
								throw new Error('Something went wrong');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							const data = Buffer.from(resp.orderData);
 | 
				
			||||||
 | 
							console.log(data.toString('utf8'));
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						.catch((err) => {
 | 
				
			||||||
 | 
							console.error(err);
 | 
				
			||||||
 | 
							process.exit(1);
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
		Reference in New Issue
	
	Block a user