mangopay4-nodejs-sdk 1.67.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.
- package/CHANGELOG.md +39 -0
- package/README.md +0 -6
- package/docs/templates/class.mustache +0 -0
- package/docs/templates/file.mustache +0 -0
- package/docs/templates/function.mustache +0 -0
- package/docs/templates/index.mustache +0 -0
- package/docs/templates/overview.mustache +0 -0
- package/lib/apiMethods.js +10 -3
- package/lib/models/CardPreAuthorization.js +2 -2
- package/lib/models/PayInPaymentType.js +0 -1
- package/lib/models/ReportFilterV2.js +2 -1
- package/lib/services/Acquiring.js +152 -0
- package/lib/services/PayIns.js +0 -18
- package/lib/services/index.js +2 -1
- package/package.json +16 -24
- package/typings/enums.d.ts +0 -1
- package/typings/index.d.ts +5 -5
- package/typings/index.test-d.ts +0 -15
- package/typings/models/acquiring.d.ts +763 -0
- package/typings/models/payIn.d.ts +20 -80
- package/typings/models/refund.d.ts +1 -0
- package/typings/models/reportV2.d.ts +2 -0
- package/typings/services/Acquiring.d.ts +44 -0
- package/typings/services/PayIns.d.ts +0 -8
- package/typings/types.d.ts +0 -2
- package/.github/workflows/node.js.yml +0 -32
- package/.github/workflows/npm-publish.yml +0 -26
- package/.jshintrc +0 -16
- package/lib/models/PayInPaymentDetailsPayconiq.js +0 -23
- package/test/TestKycPageFile.png +0 -0
- package/test/helpers.js +0 -1536
- package/test/main.js +0 -10
- package/test/mocha.opts +0 -3
- package/test/services/BankAccounts.js +0 -46
- package/test/services/BankingAliases.js +0 -89
- package/test/services/CardPreAuthorizations.js +0 -70
- package/test/services/CardRegistrations.js +0 -239
- package/test/services/Cards.js +0 -56
- package/test/services/Clients.js +0 -235
- package/test/services/Conversions.js +0 -319
- package/test/services/Deposits.js +0 -148
- package/test/services/Disputes.js +0 -542
- package/test/services/EMoney.js +0 -54
- package/test/services/Events.js +0 -147
- package/test/services/Hooks.js +0 -109
- package/test/services/Idempotency.js +0 -41
- package/test/services/IdentityVerifications.js +0 -68
- package/test/services/KycDocuments.js +0 -73
- package/test/services/Mandates.js +0 -256
- package/test/services/PayIns.js +0 -2748
- package/test/services/PayOuts.js +0 -119
- package/test/services/RateLimit.js +0 -43
- package/test/services/Recipients.js +0 -234
- package/test/services/Refunds.js +0 -123
- package/test/services/Regulatory.js +0 -45
- package/test/services/Reports.js +0 -114
- package/test/services/ReportsV2.js +0 -306
- package/test/services/Repudiations.js +0 -22
- package/test/services/Settlements.js +0 -127
- package/test/services/Tokens.js +0 -55
- package/test/services/Transfers.js +0 -137
- package/test/services/UboDeclarations.js +0 -130
- package/test/services/Users.js +0 -1322
- package/test/services/VirtualAccounts.js +0 -105
- package/test/services/Wallets.js +0 -132
- package/test/settlement_sample.csv +0 -8
- package/test/settlement_sample_bad.csv +0 -8
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
var expect = require('chai').expect;
|
|
2
|
-
var helpers = require('../helpers');
|
|
3
|
-
var api = require('../main');
|
|
4
|
-
|
|
5
|
-
describe('Reports V2 (2025)', function () {
|
|
6
|
-
var report;
|
|
7
|
-
|
|
8
|
-
before(function (done) {
|
|
9
|
-
var reportPost = {
|
|
10
|
-
DownloadFormat: "CSV",
|
|
11
|
-
ReportType: "COLLECTED_FEES",
|
|
12
|
-
AfterDate: 1740787200,
|
|
13
|
-
BeforeDate: 1743544740
|
|
14
|
-
};
|
|
15
|
-
api.ReportsV2.create(reportPost).then(function (data) {
|
|
16
|
-
report = data;
|
|
17
|
-
done();
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should exist after creating it', function () {
|
|
22
|
-
expect(report.Id).to.exist;
|
|
23
|
-
expect(report.ReportType).to.equal("COLLECTED_FEES");
|
|
24
|
-
expect(report.DownloadFormat).to.equal("CSV");
|
|
25
|
-
expect(report.Status).to.equal("PENDING");
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe('Create for user wallet transactions', function () {
|
|
29
|
-
var userWalletTransactionReport;
|
|
30
|
-
|
|
31
|
-
before(function (done) {
|
|
32
|
-
var reportPost = {
|
|
33
|
-
DownloadFormat: "CSV",
|
|
34
|
-
ReportType: "USER_WALLET_TRANSACTIONS",
|
|
35
|
-
AfterDate: 1740787200,
|
|
36
|
-
BeforeDate: 1743544740
|
|
37
|
-
};
|
|
38
|
-
api.ReportsV2.create(reportPost).then(function (data) {
|
|
39
|
-
userWalletTransactionReport = data;
|
|
40
|
-
done();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should be correctly fetched', function () {
|
|
45
|
-
expect(userWalletTransactionReport.Id).to.exist;
|
|
46
|
-
expect(userWalletTransactionReport.ReportType).to.equal("USER_WALLET_TRANSACTIONS");
|
|
47
|
-
expect(userWalletTransactionReport.DownloadFormat).to.equal("CSV");
|
|
48
|
-
expect(userWalletTransactionReport.Status).to.equal("PENDING");
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('Getting created report', function () {
|
|
53
|
-
var getReport;
|
|
54
|
-
|
|
55
|
-
before(function (done) {
|
|
56
|
-
api.ReportsV2.get(report.Id).then(function (data) {
|
|
57
|
-
getReport = data;
|
|
58
|
-
done();
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('should be correctly fetched', function () {
|
|
63
|
-
expect(report.Id).to.equal(getReport.Id);
|
|
64
|
-
expect(report.CreationDate).to.equal(getReport.CreationDate);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('Getting all reports', function () {
|
|
69
|
-
var allReports;
|
|
70
|
-
|
|
71
|
-
before(function (done) {
|
|
72
|
-
api.ReportsV2.getAll().then(function (data) {
|
|
73
|
-
allReports = data;
|
|
74
|
-
done();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('should be correctly fetched', function () {
|
|
79
|
-
expect(allReports).to.be.an('array');
|
|
80
|
-
expect(allReports.length).to.be.above(0);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
describe('Create intent report', function () {
|
|
85
|
-
var report;
|
|
86
|
-
|
|
87
|
-
before(function (done) {
|
|
88
|
-
var reportPost = {
|
|
89
|
-
"DownloadFormat" : "CSV",
|
|
90
|
-
"ReportType" : "ECHO_INTENT",
|
|
91
|
-
"AfterDate" : 1748782023,
|
|
92
|
-
"BeforeDate" : 1753102013,
|
|
93
|
-
"Filters" : {
|
|
94
|
-
"PaymentMethod" : "PAYPAL",
|
|
95
|
-
"Status" : "CAPTURED",
|
|
96
|
-
"Type" : "PAYIN"
|
|
97
|
-
},
|
|
98
|
-
"Columns" : [
|
|
99
|
-
"Id",
|
|
100
|
-
"Status",
|
|
101
|
-
"Amount",
|
|
102
|
-
"Currency",
|
|
103
|
-
"FeesAmount",
|
|
104
|
-
"FeesCurrency",
|
|
105
|
-
"Type",
|
|
106
|
-
"PaymentMethod",
|
|
107
|
-
"BuyerId",
|
|
108
|
-
"SellerId"
|
|
109
|
-
]
|
|
110
|
-
};
|
|
111
|
-
api.ReportsV2.create(reportPost).then(function (data) {
|
|
112
|
-
report = data;
|
|
113
|
-
done();
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('should be correctly fetched', function () {
|
|
118
|
-
expect(report.Id).to.exist;
|
|
119
|
-
expect(report.ReportType).to.equal("ECHO_INTENT");
|
|
120
|
-
expect(report.DownloadFormat).to.equal("CSV");
|
|
121
|
-
expect(report.Status).to.equal("PENDING");
|
|
122
|
-
expect(report.Filters.Status).to.equal("CAPTURED");
|
|
123
|
-
expect(report.Columns.length).to.equal(10);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe('Create intent action report', function () {
|
|
128
|
-
var report;
|
|
129
|
-
|
|
130
|
-
before(function (done) {
|
|
131
|
-
var reportPost = {
|
|
132
|
-
"DownloadFormat" : "CSV",
|
|
133
|
-
"ReportType" : "ECHO_INTENT_ACTION",
|
|
134
|
-
"AfterDate" : 1748782023,
|
|
135
|
-
"BeforeDate" : 1753102013,
|
|
136
|
-
"Filters" : {
|
|
137
|
-
"PaymentMethod" : "PAYPAL",
|
|
138
|
-
"Status" : "CAPTURED",
|
|
139
|
-
"Type" : "PAYIN"
|
|
140
|
-
},
|
|
141
|
-
"Columns" : [
|
|
142
|
-
"IntentId",
|
|
143
|
-
"Id",
|
|
144
|
-
"ExternalProcessingDate",
|
|
145
|
-
"ExternalProviderReference",
|
|
146
|
-
"ExternalMerchantReference",
|
|
147
|
-
"Status",
|
|
148
|
-
"Amount",
|
|
149
|
-
"Currency",
|
|
150
|
-
"FeesAmount",
|
|
151
|
-
"FeesCurrency",
|
|
152
|
-
"Type",
|
|
153
|
-
"PaymentMethod",
|
|
154
|
-
"BuyerId",
|
|
155
|
-
"SellerId"
|
|
156
|
-
]
|
|
157
|
-
};
|
|
158
|
-
api.ReportsV2.create(reportPost).then(function (data) {
|
|
159
|
-
report = data;
|
|
160
|
-
done();
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('should be correctly fetched', function () {
|
|
165
|
-
expect(report.Id).to.exist;
|
|
166
|
-
expect(report.ReportType).to.equal("ECHO_INTENT_ACTION");
|
|
167
|
-
expect(report.DownloadFormat).to.equal("CSV");
|
|
168
|
-
expect(report.Status).to.equal("PENDING");
|
|
169
|
-
expect(report.Filters.Status).to.equal("CAPTURED");
|
|
170
|
-
expect(report.Columns.length).to.equal(14);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
describe('Create settlement report', function () {
|
|
175
|
-
var report;
|
|
176
|
-
|
|
177
|
-
before(function (done) {
|
|
178
|
-
var reportPost = {
|
|
179
|
-
"DownloadFormat" : "CSV",
|
|
180
|
-
"ReportType" : "ECHO_SETTLEMENT",
|
|
181
|
-
"AfterDate" : 1748782023,
|
|
182
|
-
"BeforeDate" : 1753102013,
|
|
183
|
-
"Filters" : {
|
|
184
|
-
"Status" : "RECONCILED",
|
|
185
|
-
"ExternalProviderName" : "PAYPAL"
|
|
186
|
-
},
|
|
187
|
-
"Columns" : [
|
|
188
|
-
"Id",
|
|
189
|
-
"CreationDate",
|
|
190
|
-
"FileName",
|
|
191
|
-
"SettlementCurrency",
|
|
192
|
-
"Status",
|
|
193
|
-
"SettledTransactionCount",
|
|
194
|
-
"UnsettledTransactionCount",
|
|
195
|
-
"SettledAmount",
|
|
196
|
-
"DeclaredAmount",
|
|
197
|
-
"DeficitAmount"
|
|
198
|
-
]
|
|
199
|
-
};
|
|
200
|
-
api.ReportsV2.create(reportPost).then(function (data) {
|
|
201
|
-
report = data;
|
|
202
|
-
done();
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('should be correctly fetched', function () {
|
|
207
|
-
expect(report.Id).to.exist;
|
|
208
|
-
expect(report.ReportType).to.equal("ECHO_SETTLEMENT");
|
|
209
|
-
expect(report.DownloadFormat).to.equal("CSV");
|
|
210
|
-
expect(report.Status).to.equal("PENDING");
|
|
211
|
-
expect(report.Filters.Status).to.equal("RECONCILED");
|
|
212
|
-
expect(report.Columns.length).to.equal(10);
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
describe('Create settlement report', function () {
|
|
217
|
-
var report;
|
|
218
|
-
|
|
219
|
-
before(function (done) {
|
|
220
|
-
var reportPost = {
|
|
221
|
-
"DownloadFormat" : "CSV",
|
|
222
|
-
"ReportType" : "ECHO_SETTLEMENT",
|
|
223
|
-
"AfterDate" : 1748782023,
|
|
224
|
-
"BeforeDate" : 1753102013,
|
|
225
|
-
"Filters" : {
|
|
226
|
-
"Status" : "RECONCILED",
|
|
227
|
-
"ExternalProviderName" : "PAYPAL"
|
|
228
|
-
},
|
|
229
|
-
"Columns" : [
|
|
230
|
-
"Id",
|
|
231
|
-
"CreationDate",
|
|
232
|
-
"FileName",
|
|
233
|
-
"SettlementCurrency",
|
|
234
|
-
"Status",
|
|
235
|
-
"SettledTransactionCount",
|
|
236
|
-
"UnsettledTransactionCount",
|
|
237
|
-
"SettledAmount",
|
|
238
|
-
"DeclaredAmount",
|
|
239
|
-
"DeficitAmount"
|
|
240
|
-
]
|
|
241
|
-
};
|
|
242
|
-
api.ReportsV2.create(reportPost).then(function (data) {
|
|
243
|
-
report = data;
|
|
244
|
-
done();
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it('should be correctly fetched', function () {
|
|
249
|
-
expect(report.Id).to.exist;
|
|
250
|
-
expect(report.ReportType).to.equal("ECHO_SETTLEMENT");
|
|
251
|
-
expect(report.DownloadFormat).to.equal("CSV");
|
|
252
|
-
expect(report.Status).to.equal("PENDING");
|
|
253
|
-
expect(report.Filters.Status).to.equal("RECONCILED");
|
|
254
|
-
expect(report.Columns.length).to.equal(10);
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
describe('Create split report', function () {
|
|
259
|
-
var report;
|
|
260
|
-
|
|
261
|
-
before(function (done) {
|
|
262
|
-
var reportPost = {
|
|
263
|
-
"Tag" : "Creating a report using new Mangopay system",
|
|
264
|
-
"DownloadFormat" : "CSV",
|
|
265
|
-
"ReportType" : "ECHO_SPLIT",
|
|
266
|
-
"AfterDate" : 1748782023,
|
|
267
|
-
"BeforeDate" : 1753102013,
|
|
268
|
-
"Filters" : {
|
|
269
|
-
"Status" : "COMPLETED",
|
|
270
|
-
"IntentId" : "int_0197f975-63f6-714e-8fc6-4451e128170f",
|
|
271
|
-
"Scheduled": false
|
|
272
|
-
},
|
|
273
|
-
"Columns" : [
|
|
274
|
-
"Id",
|
|
275
|
-
"IntentId",
|
|
276
|
-
"AuthorId",
|
|
277
|
-
"Amount",
|
|
278
|
-
"Currency",
|
|
279
|
-
"FeesAmount",
|
|
280
|
-
"FeesCurrency",
|
|
281
|
-
"Status",
|
|
282
|
-
"Description",
|
|
283
|
-
"CreditedWalletId",
|
|
284
|
-
"DebitedWalletId",
|
|
285
|
-
"Scheduled",
|
|
286
|
-
"CreationDate",
|
|
287
|
-
"ExecutionDate"
|
|
288
|
-
]
|
|
289
|
-
};
|
|
290
|
-
api.ReportsV2.create(reportPost).then(function (data) {
|
|
291
|
-
report = data;
|
|
292
|
-
done();
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it('should be correctly fetched', function () {
|
|
297
|
-
expect(report.Id).to.exist;
|
|
298
|
-
expect(report.ReportType).to.equal("ECHO_SPLIT");
|
|
299
|
-
expect(report.DownloadFormat).to.equal("CSV");
|
|
300
|
-
expect(report.Status).to.equal("PENDING");
|
|
301
|
-
expect(report.Filters.Status).to.equal("COMPLETED");
|
|
302
|
-
expect(report.Filters.IntentId).to.equal("int_0197f975-63f6-714e-8fc6-4451e128170f");
|
|
303
|
-
expect(report.Columns.length).to.equal(14);
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
var expect = require('chai').expect;
|
|
2
|
-
var api = require('../main');
|
|
3
|
-
|
|
4
|
-
describe('Repudiations', function() {
|
|
5
|
-
var REPUDIATION_ID = '41631014';
|
|
6
|
-
|
|
7
|
-
describe('Get Refunds', function() {
|
|
8
|
-
var getRefunds;
|
|
9
|
-
|
|
10
|
-
before(function(done) {
|
|
11
|
-
api.Repudiations.getRefunds(REPUDIATION_ID, function(data, response) {
|
|
12
|
-
getRefunds = data;
|
|
13
|
-
done();
|
|
14
|
-
})
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should be retrieved', function() {
|
|
18
|
-
expect(getRefunds).not.to.be.undefined;
|
|
19
|
-
expect(getRefunds).to.be.an('array');
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
var expect = require('chai').expect;
|
|
2
|
-
var api = require('../main');
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
|
|
6
|
-
describe('Settlements', function () {
|
|
7
|
-
var settlement;
|
|
8
|
-
|
|
9
|
-
before(function (done) {
|
|
10
|
-
api.Settlements.generateUploadUrl({FileName: "settlement_sample.csv"}).then(function (data) {
|
|
11
|
-
settlement = data;
|
|
12
|
-
done();
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should generate upload url', function () {
|
|
17
|
-
expect(settlement).not.to.be.undefined;
|
|
18
|
-
expect(settlement.UploadUrl).not.to.be.undefined;
|
|
19
|
-
expect(settlement.SettlementId).not.to.be.undefined;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe('Fetch', function () {
|
|
23
|
-
var fetched;
|
|
24
|
-
|
|
25
|
-
before(function (done) {
|
|
26
|
-
api.Settlements.get(settlement.SettlementId).then(function (data) {
|
|
27
|
-
fetched = data;
|
|
28
|
-
done();
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should be fetched', function () {
|
|
33
|
-
expect(fetched).not.to.be.undefined;
|
|
34
|
-
expect(fetched.Status).to.equal("PENDING_UPLOAD");
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('Generate new upload url', function () {
|
|
39
|
-
var newUploadUrl;
|
|
40
|
-
|
|
41
|
-
before(function (done) {
|
|
42
|
-
api.Settlements.generateNewUploadUrl(settlement.SettlementId, {FileName: "settlement_sample_updated.csv"}).then(function (data) {
|
|
43
|
-
newUploadUrl = data;
|
|
44
|
-
done();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should generate the new url', function () {
|
|
49
|
-
expect(newUploadUrl).not.to.be.undefined;
|
|
50
|
-
expect(newUploadUrl.UploadUrl).not.to.be.undefined;
|
|
51
|
-
expect(newUploadUrl.SettlementId).not.to.be.undefined;
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe('Upload file', function () {
|
|
56
|
-
var uploadResponse;
|
|
57
|
-
|
|
58
|
-
before(function (done) {
|
|
59
|
-
const filePath = path.resolve(__dirname, '../settlement_sample.csv');
|
|
60
|
-
const fileBuffer = fs.readFileSync(filePath);
|
|
61
|
-
|
|
62
|
-
var options = {
|
|
63
|
-
data: fileBuffer,
|
|
64
|
-
url: settlement.UploadUrl,
|
|
65
|
-
headers: {
|
|
66
|
-
'Content-Type': 'text/csv'
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
api.method('put', function (data, response) {
|
|
71
|
-
uploadResponse = response;
|
|
72
|
-
done();
|
|
73
|
-
}, options);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should upload the file', function () {
|
|
77
|
-
expect(uploadResponse).not.to.be.undefined;
|
|
78
|
-
expect(uploadResponse.status).to.equal(200);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe('Get Validations', function () {
|
|
83
|
-
var validations;
|
|
84
|
-
|
|
85
|
-
before(function (done) {
|
|
86
|
-
const filePath = path.resolve(__dirname, '../settlement_sample_bad.csv');
|
|
87
|
-
const fileBuffer = fs.readFileSync(filePath);
|
|
88
|
-
|
|
89
|
-
var options = {
|
|
90
|
-
data: fileBuffer,
|
|
91
|
-
url: settlement.UploadUrl,
|
|
92
|
-
headers: {
|
|
93
|
-
'Content-Type': 'text/csv'
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
api.method('put', function (data, response) {
|
|
98
|
-
api.Settlements.getValidations(settlement.SettlementId).then(function (data) {
|
|
99
|
-
validations = data;
|
|
100
|
-
done();
|
|
101
|
-
});
|
|
102
|
-
}, options);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should upload the file', function () {
|
|
106
|
-
expect(validations).not.to.be.undefined;
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe('Cancel settlement', function () {
|
|
111
|
-
var cancelled;
|
|
112
|
-
|
|
113
|
-
before(function (done) {
|
|
114
|
-
api.Settlements.generateUploadUrl({FileName: "settlement_sample.csv"}).then(function (data) {
|
|
115
|
-
api.Settlements.cancel(data.SettlementId).then(function (data) {
|
|
116
|
-
cancelled = data;
|
|
117
|
-
done();
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('should cancel the settlement', function () {
|
|
123
|
-
expect(cancelled).not.to.be.undefined;
|
|
124
|
-
expect(cancelled.Status).to.equal("CANCELLED");
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
});
|
package/test/services/Tokens.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var expect = require('chai').expect;
|
|
2
|
-
var mangopay = require('../../index');
|
|
3
|
-
var api = require('../main');
|
|
4
|
-
|
|
5
|
-
describe('Tokens', function() {
|
|
6
|
-
var authentication1, authentication2;
|
|
7
|
-
|
|
8
|
-
before(function(done){
|
|
9
|
-
api.authorize()
|
|
10
|
-
.then(function(data){
|
|
11
|
-
authentication1 = data;
|
|
12
|
-
api.authorize()
|
|
13
|
-
.then(function(data){
|
|
14
|
-
authentication2 = data;
|
|
15
|
-
done();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should have different token values', function(){
|
|
21
|
-
expect(authentication1.access_token).to.not.equal(authentication2.access_token);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('When trying to authenticate with wrong credentials', function() {
|
|
26
|
-
var wrongCredentialsError;
|
|
27
|
-
|
|
28
|
-
before('Build API object with wrong credentials', function(done){
|
|
29
|
-
var wrongApi = new mangopay({
|
|
30
|
-
clientId: 'sdk-unit-tests',
|
|
31
|
-
clientApiKey: 'wrongPass'
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
wrongApi.authorize()
|
|
35
|
-
.then(function(){
|
|
36
|
-
done('Promise should not pass');
|
|
37
|
-
})
|
|
38
|
-
.catch(function(data) {
|
|
39
|
-
wrongCredentialsError = data;
|
|
40
|
-
done();
|
|
41
|
-
})
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should have the right error message', function(){
|
|
45
|
-
expect(wrongCredentialsError.error).to.equal('invalid_client');
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('OAuth URL is correct', function() {
|
|
50
|
-
const url = api.buildOauthUrl();
|
|
51
|
-
|
|
52
|
-
it('has the correct format', function() {
|
|
53
|
-
expect(url).to.equal(`/${api.config.apiVersion}/oauth/token`);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
var expect = require('chai').expect;
|
|
2
|
-
var helpers = require('../helpers');
|
|
3
|
-
var api = require('../main');
|
|
4
|
-
const UserLegalSca = require("../../lib/models/UserLegalSca");
|
|
5
|
-
|
|
6
|
-
describe('Transfers', function () {
|
|
7
|
-
var john = helpers.data.getUserNatural();
|
|
8
|
-
var wallet, secondWallet, transfer;
|
|
9
|
-
|
|
10
|
-
before(function (done) {
|
|
11
|
-
api.Users.create(john).then(function () {
|
|
12
|
-
wallet = {
|
|
13
|
-
Owners: [john.Id],
|
|
14
|
-
Currency: 'EUR',
|
|
15
|
-
Description: 'WALLET IN EUR'
|
|
16
|
-
};
|
|
17
|
-
secondWallet = {
|
|
18
|
-
Owners: [john.Id],
|
|
19
|
-
Currency: 'EUR',
|
|
20
|
-
Description: 'WALLET IN EUR'
|
|
21
|
-
};
|
|
22
|
-
api.Wallets.create(wallet).then(function () {
|
|
23
|
-
api.Wallets.create(secondWallet).then(function () {
|
|
24
|
-
api.Transfers.create({
|
|
25
|
-
AuthorId: john.Id,
|
|
26
|
-
Tag: 'DefaultTag',
|
|
27
|
-
CreditedUserId: john.Id,
|
|
28
|
-
DebitedFunds: {
|
|
29
|
-
Currency: 'EUR',
|
|
30
|
-
Amount: 1
|
|
31
|
-
},
|
|
32
|
-
Fees: {
|
|
33
|
-
Currency: 'EUR',
|
|
34
|
-
Amount: 0
|
|
35
|
-
},
|
|
36
|
-
DebitedWalletId: wallet.Id,
|
|
37
|
-
CreditedWalletId: secondWallet.Id
|
|
38
|
-
}, function (data, response) {
|
|
39
|
-
transfer = data;
|
|
40
|
-
done();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('Create', function () {
|
|
48
|
-
it('should not happen because of insufficient funds', function () {
|
|
49
|
-
expect(transfer.Status).to.equal('FAILED');
|
|
50
|
-
expect(transfer.CreditedUserId).to.equal(john.Id);
|
|
51
|
-
expect(transfer.DebitedWalletId).to.equal(wallet.Id);
|
|
52
|
-
expect(transfer.CreditedWalletId).to.equal(secondWallet.Id);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe('Create Transfer Sca User Present', function () {
|
|
57
|
-
var validUserNaturalScaId = "user_m_01JRFJJN9BR864A4KG7MH1WCZG";
|
|
58
|
-
var transferWithPendingUserAction;
|
|
59
|
-
var transferWithoutPendingUserAction;
|
|
60
|
-
var transferUserNotPresent;
|
|
61
|
-
|
|
62
|
-
before(function (done) {
|
|
63
|
-
// var johnSca = helpers.data.getUserNaturalScaOwner();
|
|
64
|
-
var matrixScaOwnerPost = new UserLegalSca(helpers.data.getUserLegalScaOwner());
|
|
65
|
-
api.Users.create(matrixScaOwnerPost).then(function (matrixScaOwner) {
|
|
66
|
-
helpers.getNewWalletWithMoney(api, validUserNaturalScaId, function (debitedWallet) {
|
|
67
|
-
var creditedWalletPost = {
|
|
68
|
-
Owners: [matrixScaOwner.Id],
|
|
69
|
-
Currency: 'EUR',
|
|
70
|
-
Description: 'WALLET IN EUR'
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
api.Wallets.create(creditedWalletPost).then(function (creditedWallet) {
|
|
74
|
-
var transferPost = {
|
|
75
|
-
AuthorId: validUserNaturalScaId,
|
|
76
|
-
CreditedUserId: matrixScaOwner.Id,
|
|
77
|
-
DebitedFunds: {
|
|
78
|
-
Currency: 'EUR',
|
|
79
|
-
Amount: 3001
|
|
80
|
-
},
|
|
81
|
-
Fees: {
|
|
82
|
-
Currency: 'EUR',
|
|
83
|
-
Amount: 0
|
|
84
|
-
},
|
|
85
|
-
DebitedWalletId: debitedWallet.Id,
|
|
86
|
-
CreditedWalletId: creditedWallet.Id,
|
|
87
|
-
ScaContext: 'USER_PRESENT'
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
api.Transfers.create(transferPost).then(function (data) {
|
|
91
|
-
transferWithPendingUserAction = data;
|
|
92
|
-
transferPost.DebitedFunds = {
|
|
93
|
-
Currency: 'EUR',
|
|
94
|
-
Amount: 20
|
|
95
|
-
};
|
|
96
|
-
api.Transfers.create(transferPost).then(function (data) {
|
|
97
|
-
transferWithoutPendingUserAction = data;
|
|
98
|
-
transferPost.ScaContext = 'USER_NOT_PRESENT';
|
|
99
|
-
api.Transfers.create(transferPost).then(function (data) {
|
|
100
|
-
transferUserNotPresent = data;
|
|
101
|
-
done();
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('should be created', function () {
|
|
111
|
-
expect(transferWithPendingUserAction.Status).to.equal('SUCCEEDED');
|
|
112
|
-
expect(transferWithPendingUserAction.PendingUserAction).not.to.be.undefined;
|
|
113
|
-
|
|
114
|
-
expect(transferWithoutPendingUserAction.Status).to.equal('SUCCEEDED');
|
|
115
|
-
expect(transferWithoutPendingUserAction.PendingUserAction).to.be.null;
|
|
116
|
-
|
|
117
|
-
expect(transferUserNotPresent.Status).to.equal('SUCCEEDED');
|
|
118
|
-
expect(transferUserNotPresent.PendingUserAction).to.be.null;
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('Get Refunds', function () {
|
|
123
|
-
var getRefunds;
|
|
124
|
-
|
|
125
|
-
before(function (done) {
|
|
126
|
-
api.Transfers.getRefunds(transfer.Id, function (data, response) {
|
|
127
|
-
getRefunds = data;
|
|
128
|
-
done();
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('should be retrieved', function () {
|
|
133
|
-
expect(getRefunds).not.to.be.undefined;
|
|
134
|
-
expect(getRefunds).to.be.an('array');
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
});
|