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
package/test/services/Events.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
var _ = require('underscore');
|
|
2
|
-
var expect = require('chai').expect;
|
|
3
|
-
var api = require('../main');
|
|
4
|
-
|
|
5
|
-
var helpers = require('../helpers');
|
|
6
|
-
|
|
7
|
-
describe('Events', function() {
|
|
8
|
-
var john = helpers.data.getUserNatural();
|
|
9
|
-
|
|
10
|
-
before(function(done){
|
|
11
|
-
api.Users.create(john, function(){
|
|
12
|
-
done();
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
describe('Get Events List', function () {
|
|
17
|
-
describe('Payin Normal Created', function () {
|
|
18
|
-
var payIn, events;
|
|
19
|
-
|
|
20
|
-
before(function(done) {
|
|
21
|
-
helpers.getNewPayInCardWeb(api, john, async function (data, response) {
|
|
22
|
-
payIn = data;
|
|
23
|
-
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
24
|
-
await delay(5000);
|
|
25
|
-
api.Events.getAll(function (data, response) {
|
|
26
|
-
events = data;
|
|
27
|
-
done();
|
|
28
|
-
}, {
|
|
29
|
-
parameters: {
|
|
30
|
-
BeforeDate: payIn.CreationDate + 10,
|
|
31
|
-
AfterDate: payIn.CreationDate - 10,
|
|
32
|
-
EventType: 'PAYIN_NORMAL_CREATED'
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should find created event', function () {
|
|
39
|
-
expect(events.length).to.be.above(0);
|
|
40
|
-
expect(_.findWhere(events, {ResourceId: payIn.Id})).to.exist;
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe('Payin Normal Succeeded', function () {
|
|
45
|
-
var payIn, events;
|
|
46
|
-
|
|
47
|
-
before(function(done) {
|
|
48
|
-
helpers.getNewPayInCardDirect(api, john, async function (data, response) {
|
|
49
|
-
payIn = data;
|
|
50
|
-
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
51
|
-
await delay(10000);
|
|
52
|
-
api.Events.getAll(function (data, response) {
|
|
53
|
-
events = data;
|
|
54
|
-
done();
|
|
55
|
-
}, {
|
|
56
|
-
parameters: {
|
|
57
|
-
BeforeDate: payIn.ExecutionDate + 100,
|
|
58
|
-
AfterDate: payIn.CreationDate - 100,
|
|
59
|
-
EventType: 'PAYIN_NORMAL_SUCCEEDED'
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should find succeeded event', function () {
|
|
66
|
-
expect(events.length).to.be.above(0);
|
|
67
|
-
expect(_.findWhere(events, {ResourceId: payIn.Id})).to.exist;
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('Payout Normal Created', function () {
|
|
72
|
-
var payOut, events;
|
|
73
|
-
|
|
74
|
-
before(function(done) {
|
|
75
|
-
helpers.getNewPayoutBankWire(api, john, async function (data, response) {
|
|
76
|
-
payOut = data;
|
|
77
|
-
// wait 2 seconds for the transactions to be created by the API
|
|
78
|
-
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
79
|
-
await delay(5000);
|
|
80
|
-
|
|
81
|
-
api.Events.getAll(function (data, response) {
|
|
82
|
-
events = data;
|
|
83
|
-
done();
|
|
84
|
-
}, {
|
|
85
|
-
parameters: {
|
|
86
|
-
BeforeDate: payOut.CreationDate + 10,
|
|
87
|
-
AfterDate: payOut.CreationDate - 10,
|
|
88
|
-
EventType: 'PAYOUT_NORMAL_CREATED'
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should find payout created event', function () {
|
|
95
|
-
expect(events.length).to.be.above(0);
|
|
96
|
-
expect(_.findWhere(events, {ResourceId: payOut.Id})).to.exist;
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe('Get KYC Documents', function () {
|
|
102
|
-
var kycDocument, events;
|
|
103
|
-
before(function(done){
|
|
104
|
-
api.Users.createKycDocument(john.Id, {
|
|
105
|
-
Status: 'CREATED',
|
|
106
|
-
Type: 'IDENTITY_PROOF'
|
|
107
|
-
}).then(function(document){
|
|
108
|
-
kycDocument = document;
|
|
109
|
-
api.Events.getAll(function(data, response){
|
|
110
|
-
events = data;
|
|
111
|
-
done();
|
|
112
|
-
}, {
|
|
113
|
-
parameters: {
|
|
114
|
-
BeforeDate: kycDocument.CreationDate+10,
|
|
115
|
-
AfterDate: kycDocument.CreationDate-10,
|
|
116
|
-
EventType: 'KYC_CREATED'
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('should find KYC Document event', function () {
|
|
123
|
-
expect(events.length).to.be.above(0);
|
|
124
|
-
expect(_.findWhere(events, {ResourceId: kycDocument.Id})).to.exist;
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// TODO: Remove the .skip() call once Get Events endpoint is fixed on the server.
|
|
129
|
-
describe.skip('Get All Sort By Creation Date', function () {
|
|
130
|
-
var events;
|
|
131
|
-
before(function(done){
|
|
132
|
-
api.Events.getAll(function(data, response){
|
|
133
|
-
events = data;
|
|
134
|
-
done();
|
|
135
|
-
}, {
|
|
136
|
-
parameters: {
|
|
137
|
-
Sort: 'CreationDate:asc'
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should return events sorted', function () {
|
|
143
|
-
expect(events.length).to.be.above(0);
|
|
144
|
-
expect(events[1].Date).to.be.above(events[0].Date);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
});
|
package/test/services/Hooks.js
DELETED
|
@@ -1,109 +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('Hooks', function() {
|
|
7
|
-
var hook;
|
|
8
|
-
|
|
9
|
-
describe('Create', function () {
|
|
10
|
-
before(function (done) {
|
|
11
|
-
api.Hooks.getAll(function(data, response){
|
|
12
|
-
if (data.length) {
|
|
13
|
-
hook = data[0];
|
|
14
|
-
done();
|
|
15
|
-
} else {
|
|
16
|
-
api.Hooks.create({
|
|
17
|
-
EventType: 'PAYIN_NORMAL_CREATED',
|
|
18
|
-
Url: 'http://test.com'
|
|
19
|
-
}, function(data, response){
|
|
20
|
-
hook = data;
|
|
21
|
-
done()
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should be created', function () {
|
|
28
|
-
expect(hook.Id).to.exist;
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('Get', function () {
|
|
33
|
-
var getHook;
|
|
34
|
-
before(function (done) {
|
|
35
|
-
api.Hooks.get(hook.Id, function(data, response){
|
|
36
|
-
getHook = data;
|
|
37
|
-
done();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should be the same as the created one', function () {
|
|
42
|
-
expect(getHook.Id).to.equal(hook.Id);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe('Update', function () {
|
|
47
|
-
var updatedHook;
|
|
48
|
-
var newUrl = 'http://test123.com?_t=' + new Date().getTime();
|
|
49
|
-
before(function (done) {
|
|
50
|
-
hook.Url = newUrl;
|
|
51
|
-
api.Hooks.update(hook, function(data, response){
|
|
52
|
-
updatedHook = data;
|
|
53
|
-
done();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should be updated', function () {
|
|
58
|
-
expect(updatedHook.Url).to.equal(newUrl);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('Create User Kyc Regular', function () {
|
|
63
|
-
before(function (done) {
|
|
64
|
-
api.Hooks.getAll(function(data, response){
|
|
65
|
-
hook = data.find(x => x.EventType === "USER_KYC_REGULAR");
|
|
66
|
-
if (!hook){
|
|
67
|
-
api.Hooks.create({
|
|
68
|
-
EventType: 'USER_KYC_REGULAR',
|
|
69
|
-
Url: 'http://test.com'
|
|
70
|
-
}, function(data, response){
|
|
71
|
-
hook = data;
|
|
72
|
-
done();
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
done();
|
|
76
|
-
}, {
|
|
77
|
-
parameters: {
|
|
78
|
-
EventType: 'USER_KYC_REGULAR',
|
|
79
|
-
Page: 1,
|
|
80
|
-
Per_Page: 100
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should be created', function () {
|
|
86
|
-
expect(hook.Id).to.exist;
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe('Get All', function () {
|
|
91
|
-
var hooks;
|
|
92
|
-
before(function (done) {
|
|
93
|
-
api.Hooks.getAll(function(data, response){
|
|
94
|
-
hooks = data;
|
|
95
|
-
done();
|
|
96
|
-
}, {
|
|
97
|
-
page: 1,
|
|
98
|
-
per_page: 50,
|
|
99
|
-
sort: "CreationDate:DESC"
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('should be > 0', function(){
|
|
104
|
-
expect(hooks.length).to.be.greaterThan(0);
|
|
105
|
-
expect(hooks[0].CreationDate).to.be.greaterThan(hooks[1].CreationDate);
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
var expect = require('chai').expect;
|
|
2
|
-
var api = require('../main');
|
|
3
|
-
|
|
4
|
-
var helpers = require('../helpers');
|
|
5
|
-
var api = require('../main');
|
|
6
|
-
|
|
7
|
-
describe('Idempotency', function () {
|
|
8
|
-
var idempotencyKey = helpers.generateRandomString();
|
|
9
|
-
|
|
10
|
-
describe('Get Valid Response', function () {
|
|
11
|
-
var validIdempotencyResponse;
|
|
12
|
-
var payIn;
|
|
13
|
-
var john = helpers.data.getUserNatural();
|
|
14
|
-
|
|
15
|
-
before(function (done) {
|
|
16
|
-
api.Users.create(john, function () {
|
|
17
|
-
done();
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
before(function (done) {
|
|
22
|
-
helpers.getNewPayInCardWebWithIdempotencyKey(api, john, idempotencyKey, function (data, response) {
|
|
23
|
-
payIn = data;
|
|
24
|
-
done();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
before(function (done) {
|
|
29
|
-
api.Idempotency.get(idempotencyKey, function (data, response) {
|
|
30
|
-
validIdempotencyResponse = data;
|
|
31
|
-
done();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should get the Valid Idempotency Response', function () {
|
|
36
|
-
expect(validIdempotencyResponse.StatusCode).to.equal('200');
|
|
37
|
-
expect(validIdempotencyResponse.Resource).to.exist;
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var _ = require('underscore');
|
|
2
|
-
var expect = require('chai').expect;
|
|
3
|
-
var helpers = require('../helpers');
|
|
4
|
-
var api = require('../main');
|
|
5
|
-
const UserNatural = require("../../lib/models/UserNatural");
|
|
6
|
-
|
|
7
|
-
describe('IdentityVerifications', function () {
|
|
8
|
-
var john = new UserNatural(helpers.data.getUserNatural());
|
|
9
|
-
var identityVerification;
|
|
10
|
-
|
|
11
|
-
before(function (done) {
|
|
12
|
-
api.Users.create(john).then(function (data, response) {
|
|
13
|
-
john = data;
|
|
14
|
-
const identityVerificationCreate = {
|
|
15
|
-
"ReturnUrl": "https://example.com",
|
|
16
|
-
"Tag": "Created using the NodeJS SDK"
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
api.IdentityVerifications.create(john.Id, identityVerificationCreate).then(function (data, response) {
|
|
20
|
-
identityVerification = data;
|
|
21
|
-
done();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('Create', function () {
|
|
27
|
-
it('should be created', function () {
|
|
28
|
-
expect(identityVerification).not.to.be.undefined;
|
|
29
|
-
expect(identityVerification.HostedUrl).not.to.be.undefined;
|
|
30
|
-
expect(identityVerification.ReturnUrl).not.to.be.undefined;
|
|
31
|
-
expect(identityVerification.Status).to.equal("PENDING");
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('Get', function () {
|
|
36
|
-
var fetched;
|
|
37
|
-
|
|
38
|
-
before(function (done) {
|
|
39
|
-
api.IdentityVerifications.get(identityVerification.Id).then(function (data, response) {
|
|
40
|
-
fetched = data;
|
|
41
|
-
done();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should be fetched', function () {
|
|
46
|
-
expect(fetched).not.to.be.undefined;
|
|
47
|
-
expect(fetched.HostedUrl).to.equal(identityVerification.HostedUrl);
|
|
48
|
-
expect(fetched.ReturnUrl).to.equal(identityVerification.ReturnUrl);
|
|
49
|
-
expect(fetched.Status).to.equal(identityVerification.Status);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe('Get All', function () {
|
|
54
|
-
var fetched;
|
|
55
|
-
|
|
56
|
-
before(function (done) {
|
|
57
|
-
api.IdentityVerifications.getAll(john.Id).then(function (data, response) {
|
|
58
|
-
fetched = data;
|
|
59
|
-
done();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should be fetched', function () {
|
|
64
|
-
expect(fetched).not.to.be.undefined;
|
|
65
|
-
expect(fetched.length).to.be.above(0);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,73 +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('KycDocuments', function() {
|
|
7
|
-
var john = helpers.data.getUserNatural();
|
|
8
|
-
var document;
|
|
9
|
-
|
|
10
|
-
before(function(done){
|
|
11
|
-
api.Users.create(john).then(function(){
|
|
12
|
-
api.Users.createKycDocument(john.Id, {
|
|
13
|
-
Status: 'CREATED',
|
|
14
|
-
Type: 'IDENTITY_PROOF',
|
|
15
|
-
Tag: "custom meta"
|
|
16
|
-
}).then(function(data){
|
|
17
|
-
document = data;
|
|
18
|
-
done();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe('Get All', function () {
|
|
24
|
-
var documents;
|
|
25
|
-
before(function(done){
|
|
26
|
-
api.KycDocuments.getAll(function(data, response){
|
|
27
|
-
documents = data;
|
|
28
|
-
done();
|
|
29
|
-
}, {
|
|
30
|
-
parameters: {
|
|
31
|
-
AfterDate: document.CreationDate - 10,
|
|
32
|
-
BeforeDate: document.CreationDate + 10
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should contain the created document', function () {
|
|
38
|
-
expect(_.findWhere(documents, {Id: document.Id})).to.exist;
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe('Get', function () {
|
|
43
|
-
var getDocument;
|
|
44
|
-
before(function(done){
|
|
45
|
-
api.KycDocuments.get(document.Id, function(data, response){
|
|
46
|
-
getDocument = data;
|
|
47
|
-
done();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should get the document', function () {
|
|
52
|
-
expect(getDocument.Id).to.equal(document.Id);
|
|
53
|
-
expect(getDocument.Flags).not.to.be.undefined;
|
|
54
|
-
expect(getDocument.Flags).to.be.an('array');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('Create KYC Document Consult', function () {
|
|
59
|
-
var consults;
|
|
60
|
-
|
|
61
|
-
before(function(done) {
|
|
62
|
-
api.KycDocuments.createKycDocumentConsult(document.Id, function(data, response) {
|
|
63
|
-
consults = data;
|
|
64
|
-
done();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('should be created', function () {
|
|
69
|
-
expect(consults).not.to.be.undefined;
|
|
70
|
-
expect(consults).to.be.an('array');
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
var _ = require('underscore');
|
|
2
|
-
var path = require('path');
|
|
3
|
-
var Promise = require('promise');
|
|
4
|
-
var expect = require('chai').expect;
|
|
5
|
-
var assert = require('chai').assert;
|
|
6
|
-
var os = require('os');
|
|
7
|
-
var api = require('../main');
|
|
8
|
-
|
|
9
|
-
var helpers = require('../helpers');
|
|
10
|
-
|
|
11
|
-
var Mandate = require('../../lib/models/Mandate');
|
|
12
|
-
var UserNatural = require('../../lib/models/UserNatural');
|
|
13
|
-
var BankAccount = require('../../lib/models/BankAccount');
|
|
14
|
-
var BankAccountDetailsIBAN = require('../../lib/models/BankAccountDetailsIBAN');
|
|
15
|
-
var Wallet = require('../../lib/models/Wallet');
|
|
16
|
-
var PayIn = require('../../lib/models/PayIn');
|
|
17
|
-
|
|
18
|
-
describe('Mandates', function() {
|
|
19
|
-
var ibanAccount, mandate;
|
|
20
|
-
var john = new UserNatural(_.extend(helpers.data.getUserNatural()));
|
|
21
|
-
|
|
22
|
-
before(function(done){
|
|
23
|
-
api.Users.create(john).then(function(data){
|
|
24
|
-
john = data;
|
|
25
|
-
|
|
26
|
-
var account = new BankAccount({
|
|
27
|
-
OwnerName: john.FirstName + ' ' + john.LastName,
|
|
28
|
-
OwnerAddress: john.Address,
|
|
29
|
-
Details: new BankAccountDetailsIBAN({
|
|
30
|
-
IBAN: 'FR7630004000031234567890143',
|
|
31
|
-
BIC: 'BNPAFRPP'
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
api.Users.createBankAccount(john.Id, account).then(function(data){
|
|
36
|
-
ibanAccount = data;
|
|
37
|
-
|
|
38
|
-
mandate = new Mandate({
|
|
39
|
-
Tag: 'custom meta',
|
|
40
|
-
BankAccountId: ibanAccount.Id,
|
|
41
|
-
Culture: 'EN',
|
|
42
|
-
ReturnURL: 'http://www.my-site.com/returnURL/'
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
api.Mandates.create(mandate, function(data){
|
|
46
|
-
mandate = data;
|
|
47
|
-
done();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should be created with the right properties', function(){
|
|
55
|
-
expect(mandate.Id).not.to.be.undefined;
|
|
56
|
-
expect(mandate.BankAccountId).to.equal(ibanAccount.Id);
|
|
57
|
-
expect(mandate.MandateType).to.equal('DIRECT_DEBIT');
|
|
58
|
-
expect(mandate.ExecutionType).to.equal('WEB');
|
|
59
|
-
expect(mandate.ReturnURL).to.equal('http://www.my-site.com/returnURL/?MandateId=' + mandate.Id);
|
|
60
|
-
expect(mandate.Tag).to.equal('custom meta');
|
|
61
|
-
expect(mandate.Status).to.equal('CREATED');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe('Get created mandate', function() {
|
|
65
|
-
before(function(done){
|
|
66
|
-
api.Mandates.get(mandate.Id, function(data){
|
|
67
|
-
mandate = data;
|
|
68
|
-
done();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should be received with the right properties', function(){
|
|
73
|
-
expect(mandate.Id).not.to.be.undefined;
|
|
74
|
-
expect(mandate.BankAccountId).to.equal(ibanAccount.Id);
|
|
75
|
-
expect(mandate.MandateType).to.equal('DIRECT_DEBIT');
|
|
76
|
-
expect(mandate.ExecutionType).to.equal('WEB');
|
|
77
|
-
expect(mandate.ReturnURL).to.equal('http://www.my-site.com/returnURL/?MandateId=' + mandate.Id);
|
|
78
|
-
expect(mandate.Tag).to.equal('custom meta');
|
|
79
|
-
expect(mandate.Status).to.equal('CREATED');
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe('Get all mandates', function() {
|
|
84
|
-
var mandates;
|
|
85
|
-
|
|
86
|
-
before(function(done){
|
|
87
|
-
api.Mandates.getAll(function(data){
|
|
88
|
-
mandates = data;
|
|
89
|
-
done();
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should be retrieve at least one mandate', function(){
|
|
94
|
-
expect(mandates.length).to.be.above(1);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('Cancel a mandate before being approved it - CREATED status', function() {
|
|
99
|
-
var cancelResponse;
|
|
100
|
-
before(function(done){
|
|
101
|
-
api.Mandates.cancel(mandate.Id, function(data){
|
|
102
|
-
cancelResponse = data;
|
|
103
|
-
done();
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('shouldn\'t be able to cancel a mandate with the status "CREATED"', function(){
|
|
108
|
-
expect(cancelResponse.Type).to.equal('mandate_cannot_be_cancelled');
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
describe('Create DirectDebit Direct Payin before being approved - "CREATED" status', function() {
|
|
113
|
-
var payIn, wallet;
|
|
114
|
-
|
|
115
|
-
before(function(done){
|
|
116
|
-
wallet = new Wallet({
|
|
117
|
-
Owners: [john.Id],
|
|
118
|
-
Currency: 'EUR',
|
|
119
|
-
Description: 'WALLET IN EUR'
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
api.Wallets.create(wallet).then(function(data){
|
|
123
|
-
wallet = data;
|
|
124
|
-
|
|
125
|
-
payIn = new PayIn({
|
|
126
|
-
CreditedWalletId: wallet.Id,
|
|
127
|
-
AuthorId: john.Id,
|
|
128
|
-
DebitedFunds: {
|
|
129
|
-
Amount: 10000,
|
|
130
|
-
Currency: 'EUR'
|
|
131
|
-
},
|
|
132
|
-
Fees: {
|
|
133
|
-
Amount: 0,
|
|
134
|
-
Currency: 'EUR'
|
|
135
|
-
},
|
|
136
|
-
PaymentType: 'DIRECT_DEBIT',
|
|
137
|
-
ExecutionType: 'DIRECT',
|
|
138
|
-
MandateId: mandate.Id
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
api.PayIns.create(payIn, function(data) {
|
|
142
|
-
payIn = data;
|
|
143
|
-
done();
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('should be created successfully but with "FAILED" status', function(){
|
|
149
|
-
expect(payIn.AuthorId).to.equal(john.Id);
|
|
150
|
-
expect(payIn.CreditedUserId).to.equal(john.Id);
|
|
151
|
-
expect(payIn.CreditedWalletId).to.equal(wallet.Id);
|
|
152
|
-
expect(payIn.Status).to.equal('FAILED');
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Check if the OS platform has a GUI ( MacOS / Windows ) and if the tests are running
|
|
158
|
-
* in debugging mode. Otherwise this test cannot run, since a user action is required
|
|
159
|
-
* inside the browser, for approving the Mandate (clicking the "CONFIRM" button)
|
|
160
|
-
*/
|
|
161
|
-
if ((os.platform() === 'darwin' || os.platform() === 'win32') && process.execArgv && process.execArgv[0] && process.execArgv[0].match(/--debug-brk/)) {
|
|
162
|
-
describe('After approving the mandate', function() {
|
|
163
|
-
before(function(done){
|
|
164
|
-
/**
|
|
165
|
-
* ! IMPORTANT NOTE !
|
|
166
|
-
*
|
|
167
|
-
* In order to make this test pass debugging mode is required to stop at the breakpoint below
|
|
168
|
-
* and navigate to URL the mandate.RedirectURL property points to and click "CONFIRM" button.
|
|
169
|
-
*
|
|
170
|
-
* The command above is supposed to open your default browser window with that link for you:
|
|
171
|
-
*/
|
|
172
|
-
var spawn = require('child_process').spawn;
|
|
173
|
-
spawn('open', [mandate.RedirectURL]);
|
|
174
|
-
|
|
175
|
-
debugger;
|
|
176
|
-
done();
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
describe('Create DirectDebit Direct Payin after being approved', function() {
|
|
180
|
-
var payIn, wallet;
|
|
181
|
-
|
|
182
|
-
before(function(done){
|
|
183
|
-
wallet = new Wallet({
|
|
184
|
-
Owners: [john.Id],
|
|
185
|
-
Currency: 'EUR',
|
|
186
|
-
Description: 'WALLET IN EUR'
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
api.Wallets.create(wallet).then(function(data){
|
|
190
|
-
wallet = data;
|
|
191
|
-
|
|
192
|
-
payIn = new PayIn({
|
|
193
|
-
CreditedWalletId: wallet.Id,
|
|
194
|
-
AuthorId: john.Id,
|
|
195
|
-
DebitedFunds: {
|
|
196
|
-
Amount: 10000,
|
|
197
|
-
Currency: 'EUR'
|
|
198
|
-
},
|
|
199
|
-
Fees: {
|
|
200
|
-
Amount: 0,
|
|
201
|
-
Currency: 'EUR'
|
|
202
|
-
},
|
|
203
|
-
PaymentType: 'DIRECT_DEBIT',
|
|
204
|
-
ExecutionType: 'DIRECT',
|
|
205
|
-
MandateId: mandate.Id
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
api.PayIns.create(payIn, function(data) {
|
|
209
|
-
payIn = data;
|
|
210
|
-
done();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it('should be created successfully but with the right status', function(){
|
|
216
|
-
expect(payIn.AuthorId).to.equal(john.Id);
|
|
217
|
-
expect(payIn.CreditedUserId).to.equal(john.Id);
|
|
218
|
-
expect(payIn.CreditedWalletId).to.equal(wallet.Id);
|
|
219
|
-
expect(payIn.MandateId).to.equal(mandate.Id);
|
|
220
|
-
expect(payIn.Status).to.equal('CREATED');
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
describe('Cancel a mandate after being confirmed', function() {
|
|
225
|
-
var cancelResponse;
|
|
226
|
-
|
|
227
|
-
before(function(done){
|
|
228
|
-
api.Mandates.cancel(mandate.Id, function(data){
|
|
229
|
-
cancelResponse = data;
|
|
230
|
-
done();
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('should set the mandate status to "FAILED"', function(){
|
|
235
|
-
expect(cancelResponse.Status).to.equal('FAILED');
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
describe('Get Transactions', function() {
|
|
242
|
-
var getTransactions;
|
|
243
|
-
|
|
244
|
-
before(function(done) {
|
|
245
|
-
api.Mandates.getTransactions(mandate.Id, function(data) {
|
|
246
|
-
getTransactions = data;
|
|
247
|
-
done();
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it('should be retrieved', function() {
|
|
252
|
-
expect(getTransactions).not.to.be.undefined;
|
|
253
|
-
expect(getTransactions).to.be.an('array');
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
});
|