mangopay4-nodejs-sdk 1.64.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/.github/workflows/node.js.yml +32 -0
- package/.github/workflows/npm-publish.yml +26 -0
- package/.jshintrc +16 -0
- package/CHANGELOG.md +946 -0
- package/LICENSE +21 -0
- package/README.md +179 -0
- package/docs/BankAccounts.md +35 -0
- package/docs/BankingAliases.md +108 -0
- package/docs/CardPreAuthorizations.md +55 -0
- package/docs/CardRegistrations.md +55 -0
- package/docs/Cards.md +82 -0
- package/docs/Clients.md +142 -0
- package/docs/DisputeDocuments.md +53 -0
- package/docs/Disputes.md +292 -0
- package/docs/Events.md +23 -0
- package/docs/Hooks.md +68 -0
- package/docs/Idempotency.md +11 -0
- package/docs/KycDocuments.md +52 -0
- package/docs/Mandates.md +125 -0
- package/docs/OptionsHelper.md +32 -0
- package/docs/PayIns.md +72 -0
- package/docs/PayOuts.md +55 -0
- package/docs/README.md +131 -0
- package/docs/Refunds.md +25 -0
- package/docs/Reports.md +63 -0
- package/docs/Repudiations.md +25 -0
- package/docs/Responses.md +33 -0
- package/docs/Transfers.md +72 -0
- package/docs/UboDeclarations.md +70 -0
- package/docs/Users.md +322 -0
- package/docs/Wallets.md +70 -0
- package/docs/templates/class.mustache +11 -0
- package/docs/templates/file.mustache +53 -0
- package/docs/templates/function.mustache +33 -0
- package/docs/templates/index.mustache +26 -0
- package/docs/templates/overview.mustache +1 -0
- package/examples/createUsers.js +112 -0
- package/examples/createWallet.js +28 -0
- package/examples/failedRequest.js +20 -0
- package/examples/getBankAccounts.js +29 -0
- package/examples/getUserEmoney.js +16 -0
- package/examples/getUsers.js +32 -0
- package/examples/readResponseHeaders.js +42 -0
- package/index.js +1 -0
- package/lib/Model.js +58 -0
- package/lib/api.js +467 -0
- package/lib/apiMethods.js +270 -0
- package/lib/config.js +57 -0
- package/lib/log.js +9 -0
- package/lib/mangopay.js +8 -0
- package/lib/models/Address.js +32 -0
- package/lib/models/BankAccount.js +45 -0
- package/lib/models/BankAccountDetails.js +7 -0
- package/lib/models/BankAccountDetailsCA.js +12 -0
- package/lib/models/BankAccountDetailsGB.js +10 -0
- package/lib/models/BankAccountDetailsIBAN.js +10 -0
- package/lib/models/BankAccountDetailsOTHER.js +16 -0
- package/lib/models/BankAccountDetailsUS.js +14 -0
- package/lib/models/BankAccountType.js +8 -0
- package/lib/models/BankingAlias.js +37 -0
- package/lib/models/BankingAliasIBAN.js +27 -0
- package/lib/models/Billing.js +14 -0
- package/lib/models/BinData.js +16 -0
- package/lib/models/Birthplace.js +10 -0
- package/lib/models/BrowserInfo.js +15 -0
- package/lib/models/Card.js +19 -0
- package/lib/models/CardInfo.js +32 -0
- package/lib/models/CardPreAuthorization.js +144 -0
- package/lib/models/CardRegistration.js +29 -0
- package/lib/models/CardValidation.js +19 -0
- package/lib/models/CategorizeUserLegal.js +15 -0
- package/lib/models/CategorizeUserNatural.js +18 -0
- package/lib/models/Check.js +13 -0
- package/lib/models/CheckData.js +8 -0
- package/lib/models/Client.js +62 -0
- package/lib/models/ClientWallet.js +28 -0
- package/lib/models/Conversion.js +19 -0
- package/lib/models/ConversionRate.js +10 -0
- package/lib/models/CountryAuthorization.js +12 -0
- package/lib/models/DebitedBankAccount.js +15 -0
- package/lib/models/DeclaredUbo.js +29 -0
- package/lib/models/DeclaredUboStatus.js +17 -0
- package/lib/models/Deposit.js +29 -0
- package/lib/models/Dispute.js +46 -0
- package/lib/models/DisputeDocument.js +10 -0
- package/lib/models/DisputeDocumentPage.js +12 -0
- package/lib/models/DisputeReason.js +11 -0
- package/lib/models/Document.js +12 -0
- package/lib/models/DocumentPageConsult.js +17 -0
- package/lib/models/EMoney.js +30 -0
- package/lib/models/EntityBase.js +70 -0
- package/lib/models/Hook.js +19 -0
- package/lib/models/IdempotencyResponse.js +11 -0
- package/lib/models/IdentityVerification.js +12 -0
- package/lib/models/KycDocument.js +11 -0
- package/lib/models/KycDocumentStatus.js +7 -0
- package/lib/models/KycDocumentType.js +7 -0
- package/lib/models/KycPage.js +12 -0
- package/lib/models/LegalPersonType.js +7 -0
- package/lib/models/LegalRepresentative.js +16 -0
- package/lib/models/Mandate.js +69 -0
- package/lib/models/MandateStatus.js +7 -0
- package/lib/models/Money.js +16 -0
- package/lib/models/PayByBankSupportedBank.js +7 -0
- package/lib/models/PayIn.js +36 -0
- package/lib/models/PayInExecutionDetails.js +7 -0
- package/lib/models/PayInExecutionDetailsBankingAlias.js +19 -0
- package/lib/models/PayInExecutionDetailsDirect.js +29 -0
- package/lib/models/PayInExecutionDetailsWeb.js +40 -0
- package/lib/models/PayInExecutionType.js +5 -0
- package/lib/models/PayInIntent.js +20 -0
- package/lib/models/PayInIntentSplit.js +14 -0
- package/lib/models/PayInIntentSplits.js +7 -0
- package/lib/models/PayInPaymentDetails.js +7 -0
- package/lib/models/PayInPaymentDetailsApplePay.js +19 -0
- package/lib/models/PayInPaymentDetailsBancontact.js +13 -0
- package/lib/models/PayInPaymentDetailsBankWire.js +23 -0
- package/lib/models/PayInPaymentDetailsBankingAlias.js +18 -0
- package/lib/models/PayInPaymentDetailsBizum.js +23 -0
- package/lib/models/PayInPaymentDetailsBlik.js +17 -0
- package/lib/models/PayInPaymentDetailsCard.js +10 -0
- package/lib/models/PayInPaymentDetailsCardDirect.js +14 -0
- package/lib/models/PayInPaymentDetailsCardWeb.js +28 -0
- package/lib/models/PayInPaymentDetailsDirectDebitDirect.js +22 -0
- package/lib/models/PayInPaymentDetailsDirectDebitWeb.js +13 -0
- package/lib/models/PayInPaymentDetailsGiropay.js +15 -0
- package/lib/models/PayInPaymentDetailsGooglePay.js +35 -0
- package/lib/models/PayInPaymentDetailsIdeal.js +25 -0
- package/lib/models/PayInPaymentDetailsKlarna.js +36 -0
- package/lib/models/PayInPaymentDetailsMbway.js +20 -0
- package/lib/models/PayInPaymentDetailsMultibanco.js +14 -0
- package/lib/models/PayInPaymentDetailsPayByBank.js +71 -0
- package/lib/models/PayInPaymentDetailsPayPal.js +63 -0
- package/lib/models/PayInPaymentDetailsPayconiq.js +23 -0
- package/lib/models/PayInPaymentDetailsPreAuthorized.js +10 -0
- package/lib/models/PayInPaymentDetailsSatispay.js +19 -0
- package/lib/models/PayInPaymentDetailsSwish.js +35 -0
- package/lib/models/PayInPaymentDetailsTwint.js +15 -0
- package/lib/models/PayInPaymentType.js +21 -0
- package/lib/models/PayInRecurringRegistration.js +64 -0
- package/lib/models/PayInTemplateURLOptions.js +10 -0
- package/lib/models/PayOut.js +24 -0
- package/lib/models/PayOutPaymentDetails.js +7 -0
- package/lib/models/PayOutPaymentDetailsBankWire.js +32 -0
- package/lib/models/PayOutPaymentType.js +3 -0
- package/lib/models/PaymentData.js +20 -0
- package/lib/models/PaymentMethodMetadata.js +38 -0
- package/lib/models/PayoutMethods.js +7 -0
- package/lib/models/PendingUserAction.js +16 -0
- package/lib/models/PersonType.js +5 -0
- package/lib/models/PlatformCategorization.js +16 -0
- package/lib/models/PlatformType.js +10 -0
- package/lib/models/Quote.js +11 -0
- package/lib/models/Recipient.js +20 -0
- package/lib/models/RecipientSchema.js +17 -0
- package/lib/models/RecurringPayIn.js +10 -0
- package/lib/models/RecurringPayInCIT.js +32 -0
- package/lib/models/RecurringPayInCurrentState.js +24 -0
- package/lib/models/RecurringPayInMIT.js +27 -0
- package/lib/models/RecurringPayInPut.js +24 -0
- package/lib/models/Refund.js +26 -0
- package/lib/models/RefundReasonDetails.js +10 -0
- package/lib/models/Report.js +54 -0
- package/lib/models/ReportFilter.js +52 -0
- package/lib/models/ReportFilterV2.js +11 -0
- package/lib/models/ReportV2.js +28 -0
- package/lib/models/Repudiation.js +51 -0
- package/lib/models/SecurityInfo.js +12 -0
- package/lib/models/Settlement.js +16 -0
- package/lib/models/SettlementTransfer.js +37 -0
- package/lib/models/Shipping.js +14 -0
- package/lib/models/ShippingAddress.js +25 -0
- package/lib/models/ShippingPreference.js +5 -0
- package/lib/models/Transaction.js +50 -0
- package/lib/models/Transfer.js +13 -0
- package/lib/models/Ubo.js +19 -0
- package/lib/models/UboDeclaration.js +42 -0
- package/lib/models/UboDeclarationRefusedReasonType.js +23 -0
- package/lib/models/UboDeclarationStatus.js +26 -0
- package/lib/models/UboRefusedReasonType.js +14 -0
- package/lib/models/User.js +66 -0
- package/lib/models/UserCategory.js +5 -0
- package/lib/models/UserConsent.js +7 -0
- package/lib/models/UserDataFormatValidation.js +7 -0
- package/lib/models/UserEnrollmentResult.js +7 -0
- package/lib/models/UserLegal.js +65 -0
- package/lib/models/UserLegalOwner.js +66 -0
- package/lib/models/UserLegalPayer.js +66 -0
- package/lib/models/UserLegalSca.js +57 -0
- package/lib/models/UserNatural.js +51 -0
- package/lib/models/UserNaturalCapacity.js +13 -0
- package/lib/models/UserNaturalOwner.js +55 -0
- package/lib/models/UserNaturalPayer.js +55 -0
- package/lib/models/UserNaturalPut.js +49 -0
- package/lib/models/UserNaturalSca.js +56 -0
- package/lib/models/VirtualAccount.js +22 -0
- package/lib/models/Wallet.js +32 -0
- package/lib/models/index.js +102 -0
- package/lib/service.js +14 -0
- package/lib/services/BankAccounts.js +31 -0
- package/lib/services/BankingAliases.js +137 -0
- package/lib/services/CardPreAuthorizations.js +75 -0
- package/lib/services/CardRegistrations.js +64 -0
- package/lib/services/Cards.js +168 -0
- package/lib/services/Clients.js +196 -0
- package/lib/services/Conversions.js +155 -0
- package/lib/services/Deposits.js +109 -0
- package/lib/services/DisputeDocuments.js +65 -0
- package/lib/services/Disputes.js +409 -0
- package/lib/services/Events.js +24 -0
- package/lib/services/Hooks.js +81 -0
- package/lib/services/Idempotency.js +17 -0
- package/lib/services/IdentityVerifications.js +48 -0
- package/lib/services/KycDocuments.js +66 -0
- package/lib/services/Mandates.js +161 -0
- package/lib/services/OptionsHelper.js +20 -0
- package/lib/services/PayIns.js +690 -0
- package/lib/services/PayOuts.js +110 -0
- package/lib/services/Recipients.js +117 -0
- package/lib/services/Refunds.js +29 -0
- package/lib/services/Regulatory.js +29 -0
- package/lib/services/Reports.js +61 -0
- package/lib/services/ReportsV2.js +55 -0
- package/lib/services/Repudiations.js +33 -0
- package/lib/services/Responses.js +23 -0
- package/lib/services/Settlements.js +74 -0
- package/lib/services/Transfers.js +87 -0
- package/lib/services/UboDeclarations.js +135 -0
- package/lib/services/Users.js +831 -0
- package/lib/services/VirtualAccounts.js +99 -0
- package/lib/services/Wallets.js +85 -0
- package/lib/services/index.js +34 -0
- package/lib/utils.js +36 -0
- package/package.json +40 -0
- package/test/TestKycPageFile.png +0 -0
- package/test/helpers.js +1431 -0
- package/test/main.js +10 -0
- package/test/mocha.opts +3 -0
- package/test/services/BankAccounts.js +46 -0
- package/test/services/BankingAliases.js +89 -0
- package/test/services/CardPreAuthorizations.js +70 -0
- package/test/services/CardRegistrations.js +239 -0
- package/test/services/Cards.js +54 -0
- package/test/services/Clients.js +235 -0
- package/test/services/Conversions.js +308 -0
- package/test/services/Deposits.js +148 -0
- package/test/services/Disputes.js +542 -0
- package/test/services/EMoney.js +54 -0
- package/test/services/Events.js +143 -0
- package/test/services/Hooks.js +109 -0
- package/test/services/Idempotency.js +46 -0
- package/test/services/IdentityVerifications.js +68 -0
- package/test/services/KycDocuments.js +73 -0
- package/test/services/Mandates.js +256 -0
- package/test/services/PayIns.js +2553 -0
- package/test/services/PayOuts.js +106 -0
- package/test/services/RateLimit.js +48 -0
- package/test/services/Recipients.js +234 -0
- package/test/services/Refunds.js +123 -0
- package/test/services/Regulatory.js +45 -0
- package/test/services/Reports.js +114 -0
- package/test/services/ReportsV2.js +306 -0
- package/test/services/Repudiations.js +22 -0
- package/test/services/Settlements.js +58 -0
- package/test/services/Tokens.js +55 -0
- package/test/services/Transfers.js +137 -0
- package/test/services/UboDeclarations.js +135 -0
- package/test/services/Users.js +1303 -0
- package/test/services/VirtualAccounts.js +105 -0
- package/test/services/Wallets.js +132 -0
- package/test/settlement_sample.csv +8 -0
- package/typings/base.d.ts +308 -0
- package/typings/enums.d.ts +204 -0
- package/typings/index.d.ts +885 -0
- package/typings/index.test-d.ts +1535 -0
- package/typings/models/address.d.ts +70 -0
- package/typings/models/bankAccount.d.ts +235 -0
- package/typings/models/bankingAlias.d.ts +97 -0
- package/typings/models/billing.d.ts +42 -0
- package/typings/models/birthplace.d.ts +9 -0
- package/typings/models/card.d.ts +119 -0
- package/typings/models/cardPreauthorization.d.ts +157 -0
- package/typings/models/cardRegistration.d.ts +83 -0
- package/typings/models/cardValidation.d.ts +125 -0
- package/typings/models/client.d.ts +208 -0
- package/typings/models/conversion.d.ts +225 -0
- package/typings/models/conversionRate.d.ts +29 -0
- package/typings/models/countryAuthorization.d.ts +16 -0
- package/typings/models/deposit.d.ts +104 -0
- package/typings/models/dispute.d.ts +116 -0
- package/typings/models/disputeDocument.d.ts +119 -0
- package/typings/models/entityBase.d.ts +9 -0
- package/typings/models/event.d.ts +142 -0
- package/typings/models/hook.d.ts +39 -0
- package/typings/models/idempotency.d.ts +36 -0
- package/typings/models/identityVerification.d.ts +98 -0
- package/typings/models/kycDocument.d.ts +114 -0
- package/typings/models/mandate.d.ts +93 -0
- package/typings/models/money.d.ts +45 -0
- package/typings/models/payIn.d.ts +3742 -0
- package/typings/models/payOut.d.ts +144 -0
- package/typings/models/recipient.d.ts +242 -0
- package/typings/models/refund.d.ts +92 -0
- package/typings/models/report.d.ts +234 -0
- package/typings/models/reportV2.d.ts +145 -0
- package/typings/models/repudiation.d.ts +26 -0
- package/typings/models/securityInfo.d.ts +12 -0
- package/typings/models/settlement.d.ts +50 -0
- package/typings/models/settlementTransfer.d.ts +37 -0
- package/typings/models/shipping.d.ts +37 -0
- package/typings/models/shippingAddress.d.ts +15 -0
- package/typings/models/transaction.d.ts +85 -0
- package/typings/models/transfer.d.ts +119 -0
- package/typings/models/uboDeclaration.d.ts +100 -0
- package/typings/models/user.d.ts +1001 -0
- package/typings/models/virtualAccount.d.ts +182 -0
- package/typings/models/wallet.d.ts +46 -0
- package/typings/models.d.ts +74 -0
- package/typings/services/BankAccounts.d.ts +12 -0
- package/typings/services/BankingAliases.d.ts +51 -0
- package/typings/services/CardPreauthorizations.d.ts +44 -0
- package/typings/services/CardRegistrations.d.ts +43 -0
- package/typings/services/Cards.d.ts +80 -0
- package/typings/services/Clients.d.ts +77 -0
- package/typings/services/Conversions.d.ts +23 -0
- package/typings/services/Deposits.d.ts +20 -0
- package/typings/services/DisputeDocuments.d.ts +27 -0
- package/typings/services/Disputes.d.ts +169 -0
- package/typings/services/Events.d.ts +11 -0
- package/typings/services/Hooks.d.ts +33 -0
- package/typings/services/Idempotency.d.ts +7 -0
- package/typings/services/IdentityVerifications.d.ts +29 -0
- package/typings/services/KycDocuments.d.ts +38 -0
- package/typings/services/Mandates.d.ts +59 -0
- package/typings/services/OptionsHelper.d.ts +11 -0
- package/typings/services/PayIns.d.ts +319 -0
- package/typings/services/PayOuts.d.ts +34 -0
- package/typings/services/Recipients.d.ts +55 -0
- package/typings/services/Refunds.d.ts +12 -0
- package/typings/services/Regulatory.d.ts +17 -0
- package/typings/services/Reports.d.ts +26 -0
- package/typings/services/ReportsV2.d.ts +26 -0
- package/typings/services/Repudiations.d.ts +12 -0
- package/typings/services/Responses.d.ts +10 -0
- package/typings/services/Settlements.d.ts +28 -0
- package/typings/services/Transfers.d.ts +38 -0
- package/typings/services/UboDeclarations.d.ts +81 -0
- package/typings/services/Users.d.ts +308 -0
- package/typings/services/VirtualAccounts.d.ts +42 -0
- package/typings/services/Wallets.d.ts +36 -0
- package/typings/tsconfig.json +20 -0
- package/typings/tslint.json +11 -0
- package/typings/types.d.ts +652 -0
|
@@ -0,0 +1,1303 @@
|
|
|
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 sinon = require('sinon');
|
|
7
|
+
var api = require('../main');
|
|
8
|
+
|
|
9
|
+
var helpers = require('../helpers');
|
|
10
|
+
|
|
11
|
+
var UserLegal = require('../../lib/models/UserLegal');
|
|
12
|
+
var UserLegalSca = require('../../lib/models/UserLegalSca');
|
|
13
|
+
var UserNatural = require('../../lib/models/UserNatural');
|
|
14
|
+
var UserNaturalSca = require('../../lib/models/UserNaturalSca');
|
|
15
|
+
var Address = require('../../lib/models/Address');
|
|
16
|
+
var PersonType = require('../../lib/models/PersonType');
|
|
17
|
+
var BankAccount = require('../../lib/models/BankAccount');
|
|
18
|
+
var BankAccountDetailsIBAN = require('../../lib/models/BankAccountDetailsIBAN');
|
|
19
|
+
var BankAccountDetailsGB = require('../../lib/models/BankAccountDetailsGB');
|
|
20
|
+
var KycDocument = require('../../lib/models/KycDocument');
|
|
21
|
+
var KycDocumentStatus = require('../../lib/models/KycDocumentStatus');
|
|
22
|
+
var KycDocumentType = require('../../lib/models/KycDocumentType');
|
|
23
|
+
var UboDeclaration = require('../../lib/models/UboDeclaration');
|
|
24
|
+
var Ubo = require('../../lib/models/Ubo');
|
|
25
|
+
var UboDeclarationStatus = require('../../lib/models/UboDeclarationStatus');
|
|
26
|
+
var UserNaturalPut = require('../../lib/models/UserNaturalPut');
|
|
27
|
+
var CategorizeUserNatural = require('../../lib/models/CategorizeUserNatural');
|
|
28
|
+
var CategorizeUserLegal = require('../../lib/models/CategorizeUserLegal');
|
|
29
|
+
|
|
30
|
+
describe('Users', function() {
|
|
31
|
+
var john = new UserNatural(helpers.data.getUserNatural());
|
|
32
|
+
var johnScaOwner = new UserNaturalSca(helpers.data.getUserNaturalScaOwner());
|
|
33
|
+
var johnScaPayer = new UserNaturalSca(helpers.data.getUserNaturalScaPayer());
|
|
34
|
+
var matrix = new UserLegal(helpers.data.getUserLegal());
|
|
35
|
+
var matrixScaOwner = new UserLegalSca(helpers.data.getUserLegalScaOwner());
|
|
36
|
+
var matrixScaPayer = new UserLegalSca(helpers.data.getUserLegalScaPayer());
|
|
37
|
+
|
|
38
|
+
var johnPayer = new UserNatural(helpers.data.getUserNaturalPayer());
|
|
39
|
+
var johnOwner = new UserNatural(helpers.data.getUserNaturalOwner());
|
|
40
|
+
|
|
41
|
+
var matrixPayer = new UserLegal(helpers.data.getUserLegalPayer());
|
|
42
|
+
var matrixOwner = new UserLegal(helpers.data.getUserLegalOwner());
|
|
43
|
+
|
|
44
|
+
before(function(done){
|
|
45
|
+
api.Users.create(john).then(function(data){
|
|
46
|
+
john = data;
|
|
47
|
+
api.Users.create(matrix).then(function(data){
|
|
48
|
+
matrix = data;
|
|
49
|
+
done();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
before(function(done){
|
|
55
|
+
api.Users.create(johnPayer).then(function(data){
|
|
56
|
+
johnPayer = data;
|
|
57
|
+
api.Users.create(johnOwner).then(function(data){
|
|
58
|
+
johnOwner = data;
|
|
59
|
+
done();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
before(function(done){
|
|
65
|
+
api.Users.create(matrixPayer).then(function(data){
|
|
66
|
+
matrixPayer = data;
|
|
67
|
+
api.Users.create(matrixOwner).then(function(data){
|
|
68
|
+
matrixOwner = data;
|
|
69
|
+
done();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
before(function(done){
|
|
75
|
+
api.Users.create(johnScaOwner).then(function(data, err){
|
|
76
|
+
johnScaOwner = data;
|
|
77
|
+
done();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
before(function(done){
|
|
82
|
+
api.Users.create(matrixScaOwner).then(function(data, err){
|
|
83
|
+
matrixScaOwner = data;
|
|
84
|
+
done();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
before(function(done){
|
|
89
|
+
api.Users.create(johnScaPayer).then(function(data, err){
|
|
90
|
+
johnScaPayer = data;
|
|
91
|
+
done();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
before(function(done){
|
|
96
|
+
api.Users.create(matrixScaPayer).then(function(data, err){
|
|
97
|
+
matrixScaPayer = data;
|
|
98
|
+
done();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('Create Natural', function(){
|
|
103
|
+
expect(john.Id).not.to.be.undefined;
|
|
104
|
+
expect(john.PersonType).to.equal(PersonType.Natural);
|
|
105
|
+
expect(john.TermsAndConditionsAccepted).to.be.true;
|
|
106
|
+
expect(john.UserCategory).to.equal('OWNER');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('Create Natural SCA', function(){
|
|
110
|
+
expect(johnScaOwner.Id).not.to.be.undefined;
|
|
111
|
+
expect(johnScaOwner.PersonType).to.equal(PersonType.Natural);
|
|
112
|
+
expect(johnScaOwner.TermsAndConditionsAccepted).to.be.true;
|
|
113
|
+
expect(johnScaOwner.UserCategory).to.equal('OWNER');
|
|
114
|
+
expect(johnScaOwner.PendingUserAction).not.to.be.undefined;
|
|
115
|
+
expect(johnScaOwner.PhoneNumber).not.to.be.undefined;
|
|
116
|
+
expect(johnScaOwner.PhoneNumberCountry).not.to.be.undefined;
|
|
117
|
+
expect(johnScaOwner.UserStatus).to.equal('PENDING_USER_ACTION');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('Create Legal', function() {
|
|
121
|
+
expect(matrix.Id).not.to.be.undefined;
|
|
122
|
+
expect(matrix.PersonType).to.equal(PersonType.Legal);
|
|
123
|
+
expect(matrix.TermsAndConditionsAccepted).to.be.true;
|
|
124
|
+
expect(matrix.UserCategory).to.equal('OWNER');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('Create Legal SCA', function() {
|
|
128
|
+
expect(matrixScaOwner.Id).not.to.be.undefined;
|
|
129
|
+
expect(matrixScaOwner.PersonType).to.equal(PersonType.Legal);
|
|
130
|
+
expect(matrixScaOwner.TermsAndConditionsAccepted).to.be.true;
|
|
131
|
+
expect(matrixScaOwner.UserCategory).to.equal('OWNER');
|
|
132
|
+
expect(matrixScaOwner.PendingUserAction).not.to.be.undefined;
|
|
133
|
+
expect(matrixScaOwner.LegalRepresentative).not.to.be.undefined;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('Create Natural Payer', function(){
|
|
137
|
+
expect(johnPayer.Id).not.to.be.undefined;
|
|
138
|
+
expect(johnPayer.PersonType).to.equal(PersonType.Natural);
|
|
139
|
+
expect(johnPayer.UserCategory).to.equal('PAYER');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('Create Natural Owner', function(){
|
|
143
|
+
expect(johnOwner.Id).not.to.be.undefined;
|
|
144
|
+
expect(johnOwner.PersonType).to.equal(PersonType.Natural);
|
|
145
|
+
expect(johnOwner.UserCategory).to.equal('OWNER');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('Create Legal Payer', function() {
|
|
149
|
+
expect(matrixPayer.Id).not.to.be.undefined;
|
|
150
|
+
expect(matrixPayer.PersonType).to.equal(PersonType.Legal);
|
|
151
|
+
expect(matrixPayer.UserCategory).to.equal('PAYER');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('Create Legal Owner', function() {
|
|
155
|
+
expect(matrixOwner.Id).not.to.be.undefined;
|
|
156
|
+
expect(matrixOwner.PersonType).to.equal(PersonType.Legal);
|
|
157
|
+
expect(matrixOwner.UserCategory).to.equal('OWNER');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('Create Legal Fails If Required Properties Not Provided', function(done){
|
|
161
|
+
var user = new UserLegal();
|
|
162
|
+
|
|
163
|
+
api.Users.create(user, function(data){
|
|
164
|
+
expect(data.errors).to.exist;
|
|
165
|
+
done();
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('Get Natural', function() {
|
|
170
|
+
var john1, john2;
|
|
171
|
+
before(function(done){
|
|
172
|
+
Promise.all([api.Users.get(john.Id), api.Users.getNatural(john.Id)]).then(function(res){
|
|
173
|
+
john1 = res[0];
|
|
174
|
+
john2 = res[1];
|
|
175
|
+
done();
|
|
176
|
+
})
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('John should be the same', function(){
|
|
180
|
+
expect(_.isMatch(john1, _.omit(john.data, 'Address'))).to.be.true;
|
|
181
|
+
expect(_.isMatch(john2, _.omit(john.data, 'Address'))).to.be.true;
|
|
182
|
+
expect(john1.TermsAndConditionsAccepted).to.be.true;
|
|
183
|
+
expect(john2.TermsAndConditionsAccepted).to.be.true;
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('Fails for Legal User', function(done) {
|
|
187
|
+
api.Users.getLegal(john.Id, function(data) {
|
|
188
|
+
expect(data.errors).to.exist;
|
|
189
|
+
done();
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe('Get Natural SCA', function() {
|
|
195
|
+
var john1, john2;
|
|
196
|
+
before(function (done) {
|
|
197
|
+
Promise.all(
|
|
198
|
+
[api.Users.getSca(johnScaOwner.Id),
|
|
199
|
+
api.Users.getNaturalSca(johnScaOwner.Id)
|
|
200
|
+
]).then(function (res) {
|
|
201
|
+
john1 = res[0];
|
|
202
|
+
john2 = res[1];
|
|
203
|
+
done();
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('John SCA should be the same', function(){
|
|
208
|
+
expect(_.isMatch(john1, _.omit(john.data, 'Address'))).to.be.true;
|
|
209
|
+
expect(_.isMatch(john2, _.omit(john.data, 'Address'))).to.be.true;
|
|
210
|
+
expect(john1.TermsAndConditionsAccepted).to.eq(john2.TermsAndConditionsAccepted);
|
|
211
|
+
expect(john1.Id).to.eq(john2.Id);
|
|
212
|
+
expect(john1.UserStatus).to.eq(john2.UserStatus);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe('Get Legal SCA', function() {
|
|
217
|
+
var matrix1, matrix2;
|
|
218
|
+
before(function (done) {
|
|
219
|
+
Promise.all(
|
|
220
|
+
[api.Users.getSca(matrixScaOwner.Id),
|
|
221
|
+
api.Users.getLegalSca(matrixScaOwner.Id)
|
|
222
|
+
]).then(function (res) {
|
|
223
|
+
matrix1 = res[0];
|
|
224
|
+
matrix2 = res[1];
|
|
225
|
+
done();
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('Matrix SCA should be the same', function(){
|
|
230
|
+
expect(matrix1.TermsAndConditionsAccepted).to.eq(matrix2.TermsAndConditionsAccepted);
|
|
231
|
+
expect(matrix1.Id).to.eq(matrix2.Id);
|
|
232
|
+
expect(matrix1.CompanyNumber).to.eq(matrix2.CompanyNumber);
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
describe('Get Natural Payer', function() {
|
|
237
|
+
var johnPayer1, johnPayer2;
|
|
238
|
+
before(function(done){
|
|
239
|
+
Promise.all([api.Users.get(johnPayer.Id), api.Users.getNatural(johnPayer.Id)]).then(function(res){
|
|
240
|
+
johnPayer1 = res[0];
|
|
241
|
+
johnPayer2 = res[1];
|
|
242
|
+
done();
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('John Payer should be the same', function(){
|
|
247
|
+
expect(johnPayer1.Id).to.equal(johnPayer.Id);
|
|
248
|
+
expect(johnPayer2.Id).to.equal(johnPayer.Id);
|
|
249
|
+
|
|
250
|
+
expect(johnPayer1.UserCategory).to.equal('PAYER');
|
|
251
|
+
expect(johnPayer2.UserCategory).to.equal('PAYER');
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
describe('Get Natural Owner', function() {
|
|
256
|
+
var johnOwner1, johnOwner2;
|
|
257
|
+
before(function(done){
|
|
258
|
+
Promise.all([api.Users.get(johnOwner.Id), api.Users.getNatural(johnOwner.Id)]).then(function(res){
|
|
259
|
+
johnOwner1 = res[0];
|
|
260
|
+
johnOwner2 = res[1];
|
|
261
|
+
done();
|
|
262
|
+
})
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('John Owner should be the same', function(){
|
|
266
|
+
expect(johnOwner1.Id).to.equal(johnOwner.Id);
|
|
267
|
+
expect(johnOwner2.Id).to.equal(johnOwner.Id);
|
|
268
|
+
|
|
269
|
+
expect(johnOwner1.UserCategory).to.equal('OWNER');
|
|
270
|
+
expect(johnOwner2.UserCategory).to.equal('OWNER');
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
describe('Get Legal', function(){
|
|
275
|
+
var matrix1, matrix2;
|
|
276
|
+
before(function(done){
|
|
277
|
+
Promise.all([api.Users.get(matrix.Id), api.Users.getLegal(matrix.Id)]).then(function(res){
|
|
278
|
+
matrix1 = res[0];
|
|
279
|
+
matrix2 = res[1];
|
|
280
|
+
done();
|
|
281
|
+
})
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it('Matrix should be the same', function(){
|
|
285
|
+
expect(_.isMatch(matrix1, _.omit(matrix.data, 'HeadquartersAddress', 'LegalRepresentativeAddress'))).to.be.true;
|
|
286
|
+
expect(_.isMatch(matrix2, _.omit(matrix.data, 'HeadquartersAddress', 'LegalRepresentativeAddress'))).to.be.true;
|
|
287
|
+
expect(matrix1.TermsAndConditionsAccepted).to.be.true;
|
|
288
|
+
expect(matrix2.TermsAndConditionsAccepted).to.be.true;
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('Fails for Natural User', function(done) {
|
|
292
|
+
api.Users.getNatural(matrix.Id, function(data) {
|
|
293
|
+
expect(data.errors).to.exist;
|
|
294
|
+
done();
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
describe('Get Legal Payer', function() {
|
|
300
|
+
var matrixPayer1, matrixPayer2;
|
|
301
|
+
before(function(done){
|
|
302
|
+
Promise.all([api.Users.get(matrixPayer.Id), api.Users.getLegal(matrixPayer.Id)]).then(function(res){
|
|
303
|
+
matrixPayer1 = res[0];
|
|
304
|
+
matrixPayer2 = res[1];
|
|
305
|
+
done();
|
|
306
|
+
})
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it('Legal Payer should be the same', function(){
|
|
310
|
+
expect(matrixPayer1.Id).to.equal(matrixPayer.Id);
|
|
311
|
+
expect(matrixPayer2.Id).to.equal(matrixPayer.Id);
|
|
312
|
+
|
|
313
|
+
expect(matrixPayer1.UserCategory).to.equal('PAYER');
|
|
314
|
+
expect(matrixPayer2.UserCategory).to.equal('PAYER');
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
describe('Get Legal Owner', function() {
|
|
319
|
+
var matrixOwner1, matrixOwner2;
|
|
320
|
+
before(function(done){
|
|
321
|
+
Promise.all([api.Users.get(matrixOwner.Id), api.Users.getLegal(matrixOwner.Id)]).then(function(res){
|
|
322
|
+
matrixOwner1 = res[0];
|
|
323
|
+
matrixOwner2 = res[1];
|
|
324
|
+
done();
|
|
325
|
+
})
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('Legal Owner should be the same', function(){
|
|
329
|
+
expect(matrixOwner1.Id).to.equal(matrixOwner.Id);
|
|
330
|
+
expect(matrixOwner2.Id).to.equal(matrixOwner.Id);
|
|
331
|
+
|
|
332
|
+
expect(matrixOwner1.UserCategory).to.equal('OWNER');
|
|
333
|
+
expect(matrixOwner2.UserCategory).to.equal('OWNER');
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
describe('Save Natural', function(){
|
|
338
|
+
var updatedJohn;
|
|
339
|
+
before(function(done){
|
|
340
|
+
john.LastName = john.LastName + " - CHANGED";
|
|
341
|
+
john.TermsAndConditionsAccepted = true;
|
|
342
|
+
|
|
343
|
+
api.Users.update(john).then(function(){
|
|
344
|
+
api.Users.get(john.Id).then(function(user){
|
|
345
|
+
updatedJohn = user;
|
|
346
|
+
done();
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it('Models should be the same', function() {
|
|
352
|
+
expect(_.isMatch(john.LastName, updatedJohn.LastName)).to.be.true
|
|
353
|
+
expect(updatedJohn.TermsAndConditionsAccepted).to.be.true;
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
describe('Save Natural SCA', function(){
|
|
358
|
+
var updatedJohn;
|
|
359
|
+
const changedLastName = johnScaOwner.LastName + " - CHANGED";
|
|
360
|
+
|
|
361
|
+
before(function(done){
|
|
362
|
+
johnScaOwner.LastName = changedLastName;
|
|
363
|
+
|
|
364
|
+
api.Users.updateSca(johnScaOwner).then(function(){
|
|
365
|
+
api.Users.getSca(johnScaOwner.Id).then(function(user){
|
|
366
|
+
updatedJohn = user;
|
|
367
|
+
done();
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('Models should be the same', function() {
|
|
373
|
+
expect(_.isMatch(johnScaOwner.LastName, updatedJohn.LastName)).to.be.true;
|
|
374
|
+
expect(updatedJohn.LastName).to.be.eq(changedLastName);
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
describe('Save Legal SCA', function(){
|
|
379
|
+
var updatedMatrix;
|
|
380
|
+
const changedName = matrixScaOwner.Name + " - CHANGED";
|
|
381
|
+
|
|
382
|
+
before(function(done){
|
|
383
|
+
matrixScaOwner.Name = changedName;
|
|
384
|
+
|
|
385
|
+
api.Users.updateSca(matrixScaOwner).then(function(){
|
|
386
|
+
api.Users.getSca(matrixScaOwner.Id).then(function(user){
|
|
387
|
+
updatedMatrix = user;
|
|
388
|
+
done();
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it('Models should be the same', function() {
|
|
394
|
+
expect(_.isMatch(matrixScaOwner.Name, updatedMatrix.Name)).to.be.true;
|
|
395
|
+
expect(updatedMatrix.Name).to.be.eq(changedName);
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
describe('Categorize Natural SCA', function(){
|
|
400
|
+
var updatedUser;
|
|
401
|
+
|
|
402
|
+
before(function (done) {
|
|
403
|
+
var categorizeNatural = new CategorizeUserNatural(
|
|
404
|
+
{
|
|
405
|
+
Id: johnScaPayer.Id,
|
|
406
|
+
UserCategory: 'OWNER',
|
|
407
|
+
TermsAndConditionsAccepted: true,
|
|
408
|
+
Birthday: 188301600,
|
|
409
|
+
Nationality: 'FR',
|
|
410
|
+
CountryOfResidence: 'FR',
|
|
411
|
+
ScaContext: 'USER_PRESENT'
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
api.Users.categorize(categorizeNatural).then(function(data){
|
|
416
|
+
updatedUser = data;
|
|
417
|
+
done();
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
it('Category should be OWNER', function() {
|
|
422
|
+
expect(updatedUser.UserCategory).to.be.eq('OWNER');
|
|
423
|
+
expect(updatedUser.Birthday).to.not.be.undefined;
|
|
424
|
+
expect(updatedUser.Nationality).to.not.be.undefined;
|
|
425
|
+
expect(updatedUser.CountryOfResidence).to.not.be.undefined;
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
describe('Categorize Legal SCA', function(){
|
|
430
|
+
var updatedUser;
|
|
431
|
+
|
|
432
|
+
before(function (done) {
|
|
433
|
+
var categorizeLegal = new CategorizeUserLegal(
|
|
434
|
+
{
|
|
435
|
+
Id: matrixScaPayer.Id,
|
|
436
|
+
UserCategory: 'OWNER',
|
|
437
|
+
TermsAndConditionsAccepted: true,
|
|
438
|
+
LegalRepresentative: {
|
|
439
|
+
FirstName: 'John SCA',
|
|
440
|
+
LastName: 'Doe SCA Review',
|
|
441
|
+
Email: 'john.doe.sca@sample.org',
|
|
442
|
+
Birthday: 188301600,
|
|
443
|
+
Nationality: 'FR',
|
|
444
|
+
CountryOfResidence: 'FR',
|
|
445
|
+
PhoneNumber: '+33611111111',
|
|
446
|
+
PhoneNumberCountry: 'FR'
|
|
447
|
+
},
|
|
448
|
+
HeadquartersAddress: {
|
|
449
|
+
"AddressLine1": "4101 Reservoir Rd NW",
|
|
450
|
+
"AddressLine2": "address line 2",
|
|
451
|
+
"City": "Washington",
|
|
452
|
+
"Region": "District of Columbia",
|
|
453
|
+
"PostalCode": "20007",
|
|
454
|
+
"Country": "US"
|
|
455
|
+
},
|
|
456
|
+
CompanyNumber: "123456789",
|
|
457
|
+
ScaContext: 'USER_PRESENT'
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
api.Users.categorize(categorizeLegal).then(function(data){
|
|
462
|
+
updatedUser = data;
|
|
463
|
+
done();
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
it('Category should be OWNER', function() {
|
|
468
|
+
expect(updatedUser.UserCategory).to.be.eq('OWNER');
|
|
469
|
+
expect(updatedUser.HeadquartersAddress).to.not.be.undefined;
|
|
470
|
+
expect(updatedUser.LegalRepresentative).to.not.be.undefined;
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
describe('Enroll to SCA', function(){
|
|
475
|
+
var enrollmentResult;
|
|
476
|
+
|
|
477
|
+
before(function (done) {
|
|
478
|
+
api.Users.enroll(johnOwner.Id).then(function(data){
|
|
479
|
+
enrollmentResult = data;
|
|
480
|
+
done();
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it('Category should be OWNER', function() {
|
|
485
|
+
expect(enrollmentResult.PendingUserAction.RedirectUrl).to.not.be.undefined;
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
describe('Manage consent', function(){
|
|
490
|
+
var consentResult;
|
|
491
|
+
|
|
492
|
+
before(function (done) {
|
|
493
|
+
api.Users.enroll(johnOwner.Id).then(function(data){
|
|
494
|
+
api.Users.manageConsent(johnOwner.Id).then(function(data){
|
|
495
|
+
consentResult = data;
|
|
496
|
+
done();
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
it('Correct result expected', function() {
|
|
502
|
+
expect(consentResult.PendingUserAction.RedirectUrl).to.not.be.undefined;
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
describe('Save Natural Payer to Owner', function(){
|
|
507
|
+
var updatedJohn;
|
|
508
|
+
before(function(done){
|
|
509
|
+
johnPayer.Name += ' - CHANGED';
|
|
510
|
+
johnPayer.TermsAndConditionsAccepted = true;
|
|
511
|
+
johnPayer.UserCategory = 'OWNER';
|
|
512
|
+
|
|
513
|
+
//when changing the UserCategory, we need to add the missing fields for the new Category
|
|
514
|
+
johnPayer.CountryOfResidence = 'FR';
|
|
515
|
+
johnPayer.Birthday = 188301600;
|
|
516
|
+
johnPayer.Nationality = 'FR';
|
|
517
|
+
|
|
518
|
+
api.Users.update(johnPayer).then(function(){
|
|
519
|
+
api.Users.get(johnPayer.Id).then(function(user){
|
|
520
|
+
updatedJohn = user;
|
|
521
|
+
done();
|
|
522
|
+
});
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it('Models should be the same', function() {
|
|
527
|
+
expect(_.isMatch(johnPayer.LastName, updatedJohn.LastName)).to.be.true
|
|
528
|
+
expect(updatedJohn.TermsAndConditionsAccepted).to.be.true;
|
|
529
|
+
expect(updatedJohn.UserCategory).to.equal('OWNER');
|
|
530
|
+
});
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
describe('Save Legal', function(){
|
|
534
|
+
var updatedMatrix;
|
|
535
|
+
before(function(done){
|
|
536
|
+
matrix.Name += ' - CHANGED';
|
|
537
|
+
matrix.TermsAndConditionsAccepted = true;
|
|
538
|
+
|
|
539
|
+
api.Users.update(matrix).then(function(){
|
|
540
|
+
api.Users.get(matrix.Id).then(function(user){
|
|
541
|
+
updatedMatrix = user;
|
|
542
|
+
done();
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
it('Models should be the same', function(){
|
|
548
|
+
expect(_.isMatch(matrix.Name, updatedMatrix.Name)).to.be.true;
|
|
549
|
+
expect(updatedMatrix.TermsAndConditionsAccepted).to.be.true;
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
describe('Save Legal Payer to Owner', function(){
|
|
554
|
+
var updatedMatrix;
|
|
555
|
+
before(function(done){
|
|
556
|
+
matrixPayer.Name += ' - CHANGED';
|
|
557
|
+
matrixPayer.TermsAndConditionsAccepted = true;
|
|
558
|
+
matrixPayer.UserCategory = 'OWNER';
|
|
559
|
+
|
|
560
|
+
//when changing the UserCategory, we need to add the missing fields for the new Category
|
|
561
|
+
matrixPayer.HeadquartersAddress = {
|
|
562
|
+
"AddressLine1": "4101 Reservoir Rd NW",
|
|
563
|
+
"AddressLine2": "",
|
|
564
|
+
"City": "Washington",
|
|
565
|
+
"Region": "District of Columbia",
|
|
566
|
+
"PostalCode": "20007",
|
|
567
|
+
"Country": "US"
|
|
568
|
+
};
|
|
569
|
+
matrixPayer.CompanyNumber = 123456789;
|
|
570
|
+
matrixPayer.LegalRepresentativeNationality = 'FR';
|
|
571
|
+
matrixPayer.LegalRepresentativeCountryOfResidence = 'FR';
|
|
572
|
+
matrixPayer.LegalRepresentativeBirthday = 188301600;
|
|
573
|
+
|
|
574
|
+
api.Users.update(matrixPayer).then(function(){
|
|
575
|
+
api.Users.get(matrixPayer.Id).then(function(user){
|
|
576
|
+
updatedMatrix = user;
|
|
577
|
+
done();
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
it('Models should be the same', function(){
|
|
583
|
+
expect(_.isMatch(matrixPayer.Name, updatedMatrix.Name)).to.be.true;
|
|
584
|
+
expect(updatedMatrix.TermsAndConditionsAccepted).to.be.true;
|
|
585
|
+
expect(updatedMatrix.UserCategory).to.equal('OWNER');
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
describe('Close natural', function(){
|
|
590
|
+
var john = new UserNatural(helpers.data.getUserNatural());
|
|
591
|
+
var johnSca = new UserNaturalSca(helpers.data.getUserNaturalScaPayer());
|
|
592
|
+
|
|
593
|
+
var closedJohn, closedJohnSca;
|
|
594
|
+
|
|
595
|
+
before(function (done) {
|
|
596
|
+
// create new UserNatural
|
|
597
|
+
api.Users.create(john).then(function(data){
|
|
598
|
+
john = data;
|
|
599
|
+
// create new UserNaturalSca
|
|
600
|
+
api.Users.create(johnSca).then(function(data){
|
|
601
|
+
johnSca = data;
|
|
602
|
+
// close the UserNatural
|
|
603
|
+
api.Users.close(john).then(function(){
|
|
604
|
+
// close the UserNaturalSca
|
|
605
|
+
api.Users.close(johnSca).then(function (){
|
|
606
|
+
// fetch the closed UserNatural
|
|
607
|
+
api.Users.get(john.Id).then(function(data){
|
|
608
|
+
closedJohn = data;
|
|
609
|
+
// fetch the closed UserNaturalSca
|
|
610
|
+
api.Users.get(johnSca.Id).then(function(data){
|
|
611
|
+
closedJohnSca = data;
|
|
612
|
+
done();
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
it('Status should be CLOSED', function() {
|
|
622
|
+
expect(closedJohn.UserStatus).to.be.eq('CLOSED');
|
|
623
|
+
expect(closedJohnSca.UserStatus).to.be.eq('CLOSED');
|
|
624
|
+
});
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
describe('Close legal', function(){
|
|
628
|
+
var matrix = new UserLegal(helpers.data.getUserLegal());
|
|
629
|
+
var matrixSca = new UserLegalSca(helpers.data.getUserLegalScaPayer());
|
|
630
|
+
|
|
631
|
+
var closedMatrix, closedMatrixSca;
|
|
632
|
+
|
|
633
|
+
before(function (done) {
|
|
634
|
+
// create new UserLegal
|
|
635
|
+
api.Users.create(matrix).then(function(data){
|
|
636
|
+
matrix = data;
|
|
637
|
+
// create new UserLegalSca
|
|
638
|
+
api.Users.create(matrixSca).then(function(data){
|
|
639
|
+
matrixSca = data;
|
|
640
|
+
// close the UserLegal
|
|
641
|
+
api.Users.close(matrix).then(function(){
|
|
642
|
+
// close the UserLegalSca
|
|
643
|
+
api.Users.close(matrixSca).then(function (){
|
|
644
|
+
// fetch the closed UserLegal
|
|
645
|
+
api.Users.get(matrix.Id).then(function(data){
|
|
646
|
+
closedMatrix = data;
|
|
647
|
+
// fetch the closed UserLegalSca
|
|
648
|
+
api.Users.get(matrixSca.Id).then(function(data){
|
|
649
|
+
closedMatrixSca = data;
|
|
650
|
+
done();
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
it('Status should be CLOSED', function() {
|
|
660
|
+
expect(closedMatrix.UserStatus).to.be.eq('CLOSED');
|
|
661
|
+
expect(closedMatrixSca.UserStatus).to.be.eq('CLOSED');
|
|
662
|
+
});
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
describe('Create Bank Account', function(){
|
|
666
|
+
describe('IBAN', function() {
|
|
667
|
+
var ibanAccount;
|
|
668
|
+
before(function(done){
|
|
669
|
+
var account = new BankAccount({
|
|
670
|
+
OwnerName: john.FirstName + ' ' + john.LastName,
|
|
671
|
+
OwnerAddress: john.Address,
|
|
672
|
+
Details: new BankAccountDetailsIBAN({
|
|
673
|
+
IBAN: 'FR7630004000031234567890143',
|
|
674
|
+
BIC: 'BNPAFRPP'
|
|
675
|
+
})
|
|
676
|
+
});
|
|
677
|
+
api.Users.createBankAccount(john.Id, account).then(function(account){
|
|
678
|
+
ibanAccount = account;
|
|
679
|
+
done();
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
it('Account should be created correctly', function(){
|
|
684
|
+
expect(ibanAccount.Id).to.not.be.undefined;
|
|
685
|
+
expect(ibanAccount.UserId).to.equal(john.Id);
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
describe('GB', function() {
|
|
690
|
+
var gbAccount;
|
|
691
|
+
before(function(done){
|
|
692
|
+
var account = new BankAccount({
|
|
693
|
+
OwnerName: john.FirstName + ' ' + john.LastName,
|
|
694
|
+
OwnerAddress: john.Address,
|
|
695
|
+
Details: new BankAccountDetailsGB({
|
|
696
|
+
AccountNumber: '63956474',
|
|
697
|
+
SortCode: '200000'
|
|
698
|
+
})
|
|
699
|
+
});
|
|
700
|
+
api.Users.createBankAccount(john.Id, account).then(function(account){
|
|
701
|
+
gbAccount = account;
|
|
702
|
+
done();
|
|
703
|
+
});
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
it('Account should be created correctly', function(){
|
|
707
|
+
expect(gbAccount.Id).to.not.be.undefined;
|
|
708
|
+
expect(gbAccount.UserId).to.equal(john.Id);
|
|
709
|
+
expect(gbAccount.Type).to.equal('GB');
|
|
710
|
+
});
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
describe('US', function() {
|
|
714
|
+
var usAccount;
|
|
715
|
+
before(function(done){
|
|
716
|
+
var account = new api.models.BankAccount({
|
|
717
|
+
OwnerName: john.FirstName + ' ' + john.LastName,
|
|
718
|
+
OwnerAddress: john.Address,
|
|
719
|
+
Details: new api.models.BankAccountDetailsUS({
|
|
720
|
+
AccountNumber: '234234234234',
|
|
721
|
+
ABA: '234334789'
|
|
722
|
+
})
|
|
723
|
+
});
|
|
724
|
+
api.Users.createBankAccount(john.Id, account).then(function(account){
|
|
725
|
+
usAccount = account;
|
|
726
|
+
done();
|
|
727
|
+
});
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
it('Account should be created correctly', function(){
|
|
731
|
+
expect(usAccount.Id).to.not.be.undefined;
|
|
732
|
+
expect(usAccount.UserId).to.equal(john.Id);
|
|
733
|
+
expect(usAccount.Type).to.equal('US');
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
describe('CA', function() {
|
|
738
|
+
var caAccount;
|
|
739
|
+
before(function(done){
|
|
740
|
+
var account = new BankAccount({
|
|
741
|
+
OwnerName: john.FirstName + ' ' + john.LastName,
|
|
742
|
+
OwnerAddress: john.Address,
|
|
743
|
+
Type: 'CA',
|
|
744
|
+
BankName: 'TestBankName',
|
|
745
|
+
BranchCode: '12345',
|
|
746
|
+
AccountNumber: '234234234234',
|
|
747
|
+
InstitutionNumber: '123'
|
|
748
|
+
});
|
|
749
|
+
api.Users.createBankAccount(john.Id, account).then(function(account){
|
|
750
|
+
caAccount = account;
|
|
751
|
+
done();
|
|
752
|
+
});
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
it('Account should be created correctly', function(){
|
|
756
|
+
expect(caAccount.Id).to.not.be.undefined;
|
|
757
|
+
expect(caAccount.UserId).to.equal(john.Id);
|
|
758
|
+
expect(caAccount.Type).to.equal('CA');
|
|
759
|
+
});
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
describe('OTHER', function() {
|
|
763
|
+
var otherAccount;
|
|
764
|
+
before(function(done){
|
|
765
|
+
var account = new BankAccount({
|
|
766
|
+
OwnerName: john.FirstName + ' ' + john.LastName,
|
|
767
|
+
OwnerAddress: john.Address,
|
|
768
|
+
Type: 'OTHER',
|
|
769
|
+
Country: 'FR',
|
|
770
|
+
AccountNumber: '234234234234',
|
|
771
|
+
BIC: 'BINAADADXXX'
|
|
772
|
+
});
|
|
773
|
+
api.Users.createBankAccount(john.Id, account).then(function(account){
|
|
774
|
+
otherAccount = account;
|
|
775
|
+
done();
|
|
776
|
+
});
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
it('Account should be created correctly', function(){
|
|
780
|
+
expect(otherAccount.Id).to.not.be.undefined;
|
|
781
|
+
expect(otherAccount.UserId).to.equal(john.Id);
|
|
782
|
+
expect(otherAccount.Type).to.equal('OTHER');
|
|
783
|
+
});
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
describe('Bank Accounts', function() {
|
|
788
|
+
var bankAccounts;
|
|
789
|
+
before(function(done){
|
|
790
|
+
api.Users.getBankAccounts(john.Id).then(function(list){
|
|
791
|
+
bankAccounts = list;
|
|
792
|
+
done();
|
|
793
|
+
});
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
it('List should contain instances of BankAccount', function(){
|
|
797
|
+
expect(bankAccounts[0] instanceof BankAccount).to.be.true;
|
|
798
|
+
expect(bankAccounts[0].UserId).to.equal(john.Id);
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
describe('Sort by creation date', function() {
|
|
802
|
+
var bankAccounts;
|
|
803
|
+
before(function(done){
|
|
804
|
+
api.Users.getBankAccounts(john.Id, {
|
|
805
|
+
parameters: {
|
|
806
|
+
Sort: 'CreationDate:desc'
|
|
807
|
+
}
|
|
808
|
+
}).then(function(list){
|
|
809
|
+
bankAccounts = list;
|
|
810
|
+
done();
|
|
811
|
+
});
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
it('Should work properly', function(){
|
|
815
|
+
expect(bankAccounts[0].CreationDate).to.be.above(bankAccounts[3].CreationDate - 1);
|
|
816
|
+
});
|
|
817
|
+
});
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
describe('Deactivate Bank Account', function(){
|
|
821
|
+
var otherAccount;
|
|
822
|
+
var deactivatedBankAccount;
|
|
823
|
+
before(function(done){
|
|
824
|
+
var account = new BankAccount({
|
|
825
|
+
UserId: john.Id,
|
|
826
|
+
OwnerName: john.FirstName + ' ' + john.LastName,
|
|
827
|
+
OwnerAddress: john.Address,
|
|
828
|
+
Type: 'OTHER',
|
|
829
|
+
Country: 'FR',
|
|
830
|
+
AccountNumber: '234234234234',
|
|
831
|
+
BIC: 'BINAADADXXX'
|
|
832
|
+
});
|
|
833
|
+
api.Users.createBankAccount(john.Id, account).then(function(account){
|
|
834
|
+
otherAccount = account;
|
|
835
|
+
|
|
836
|
+
api.Users.deactivateBankAccount(otherAccount.UserId, otherAccount.Id).then(function(account){
|
|
837
|
+
deactivatedBankAccount = account;
|
|
838
|
+
done();
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
});
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
it('Should be deactivated correctly', function(){
|
|
845
|
+
expect(deactivatedBankAccount.Id).not.to.be.undefined;
|
|
846
|
+
expect(deactivatedBankAccount.Id).to.equal(otherAccount.Id);
|
|
847
|
+
expect(deactivatedBankAccount.Active).to.equal(false) ;
|
|
848
|
+
});
|
|
849
|
+
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
describe('Create KYC Document', function() {
|
|
853
|
+
var kycDocument, getKycDocument;
|
|
854
|
+
|
|
855
|
+
before(function(done){
|
|
856
|
+
api.Users.createKycDocument(john.Id, {
|
|
857
|
+
Status: KycDocumentStatus.Created,
|
|
858
|
+
Type: KycDocumentType.IdentityProof
|
|
859
|
+
}).then(function(document){
|
|
860
|
+
kycDocument = document;
|
|
861
|
+
api.Users.getKycDocument(john.Id, kycDocument.Id).then(function(document){
|
|
862
|
+
getKycDocument = document;
|
|
863
|
+
});
|
|
864
|
+
done();
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
it('Should be created and fetched correctly', function(){
|
|
869
|
+
expect(kycDocument.Id).not.to.be.undefined;
|
|
870
|
+
expect(kycDocument.Status).to.equal(KycDocumentStatus.Created);
|
|
871
|
+
expect(kycDocument.Type).to.equal(KycDocumentType.IdentityProof);
|
|
872
|
+
expect(_.isMatch(kycDocument, getKycDocument)).to.be.true;
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
describe('Update KYC Document', function() {
|
|
876
|
+
var updatedKycDocument;
|
|
877
|
+
|
|
878
|
+
before(function(done){
|
|
879
|
+
var filePath = path.resolve(__dirname, '../TestKycPageFile.png');
|
|
880
|
+
api.Users.createKycPageFromFile(john.Id, kycDocument.Id, filePath).then(function(){
|
|
881
|
+
kycDocument.Status = KycDocumentStatus.ValidationAsked;
|
|
882
|
+
api.Users.updateKycDocument(john.Id, kycDocument).then(function(){
|
|
883
|
+
api.Users.getKycDocument(john.Id, kycDocument.Id).then(function(document){
|
|
884
|
+
updatedKycDocument = document;
|
|
885
|
+
done();
|
|
886
|
+
});
|
|
887
|
+
});
|
|
888
|
+
});
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
it('Should be updated correctly', function(){
|
|
892
|
+
expect(updatedKycDocument.Status).to.equal(KycDocumentStatus.ValidationAsked);
|
|
893
|
+
});
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
describe('Create KYC Page', function() {
|
|
897
|
+
describe('Empty File String', function() {
|
|
898
|
+
var emptyFileStringResult;
|
|
899
|
+
|
|
900
|
+
before(function(done){
|
|
901
|
+
api.Users.createKycPage(john.Id, kycDocument.Id, {File: ''}, function (data) {
|
|
902
|
+
emptyFileStringResult = data;
|
|
903
|
+
done();
|
|
904
|
+
});
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
it('Should return error for empty file string', function(){
|
|
908
|
+
expect(emptyFileStringResult.errors).to.not.be.null;
|
|
909
|
+
});
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
describe('Wrong File String', function() {
|
|
913
|
+
var wrongFileStringResult;
|
|
914
|
+
|
|
915
|
+
before(function(done){
|
|
916
|
+
api.Users.createKycPage(john.Id, kycDocument.Id, {File: ''}, function (data) {
|
|
917
|
+
wrongFileStringResult = data;
|
|
918
|
+
done();
|
|
919
|
+
});
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
it('Should return error for wrong file string', function(){
|
|
923
|
+
expect(wrongFileStringResult.errors).to.not.be.null;
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
|
|
927
|
+
describe('Correct File String', function() {
|
|
928
|
+
var kycDocument;
|
|
929
|
+
// Create new KYC Document and add a page
|
|
930
|
+
before(function(done){
|
|
931
|
+
api.Users.createKycDocument(john.Id, {
|
|
932
|
+
Status: KycDocumentStatus.Created,
|
|
933
|
+
Type: KycDocumentType.IdentityProof
|
|
934
|
+
}).then(function(document){
|
|
935
|
+
kycDocument = document;
|
|
936
|
+
done();
|
|
937
|
+
});
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
it('Should be correctly created', function(done){
|
|
941
|
+
api.Users.createKycPage(john.Id, kycDocument.Id, {
|
|
942
|
+
File: helpers.data.KYCPageFileString
|
|
943
|
+
}).then(function(){
|
|
944
|
+
assert.isOk('Request succeeded');
|
|
945
|
+
done();
|
|
946
|
+
}, function(){
|
|
947
|
+
assert.fail('Request failed');
|
|
948
|
+
done();
|
|
949
|
+
});
|
|
950
|
+
});
|
|
951
|
+
});
|
|
952
|
+
|
|
953
|
+
describe('Empty File Path', function() {
|
|
954
|
+
before(function(){
|
|
955
|
+
sinon.stub(api, 'errorHandler');
|
|
956
|
+
api.Users.createKycPageFromFile(john.Id, kycDocument.Id, '');
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
it('Should call error handler', function(){
|
|
960
|
+
assert(api.errorHandler.calledOnce);
|
|
961
|
+
assert(api.errorHandler.calledWith('File path cannot be empty'));
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
after(function(){
|
|
965
|
+
api.errorHandler.restore();
|
|
966
|
+
});
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
describe('Wrong File Path', function() {
|
|
970
|
+
before(function(){
|
|
971
|
+
sinon.stub(api, 'errorHandler');
|
|
972
|
+
api.Users.createKycPageFromFile(john.Id, kycDocument.Id, 'notExistFileName.tmp');
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
it('Should call error handler', function(){
|
|
976
|
+
assert(api.errorHandler.calledOnce);
|
|
977
|
+
assert(api.errorHandler.calledWith('File does not exist'));
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
after(function(){
|
|
981
|
+
api.errorHandler.restore();
|
|
982
|
+
});
|
|
983
|
+
});
|
|
984
|
+
|
|
985
|
+
describe('Correct File Path', function() {
|
|
986
|
+
var kycDocument;
|
|
987
|
+
// Create new KYC Document and add a page
|
|
988
|
+
before(function(done){
|
|
989
|
+
api.Users.createKycDocument(john.Id, {
|
|
990
|
+
Status: KycDocumentStatus.Created,
|
|
991
|
+
Type: KycDocumentType.IdentityProof
|
|
992
|
+
}).then(function(document){
|
|
993
|
+
kycDocument = document;
|
|
994
|
+
done();
|
|
995
|
+
});
|
|
996
|
+
});
|
|
997
|
+
|
|
998
|
+
it('Should be correctly created', function(done){
|
|
999
|
+
var filePath = path.resolve(__dirname, '../TestKycPageFile.png');
|
|
1000
|
+
api.Users.createKycPageFromFile(john.Id, kycDocument.Id, filePath).then(function(){
|
|
1001
|
+
assert.isOk('Request succeeded');
|
|
1002
|
+
done();
|
|
1003
|
+
}, function(){
|
|
1004
|
+
assert.fail('Request failed');
|
|
1005
|
+
done();
|
|
1006
|
+
});
|
|
1007
|
+
});
|
|
1008
|
+
});
|
|
1009
|
+
});
|
|
1010
|
+
});
|
|
1011
|
+
|
|
1012
|
+
describe('Get KYC Documents', function() {
|
|
1013
|
+
var kycDocuments;
|
|
1014
|
+
before(function(done){
|
|
1015
|
+
api.Users.getKycDocuments(john.Id).then(function(list){
|
|
1016
|
+
kycDocuments = list;
|
|
1017
|
+
done();
|
|
1018
|
+
});
|
|
1019
|
+
});
|
|
1020
|
+
|
|
1021
|
+
it('List should contain instances of BankAccount', function(){
|
|
1022
|
+
expect(kycDocuments[0] instanceof KycDocument).to.be.true;
|
|
1023
|
+
});
|
|
1024
|
+
|
|
1025
|
+
describe('Sort by creation date', function() {
|
|
1026
|
+
var kycDocuments;
|
|
1027
|
+
before(function(done){
|
|
1028
|
+
// Create a new document
|
|
1029
|
+
api.Users.createKycDocument(john.Id, {
|
|
1030
|
+
Status: KycDocumentStatus.Created,
|
|
1031
|
+
Type: KycDocumentType.IdentityProof
|
|
1032
|
+
}).then(function(){
|
|
1033
|
+
// Request documents sorted
|
|
1034
|
+
api.Users.getKycDocuments(john.Id, {
|
|
1035
|
+
parameters: {
|
|
1036
|
+
Sort: 'CreationDate:desc'
|
|
1037
|
+
}
|
|
1038
|
+
}).then(function(list){
|
|
1039
|
+
kycDocuments = list;
|
|
1040
|
+
done();
|
|
1041
|
+
});
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
|
|
1045
|
+
it('Should work properly', function(){
|
|
1046
|
+
expect(kycDocuments[0].CreationDate).to.be.above(kycDocuments[1].CreationDate - 1);
|
|
1047
|
+
});
|
|
1048
|
+
});
|
|
1049
|
+
});
|
|
1050
|
+
|
|
1051
|
+
describe('Transactions', function() {
|
|
1052
|
+
var payIn, transactions;
|
|
1053
|
+
|
|
1054
|
+
before(function(done){
|
|
1055
|
+
helpers.getNewPayInCardDirect(api, john, function(data){
|
|
1056
|
+
payIn = data;
|
|
1057
|
+
done();
|
|
1058
|
+
});
|
|
1059
|
+
});
|
|
1060
|
+
|
|
1061
|
+
describe('Get all transactions', function(){
|
|
1062
|
+
before(function(done){
|
|
1063
|
+
api.Users.getTransactions(john.Id, function(data, response){
|
|
1064
|
+
transactions = data;
|
|
1065
|
+
done();
|
|
1066
|
+
}, {
|
|
1067
|
+
parameters: {
|
|
1068
|
+
Type: 'PAYIN',
|
|
1069
|
+
AfterDate: payIn.CreationDate - 10,
|
|
1070
|
+
BeforeDate: payIn.CreationDate + 10
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
});
|
|
1074
|
+
|
|
1075
|
+
it('should have one transaction', function(){
|
|
1076
|
+
expect(transactions.length).to.equal(1);
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1079
|
+
it('transaction data should be correct', function(){
|
|
1080
|
+
expect(transactions[0].AuthorId).to.equal(john.Id);
|
|
1081
|
+
});
|
|
1082
|
+
});
|
|
1083
|
+
|
|
1084
|
+
describe('Get all transactions Sca', function(){
|
|
1085
|
+
var responseError;
|
|
1086
|
+
|
|
1087
|
+
before(function(done){
|
|
1088
|
+
api.Users.getTransactions(john.Id, function(data, response) {}, {
|
|
1089
|
+
parameters: {
|
|
1090
|
+
Type: 'PAYIN',
|
|
1091
|
+
AfterDate: payIn.CreationDate - 10,
|
|
1092
|
+
BeforeDate: payIn.CreationDate + 10,
|
|
1093
|
+
ScaContext: 'USER_PRESENT'
|
|
1094
|
+
},
|
|
1095
|
+
resolveWithFullResponse: true
|
|
1096
|
+
}).catch(function (error) {
|
|
1097
|
+
responseError = error;
|
|
1098
|
+
done();
|
|
1099
|
+
});
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1102
|
+
it('redirectUrl should be present on response headers', function () {
|
|
1103
|
+
expect(responseError.headers['www-authenticate']).to.contain("PendingUserAction RedirectUrl");
|
|
1104
|
+
});
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
describe('Get all Cards', function(){
|
|
1108
|
+
var card, cards;
|
|
1109
|
+
|
|
1110
|
+
before(function(done){
|
|
1111
|
+
api.Cards.get(payIn.CardId, function(data, response){
|
|
1112
|
+
card = data;
|
|
1113
|
+
api.Users.getCards(john.Id, function(data, response){
|
|
1114
|
+
cards = data;
|
|
1115
|
+
done();
|
|
1116
|
+
});
|
|
1117
|
+
});
|
|
1118
|
+
});
|
|
1119
|
+
|
|
1120
|
+
it('should have one card', function(){
|
|
1121
|
+
expect(cards.length).to.equal(1);
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1124
|
+
it('card data should be correct', function(){
|
|
1125
|
+
expect(cards[0].UserId).to.equal(john.Id);
|
|
1126
|
+
});
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
describe('Get Transactions for Card', function(){
|
|
1130
|
+
var getTransactions;
|
|
1131
|
+
|
|
1132
|
+
before(function(done){
|
|
1133
|
+
api.Cards.getTransactions(payIn.CardId, function(data, response){
|
|
1134
|
+
getTransactions = data;
|
|
1135
|
+
done();
|
|
1136
|
+
});
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
it('should be retrieved', function(){
|
|
1140
|
+
expect(getTransactions).not.to.be.undefined;
|
|
1141
|
+
expect(getTransactions).to.be.an('array');
|
|
1142
|
+
});
|
|
1143
|
+
});
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
describe('Wallets', function() {
|
|
1147
|
+
var wallets, wallet;
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
before(function(done){
|
|
1151
|
+
wallet = {
|
|
1152
|
+
Owners: [john.Id],
|
|
1153
|
+
Currency: 'EUR',
|
|
1154
|
+
Description: 'WALLET IN EUR'
|
|
1155
|
+
};
|
|
1156
|
+
|
|
1157
|
+
api.Wallets.create(wallet).then(function(){
|
|
1158
|
+
api.Users.getWallets(john.Id, function(data, response){
|
|
1159
|
+
wallets = data;
|
|
1160
|
+
done();
|
|
1161
|
+
});
|
|
1162
|
+
});
|
|
1163
|
+
});
|
|
1164
|
+
|
|
1165
|
+
it('should have two wallets', function(){
|
|
1166
|
+
expect(wallets.length).to.equal(2);
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1169
|
+
it('wallet should contain the right data', function(){
|
|
1170
|
+
assert(_.contains(wallets[0].Owners, john.Id));
|
|
1171
|
+
});
|
|
1172
|
+
});
|
|
1173
|
+
|
|
1174
|
+
describe('Wallets Sca', function () {
|
|
1175
|
+
var responseError;
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
before(function (done) {
|
|
1179
|
+
api.Users.getWallets(john.Id, function (data, response) {
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
parameters: {
|
|
1183
|
+
ScaContext: 'USER_PRESENT'
|
|
1184
|
+
},
|
|
1185
|
+
resolveWithFullResponse: true
|
|
1186
|
+
}).catch(function (error) {
|
|
1187
|
+
responseError = error;
|
|
1188
|
+
done();
|
|
1189
|
+
});
|
|
1190
|
+
});
|
|
1191
|
+
|
|
1192
|
+
it('redirectUrl should be present on response headers', function () {
|
|
1193
|
+
expect(responseError.headers['www-authenticate']).to.contain("PendingUserAction RedirectUrl");
|
|
1194
|
+
});
|
|
1195
|
+
});
|
|
1196
|
+
|
|
1197
|
+
describe('Create UBO declaration', function() {
|
|
1198
|
+
var declarativeUser, createdDeclaration, ubo;
|
|
1199
|
+
|
|
1200
|
+
before(function(done) {
|
|
1201
|
+
declarativeUser = helpers.data.getUbo();
|
|
1202
|
+
|
|
1203
|
+
api.UboDeclarations.create(matrix.Id, function (data, response) {
|
|
1204
|
+
uboDeclaration = data;
|
|
1205
|
+
|
|
1206
|
+
api.UboDeclarations.createUbo(matrix.Id, uboDeclaration.Id, declarativeUser, function (data, response) {
|
|
1207
|
+
ubo = data;
|
|
1208
|
+
|
|
1209
|
+
done();
|
|
1210
|
+
});
|
|
1211
|
+
});
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
it('should be successful', function() {
|
|
1215
|
+
expect(uboDeclaration).not.to.be.null;
|
|
1216
|
+
expect(uboDeclaration.Status).to.equal(UboDeclarationStatus.Created);
|
|
1217
|
+
expect(ubo).not.to.be.null;
|
|
1218
|
+
expect(ubo.FirstName).to.equal(declarativeUser.FirstName);
|
|
1219
|
+
});
|
|
1220
|
+
});
|
|
1221
|
+
|
|
1222
|
+
describe('Get PreAuthorizations', function() {
|
|
1223
|
+
var getPreAuthorizations;
|
|
1224
|
+
|
|
1225
|
+
before(function(done) {
|
|
1226
|
+
api.Users.getPreAuthorizations(john.Id, function(data, response) {
|
|
1227
|
+
getPreAuthorizations = data;
|
|
1228
|
+
done();
|
|
1229
|
+
});
|
|
1230
|
+
});
|
|
1231
|
+
|
|
1232
|
+
it('should be retrieved', function() {
|
|
1233
|
+
expect(getPreAuthorizations).not.to.be.undefined;
|
|
1234
|
+
expect(getPreAuthorizations).to.be.an('array');
|
|
1235
|
+
});
|
|
1236
|
+
});
|
|
1237
|
+
|
|
1238
|
+
describe('Get BlockStatus', function () {
|
|
1239
|
+
var blockStatus;
|
|
1240
|
+
|
|
1241
|
+
before(function (done) {
|
|
1242
|
+
api.Users.getBlockStatus(john.Id, function (data, response) {
|
|
1243
|
+
blockStatus = data;
|
|
1244
|
+
done();
|
|
1245
|
+
});
|
|
1246
|
+
});
|
|
1247
|
+
|
|
1248
|
+
it('should get the block status', function() {
|
|
1249
|
+
expect(blockStatus).not.to.be.undefined;
|
|
1250
|
+
});
|
|
1251
|
+
});
|
|
1252
|
+
|
|
1253
|
+
describe('Get Regulatory', function () {
|
|
1254
|
+
var blockStatus;
|
|
1255
|
+
|
|
1256
|
+
before(function (done) {
|
|
1257
|
+
api.Users.getRegulatory(john.Id, function (data, response) {
|
|
1258
|
+
blockStatus = data;
|
|
1259
|
+
done();
|
|
1260
|
+
});
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1263
|
+
it('should get regulatory', function () {
|
|
1264
|
+
expect(blockStatus).not.to.be.undefined;
|
|
1265
|
+
});
|
|
1266
|
+
});
|
|
1267
|
+
|
|
1268
|
+
describe('Validate data format', function () {
|
|
1269
|
+
var successResult;
|
|
1270
|
+
var errorResult;
|
|
1271
|
+
|
|
1272
|
+
before(function (done) {
|
|
1273
|
+
var validation = {
|
|
1274
|
+
CompanyNumber: {
|
|
1275
|
+
CompanyNumber: "AB123456",
|
|
1276
|
+
CountryCode: "IT"
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
api.Users.validateDataFormat(validation, function (data, response) {
|
|
1280
|
+
successResult = data;
|
|
1281
|
+
validation = {
|
|
1282
|
+
CompanyNumber: {
|
|
1283
|
+
CompanyNumber: "123"
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
api.Users.validateDataFormat(validation, function (data, response) {
|
|
1287
|
+
})
|
|
1288
|
+
.catch(function (data) {
|
|
1289
|
+
errorResult = data;
|
|
1290
|
+
done();
|
|
1291
|
+
});
|
|
1292
|
+
});
|
|
1293
|
+
});
|
|
1294
|
+
|
|
1295
|
+
it('should be valid', function () {
|
|
1296
|
+
expect(successResult.CompanyNumber).not.to.be.undefined;
|
|
1297
|
+
});
|
|
1298
|
+
|
|
1299
|
+
it('should fail', function () {
|
|
1300
|
+
expect(successResult.CompanyNumber).not.to.be.undefined;
|
|
1301
|
+
});
|
|
1302
|
+
});
|
|
1303
|
+
});
|