mangopay4-nodejs-sdk 1.68.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +0 -6
  3. package/docs/templates/class.mustache +0 -0
  4. package/docs/templates/file.mustache +0 -0
  5. package/docs/templates/function.mustache +0 -0
  6. package/docs/templates/index.mustache +0 -0
  7. package/docs/templates/overview.mustache +0 -0
  8. package/lib/models/CardPreAuthorization.js +2 -2
  9. package/package.json +16 -24
  10. package/.github/workflows/node.js.yml +0 -32
  11. package/.github/workflows/npm-publish.yml +0 -26
  12. package/.jshintrc +0 -16
  13. package/test/TestKycPageFile.png +0 -0
  14. package/test/helpers.js +0 -1537
  15. package/test/main.js +0 -10
  16. package/test/mocha.opts +0 -3
  17. package/test/services/Acquiring.js +0 -338
  18. package/test/services/BankAccounts.js +0 -46
  19. package/test/services/BankingAliases.js +0 -89
  20. package/test/services/CardPreAuthorizations.js +0 -70
  21. package/test/services/CardRegistrations.js +0 -239
  22. package/test/services/Cards.js +0 -56
  23. package/test/services/Clients.js +0 -235
  24. package/test/services/Conversions.js +0 -319
  25. package/test/services/Deposits.js +0 -148
  26. package/test/services/Disputes.js +0 -542
  27. package/test/services/EMoney.js +0 -54
  28. package/test/services/Events.js +0 -147
  29. package/test/services/Hooks.js +0 -109
  30. package/test/services/Idempotency.js +0 -41
  31. package/test/services/IdentityVerifications.js +0 -68
  32. package/test/services/KycDocuments.js +0 -73
  33. package/test/services/Mandates.js +0 -256
  34. package/test/services/PayIns.js +0 -2632
  35. package/test/services/PayOuts.js +0 -119
  36. package/test/services/RateLimit.js +0 -43
  37. package/test/services/Recipients.js +0 -234
  38. package/test/services/Refunds.js +0 -123
  39. package/test/services/Regulatory.js +0 -45
  40. package/test/services/Reports.js +0 -114
  41. package/test/services/ReportsV2.js +0 -306
  42. package/test/services/Repudiations.js +0 -22
  43. package/test/services/Settlements.js +0 -127
  44. package/test/services/Tokens.js +0 -55
  45. package/test/services/Transfers.js +0 -137
  46. package/test/services/UboDeclarations.js +0 -130
  47. package/test/services/Users.js +0 -1322
  48. package/test/services/VirtualAccounts.js +0 -105
  49. package/test/services/Wallets.js +0 -132
  50. package/test/settlement_sample.csv +0 -8
  51. package/test/settlement_sample_bad.csv +0 -8
@@ -1,239 +0,0 @@
1
- var _ = require('underscore');
2
- var expect = require('chai').expect;
3
- var helpers = require('../helpers');
4
- var api = require('../main');
5
-
6
- describe('Card Registrations', function () {
7
- var cardRegistration;
8
- var john = helpers.data.getUserNatural();
9
-
10
- before(function(done){
11
- api.Users.create(john, function(){
12
- done();
13
- });
14
- });
15
-
16
- describe('Create', function () {
17
- before(function (done) {
18
- cardRegistration = {
19
- UserId: john.Id,
20
- Currency: 'EUR'
21
- };
22
- api.CardRegistrations.create(cardRegistration, function(data, response){
23
- done();
24
- });
25
- });
26
-
27
- it('should be created', function () {
28
- expect(cardRegistration.Id).not.to.be.undefined;
29
- expect(cardRegistration.AccessKey).not.to.be.undefined;
30
- expect(cardRegistration.PreregistrationData).not.to.be.undefined;
31
- expect(cardRegistration.CardRegistrationURL).not.to.be.undefined;
32
- expect(cardRegistration.Status).to.equal('CREATED');
33
- expect(cardRegistration.Currency).to.equal('EUR');
34
- expect(cardRegistration.UserId).to.equal(john.Id);
35
- });
36
- });
37
-
38
- describe('Get', function () {
39
- var cardRegistrationGet;
40
-
41
- before(function (done) {
42
- api.CardRegistrations.get(cardRegistration.Id, function(data, response){
43
- cardRegistrationGet = data;
44
- done();
45
- });
46
- });
47
-
48
- it('should be retrieved', function () {
49
- expect(cardRegistrationGet.Id).to.equal(cardRegistration.Id);
50
- expect(cardRegistrationGet.PreregistrationData).to.equal(cardRegistration.PreregistrationData);
51
- });
52
- });
53
-
54
- describe('Update', function () {
55
- var updatedCardRegistration, newRegistrationData;
56
-
57
- before(function (done) {
58
- var options = {
59
- data: {
60
- data: cardRegistration.PreregistrationData,
61
- accessKeyRef: cardRegistration.AccessKey,
62
- cardNumber: '4970107111111119',
63
- cardExpirationDate: '1229',
64
- cardCvx: '123'
65
- },
66
- url: cardRegistration.CardRegistrationURL,
67
- headers: {
68
- 'Content-Type': 'application/x-www-form-urlencoded'
69
- }
70
- };
71
-
72
- api.method('post', function (data, response) {
73
- cardRegistration.RegistrationData = Buffer.from(data).toString();
74
- newRegistrationData = cardRegistration.RegistrationData;
75
- api.CardRegistrations.update(cardRegistration).then(function(data){
76
- updatedCardRegistration = data;
77
- done();
78
- });
79
- }, options);
80
- });
81
-
82
- it('should be updated', function () {
83
- console.log(JSON.stringify(updatedCardRegistration));
84
- expect(updatedCardRegistration.RegistrationData).to.equal(newRegistrationData);
85
- expect(updatedCardRegistration.Status).to.equal('VALIDATED');
86
- expect(updatedCardRegistration.ResultCode).to.equal('000000');
87
- expect(updatedCardRegistration.CardId).to.not.be.undefined;
88
- });
89
- });
90
-
91
- describe('Update Error', function () {
92
- var newCardRegistration;
93
- before(function (done) {
94
- newCardRegistration = {
95
- UserId: john.Id,
96
- Currency: 'EUR'
97
- };
98
-
99
- api.CardRegistrations.create(newCardRegistration, function(data, response){
100
- newCardRegistration.RegistrationData = 'Wrong-data';
101
- api.CardRegistrations.update(newCardRegistration, function(data, response){
102
- done();
103
- });
104
- });
105
- });
106
-
107
- it('should fail', function () {
108
- expect(newCardRegistration.ResultCode).not.to.be.undefined;
109
- expect(newCardRegistration.ResultMessage).not.to.be.undefined;
110
- expect(newCardRegistration.Status).to.equal('ERROR');
111
- });
112
- });
113
-
114
- describe('Cards', function () {
115
- var card;
116
- var validatedCard;
117
- var fetchedCardValidation;
118
- before(function(done) {
119
- api.Cards.get(cardRegistration.CardId, function(data, response){
120
- card = data;
121
- done();
122
- });
123
- });
124
-
125
- describe('Validate Card', function () {
126
- before(function(done) {
127
- var cardValidation = {
128
- AuthorId: cardRegistration.UserId,
129
- SecureModeReturnURL: "http://example.com",
130
- IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
131
- BrowserInfo: {
132
- AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
133
- ColorDepth: 4,
134
- JavaEnabled: true,
135
- JavascriptEnabled: true,
136
- Language: 'FR-FR',
137
- ScreenHeight: 1800,
138
- ScreenWidth: 400,
139
- TimeZoneOffset: "+60",
140
- UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
141
- }
142
- };
143
-
144
- api.Cards.validate(cardRegistration.CardId, cardValidation, function (data) {
145
- validatedCard = data;
146
- done();
147
- });
148
- });
149
-
150
- it('should be validated', function () {
151
- expect(validatedCard).to.not.be.undefined;
152
- expect(validatedCard.Id).to.not.be.undefined;
153
- expect(validatedCard.Type).to.equal("CARD_VALIDATION");
154
- });
155
- });
156
-
157
- describe('Get Card Validation', function () {
158
- before(function(done) {
159
- api.Cards.getCardValidation(cardRegistration.CardId, validatedCard.Id, function(data) {
160
- fetchedCardValidation = data;
161
- done();
162
- });
163
- });
164
-
165
- it('should fetch card validation', function () {
166
- expect(fetchedCardValidation).to.not.be.undefined;
167
- expect(fetchedCardValidation.Id).to.not.be.undefined;
168
- expect(fetchedCardValidation.Id).to.equal(validatedCard.Id);
169
- expect(fetchedCardValidation.Type).to.equal("CARD_VALIDATION");
170
- });
171
- });
172
-
173
- describe('Check Card Existing', function () {
174
- it('should be retrieved', function () {
175
- expect(card.Id).to.not.be.undefined;
176
- expect(card.Validity).to.equal('UNKNOWN');
177
- });
178
- });
179
-
180
- describe('Get By Fingerprint', function() {
181
- var cards;
182
-
183
- before(function (done) {
184
- api.Cards.getByFingerprint(card.Fingerprint, function(data, response) {
185
- cards = data;
186
- done();
187
- });
188
- });
189
-
190
- it('should retrieve list', function () {
191
- expect(cards).to.be.an('array');
192
- cards.forEach(function (cardByFingerprint) {
193
- expect(cardByFingerprint.Fingerprint).to.equal(card.Fingerprint);
194
- });
195
- });
196
- });
197
-
198
- // test card deactivated
199
- //describe('Update', function () {
200
- // var updatedCard;
201
-
202
- // before(function(done) {
203
- // updatedCard = {
204
- // Id: card.Id,
205
- // Validity: 'INVALID'
206
- // };
207
- // api.Cards.update(updatedCard, function(data, response){
208
- // updatedCard = data;
209
- // done();
210
- // });
211
- // });
212
-
213
- // it('should be updated', function () {
214
- // expect(updatedCard.Id).to.equal(card.Id);
215
- // expect(updatedCard.Active).to.be.false;
216
- // });
217
- //});
218
- });
219
-
220
- describe('Creating Invalid user card registration', function () {
221
- var newInvalidCardRegistration = {
222
- UserId: '12345678',
223
- Currency: 'EUR',
224
- CardType: 'CB_VISA_MASTERCARD'
225
- };
226
- var failedResponse;
227
-
228
- before(function(done) {
229
- api.CardRegistrations.create(newInvalidCardRegistration, function (data) {
230
- failedResponse = data;
231
- done();
232
- });
233
- });
234
-
235
- it('should fail', function () {
236
- expect(failedResponse.Type).to.equal('ressource_not_found');
237
- });
238
- });
239
- });
@@ -1,56 +0,0 @@
1
- var _ = require('underscore');
2
- var expect = require('chai').expect;
3
- var helpers = require('../helpers');
4
- var UserNatural = require('../../lib/models/UserNatural');
5
- var api = require('../main');
6
-
7
- describe('Cards', function () {
8
- var john = new UserNatural(helpers.data.getUserNatural());
9
- var cardId;
10
-
11
- before(function (done) {
12
- api.Users.create(john).then(function (data, response) {
13
- john = data;
14
- done();
15
- });
16
- });
17
-
18
- describe('Get PreAuthorizations', function () {
19
- var getPreAuthorizations;
20
-
21
- before(function (done) {
22
- helpers.getNewPayInCardDirect(api, john, async function (data) {
23
- cardId = data.CardId;
24
- const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
25
- await delay(5000);
26
- api.Cards.getPreAuthorizations(cardId, function (data, response) {
27
- getPreAuthorizations = data;
28
- done();
29
- });
30
- });
31
- });
32
-
33
- it('should be retrieved', function () {
34
- expect(getPreAuthorizations).not.to.be.undefined;
35
- expect(getPreAuthorizations).to.be.an('array');
36
- });
37
- });
38
-
39
- describe('Get Transactions for Card fingerprint', function(){
40
- var getTransactions;
41
-
42
- before(function(done){
43
- api.Cards.get(cardId, function(data, response){
44
- api.Cards.getTransactionsForFingerprint(data.Fingerprint, function(data, response){
45
- getTransactions = data;
46
- done();
47
- });
48
- });
49
- });
50
-
51
- it('should be retrieved', function(){
52
- expect(getTransactions).not.to.be.undefined;
53
- expect(getTransactions).to.be.an('array');
54
- });
55
- });
56
- });
@@ -1,235 +0,0 @@
1
- var _ = require('underscore');
2
- var path = require('path');
3
- var expect = require('chai').expect;
4
- var api = require('../main');
5
-
6
- var ClientWallet = require('../../lib/models/ClientWallet');
7
- var BankAccount = require('../../lib/models/BankAccount');
8
- var BankAccountDetailsIBAN = require('../../lib/models/BankAccountDetailsIBAN');
9
- var PayOut = require('../../lib/models/PayOut');
10
- var PayOutPaymentDetailsBankWire = require('../../lib/models/PayOutPaymentDetailsBankWire');
11
-
12
- describe("Clients", function () {
13
- var client;
14
- var createdBankAccount;
15
-
16
- before(function (done) {
17
- api.Clients.get().then(function (data) {
18
- client = data;
19
- done();
20
- });
21
- });
22
-
23
- it('Get Client', function () {
24
- expect(client.ClientId).not.to.be.undefined;
25
- expect(client.ClientId).to.equal(api.config.clientId);
26
- expect(client.Licensor).not.to.be.undefined;
27
- });
28
-
29
- describe("Update client", function () {
30
- var updatedClient;
31
- var themeColor = '#123456';
32
- var buttonColor = '#654321';
33
- var phoneNumber = Math.floor(Math.random() * 100000).toString();
34
-
35
- before(function (done) {
36
- api.Clients.update({
37
- PrimaryThemeColour: themeColor,
38
- PrimaryButtonColour: buttonColor,
39
- HeadquartersPhoneNumber: phoneNumber
40
- })
41
- .then(function (data) {
42
- updatedClient = data;
43
- done();
44
- });
45
- });
46
-
47
- it("should have updated colors", function () {
48
- expect(updatedClient.ClientId).not.to.be.undefined;
49
- expect(updatedClient.PrimaryThemeColour).to.equal(themeColor);
50
- expect(updatedClient.PrimaryButtonColour).to.equal(buttonColor);
51
- });
52
-
53
- it('should have update headquarters phone number', function () {
54
- expect(updatedClient.HeadquartersPhoneNumber).to.equal(phoneNumber);
55
- });
56
-
57
- });
58
-
59
- describe.skip("Upload Logo", function () {
60
- var filePath = path.resolve(__dirname, '../TestKycPageFile.png');
61
- var requestResponse;
62
- before(function (done) {
63
- api.Clients.uploadLogoFromFile(filePath, function (data, response) {
64
- requestResponse = response;
65
- done();
66
- });
67
- });
68
-
69
- it('should be uploaded', function () {
70
- expect(requestResponse.status).to.equal(204);
71
- });
72
-
73
- });
74
-
75
- describe("Get client wallets by funds type", function () {
76
- var feesWallets;
77
- var creditWallets;
78
- before(function (done) {
79
- api.Clients.getClientWalletsByFundsType('FEES', function (data, response) {
80
- feesWallets = data;
81
- api.Clients.getClientWalletsByFundsType('CREDIT', function (data, response) {
82
- creditWallets = data;
83
- done();
84
- });
85
- });
86
- });
87
-
88
- it('should have wallets', function () {
89
- expect(feesWallets).not.to.be.undefined;
90
- expect(creditWallets).not.to.be.undefined;
91
- })
92
- });
93
-
94
- describe("Get client wallet", function () {
95
- var clientWallets;
96
- var clientWallet;
97
- before(function (done) {
98
- api.Clients.getClientWallets(function (data, response) {
99
- clientWallets = data;
100
- api.Clients.getClientWallet(clientWallets[0].FundsType, clientWallets[0].Currency
101
- , function (data, response) {
102
- clientWallet = data;
103
- done();
104
- });
105
- });
106
- });
107
-
108
- it('should get the same client wallet', function () {
109
- expect(clientWallet).not.to.be.undefined;
110
- expect(clientWallet.FundsType).to.equal(clientWallets[0].FundsType);
111
- expect(clientWallet.Currency).to.equal(clientWallets[0].Currency);
112
- });
113
- });
114
-
115
- describe("Get client wallet's transactions", function () {
116
- var clientWallets;
117
- var transactions;
118
- before(function (done) {
119
- api.Clients.getClientWallets(function (data, response) {
120
- clientWallets = data;
121
- api.Clients.getClientWalletTransactions(clientWallets[0].FundsType, clientWallets[0].Currency
122
- , function (data, response) {
123
- transactions = data;
124
- done();
125
- });
126
- });
127
- });
128
-
129
- it('should get transactions', function () {
130
- expect(transactions).not.to.be.undefined;
131
- expect(transactions.length).to.be.greaterThan(0);
132
- })
133
-
134
- });
135
-
136
- describe("Create BankAccountIBAN", function () {
137
- var account = new BankAccount({
138
- OwnerName: "Joe Blogs",
139
- OwnerAddress: {
140
- "AddressLine1": "1 Mangopay Street",
141
- "AddressLine2": "The Loop",
142
- "City": "Paris",
143
- "Region": "Ile de France",
144
- "PostalCode": "75001",
145
- "Country": "FR"
146
- },
147
- Details: new BankAccountDetailsIBAN({
148
- IBAN: "FR7630004000031234567890143",
149
- BIC: "BNPAFRPP"
150
- }),
151
- Tag: "custom meta"
152
- });
153
-
154
- before(function (done) {
155
- api.Clients.createBankAccountIBAN(account).then(function (data) {
156
- createdBankAccount = data;
157
- done();
158
- });
159
- });
160
-
161
- it('should get the bank account', function () {
162
- expect(createdBankAccount).not.to.be.undefined;
163
- expect(createdBankAccount.Id).not.to.be.undefined;
164
- });
165
- });
166
-
167
- describe("Create PayOut", function () {
168
- var createdPayOut;
169
- var clientWallets;
170
- var clientWallet;
171
-
172
- before(function (done) {
173
- api.Clients.getClientWallets(function (data, response) {
174
- clientWallets = data;
175
- api.Clients.getClientWallet(clientWallets[0].FundsType, clientWallets[0].Currency
176
- , function (data, response) {
177
- clientWallet = data;
178
-
179
- var payOut = new PayOut({
180
- DebitedWalletId: clientWallet.Id,
181
- PaymentType: 'BANK_WIRE',
182
- MeanOfPaymentDetails: new PayOutPaymentDetailsBankWire({
183
- BankAccountId: createdBankAccount.Id,
184
- BankWireRef: 'invoice 7282',
185
- PayoutModeRequested: 'STANDARD'
186
- }),
187
- DebitedFunds: {
188
- "Currency": "EUR",
189
- "Amount": 12
190
- },
191
- Tag: 'bla'
192
- });
193
-
194
- api.Clients.createPayOut(payOut).then(function (data) {
195
- createdPayOut = data;
196
- done();
197
- });
198
- });
199
- });
200
- });
201
-
202
- it('should create the payout', function () {
203
- console.log(createdPayOut);
204
- expect(createdPayOut).not.to.be.undefined;
205
- expect(createdPayOut.Id).not.to.be.undefined;
206
- });
207
- });
208
-
209
- describe("Create PayIn BankWire Direct", function () {
210
- var created;
211
-
212
- before(function (done) {
213
- const dto = {
214
- "CreditedWalletId": "CREDIT_EUR",
215
- "DeclaredDebitedFunds": {
216
- "Currency": "EUR",
217
- "Amount": 1000
218
- }
219
- };
220
- api.Clients.createBankWireDirectPayIn(dto, function(data) {
221
- created = data;
222
- done();
223
- });
224
- });
225
-
226
- it('should create the payin', function () {
227
- expect(created).not.to.be.undefined;
228
- expect(created.Id).not.to.be.undefined;
229
- expect(created.Type).to.eq('PAYIN');
230
- expect(created.Status).to.eq('CREATED');
231
- expect(created.PaymentType).to.eq('BANK_WIRE');
232
- expect(created.ExecutionType).to.eq('DIRECT');
233
- });
234
- });
235
- });