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.
Files changed (353) hide show
  1. package/.github/workflows/node.js.yml +32 -0
  2. package/.github/workflows/npm-publish.yml +26 -0
  3. package/.jshintrc +16 -0
  4. package/CHANGELOG.md +946 -0
  5. package/LICENSE +21 -0
  6. package/README.md +179 -0
  7. package/docs/BankAccounts.md +35 -0
  8. package/docs/BankingAliases.md +108 -0
  9. package/docs/CardPreAuthorizations.md +55 -0
  10. package/docs/CardRegistrations.md +55 -0
  11. package/docs/Cards.md +82 -0
  12. package/docs/Clients.md +142 -0
  13. package/docs/DisputeDocuments.md +53 -0
  14. package/docs/Disputes.md +292 -0
  15. package/docs/Events.md +23 -0
  16. package/docs/Hooks.md +68 -0
  17. package/docs/Idempotency.md +11 -0
  18. package/docs/KycDocuments.md +52 -0
  19. package/docs/Mandates.md +125 -0
  20. package/docs/OptionsHelper.md +32 -0
  21. package/docs/PayIns.md +72 -0
  22. package/docs/PayOuts.md +55 -0
  23. package/docs/README.md +131 -0
  24. package/docs/Refunds.md +25 -0
  25. package/docs/Reports.md +63 -0
  26. package/docs/Repudiations.md +25 -0
  27. package/docs/Responses.md +33 -0
  28. package/docs/Transfers.md +72 -0
  29. package/docs/UboDeclarations.md +70 -0
  30. package/docs/Users.md +322 -0
  31. package/docs/Wallets.md +70 -0
  32. package/docs/templates/class.mustache +11 -0
  33. package/docs/templates/file.mustache +53 -0
  34. package/docs/templates/function.mustache +33 -0
  35. package/docs/templates/index.mustache +26 -0
  36. package/docs/templates/overview.mustache +1 -0
  37. package/examples/createUsers.js +112 -0
  38. package/examples/createWallet.js +28 -0
  39. package/examples/failedRequest.js +20 -0
  40. package/examples/getBankAccounts.js +29 -0
  41. package/examples/getUserEmoney.js +16 -0
  42. package/examples/getUsers.js +32 -0
  43. package/examples/readResponseHeaders.js +42 -0
  44. package/index.js +1 -0
  45. package/lib/Model.js +58 -0
  46. package/lib/api.js +467 -0
  47. package/lib/apiMethods.js +270 -0
  48. package/lib/config.js +57 -0
  49. package/lib/log.js +9 -0
  50. package/lib/mangopay.js +8 -0
  51. package/lib/models/Address.js +32 -0
  52. package/lib/models/BankAccount.js +45 -0
  53. package/lib/models/BankAccountDetails.js +7 -0
  54. package/lib/models/BankAccountDetailsCA.js +12 -0
  55. package/lib/models/BankAccountDetailsGB.js +10 -0
  56. package/lib/models/BankAccountDetailsIBAN.js +10 -0
  57. package/lib/models/BankAccountDetailsOTHER.js +16 -0
  58. package/lib/models/BankAccountDetailsUS.js +14 -0
  59. package/lib/models/BankAccountType.js +8 -0
  60. package/lib/models/BankingAlias.js +37 -0
  61. package/lib/models/BankingAliasIBAN.js +27 -0
  62. package/lib/models/Billing.js +14 -0
  63. package/lib/models/BinData.js +16 -0
  64. package/lib/models/Birthplace.js +10 -0
  65. package/lib/models/BrowserInfo.js +15 -0
  66. package/lib/models/Card.js +19 -0
  67. package/lib/models/CardInfo.js +32 -0
  68. package/lib/models/CardPreAuthorization.js +144 -0
  69. package/lib/models/CardRegistration.js +29 -0
  70. package/lib/models/CardValidation.js +19 -0
  71. package/lib/models/CategorizeUserLegal.js +15 -0
  72. package/lib/models/CategorizeUserNatural.js +18 -0
  73. package/lib/models/Check.js +13 -0
  74. package/lib/models/CheckData.js +8 -0
  75. package/lib/models/Client.js +62 -0
  76. package/lib/models/ClientWallet.js +28 -0
  77. package/lib/models/Conversion.js +19 -0
  78. package/lib/models/ConversionRate.js +10 -0
  79. package/lib/models/CountryAuthorization.js +12 -0
  80. package/lib/models/DebitedBankAccount.js +15 -0
  81. package/lib/models/DeclaredUbo.js +29 -0
  82. package/lib/models/DeclaredUboStatus.js +17 -0
  83. package/lib/models/Deposit.js +29 -0
  84. package/lib/models/Dispute.js +46 -0
  85. package/lib/models/DisputeDocument.js +10 -0
  86. package/lib/models/DisputeDocumentPage.js +12 -0
  87. package/lib/models/DisputeReason.js +11 -0
  88. package/lib/models/Document.js +12 -0
  89. package/lib/models/DocumentPageConsult.js +17 -0
  90. package/lib/models/EMoney.js +30 -0
  91. package/lib/models/EntityBase.js +70 -0
  92. package/lib/models/Hook.js +19 -0
  93. package/lib/models/IdempotencyResponse.js +11 -0
  94. package/lib/models/IdentityVerification.js +12 -0
  95. package/lib/models/KycDocument.js +11 -0
  96. package/lib/models/KycDocumentStatus.js +7 -0
  97. package/lib/models/KycDocumentType.js +7 -0
  98. package/lib/models/KycPage.js +12 -0
  99. package/lib/models/LegalPersonType.js +7 -0
  100. package/lib/models/LegalRepresentative.js +16 -0
  101. package/lib/models/Mandate.js +69 -0
  102. package/lib/models/MandateStatus.js +7 -0
  103. package/lib/models/Money.js +16 -0
  104. package/lib/models/PayByBankSupportedBank.js +7 -0
  105. package/lib/models/PayIn.js +36 -0
  106. package/lib/models/PayInExecutionDetails.js +7 -0
  107. package/lib/models/PayInExecutionDetailsBankingAlias.js +19 -0
  108. package/lib/models/PayInExecutionDetailsDirect.js +29 -0
  109. package/lib/models/PayInExecutionDetailsWeb.js +40 -0
  110. package/lib/models/PayInExecutionType.js +5 -0
  111. package/lib/models/PayInIntent.js +20 -0
  112. package/lib/models/PayInIntentSplit.js +14 -0
  113. package/lib/models/PayInIntentSplits.js +7 -0
  114. package/lib/models/PayInPaymentDetails.js +7 -0
  115. package/lib/models/PayInPaymentDetailsApplePay.js +19 -0
  116. package/lib/models/PayInPaymentDetailsBancontact.js +13 -0
  117. package/lib/models/PayInPaymentDetailsBankWire.js +23 -0
  118. package/lib/models/PayInPaymentDetailsBankingAlias.js +18 -0
  119. package/lib/models/PayInPaymentDetailsBizum.js +23 -0
  120. package/lib/models/PayInPaymentDetailsBlik.js +17 -0
  121. package/lib/models/PayInPaymentDetailsCard.js +10 -0
  122. package/lib/models/PayInPaymentDetailsCardDirect.js +14 -0
  123. package/lib/models/PayInPaymentDetailsCardWeb.js +28 -0
  124. package/lib/models/PayInPaymentDetailsDirectDebitDirect.js +22 -0
  125. package/lib/models/PayInPaymentDetailsDirectDebitWeb.js +13 -0
  126. package/lib/models/PayInPaymentDetailsGiropay.js +15 -0
  127. package/lib/models/PayInPaymentDetailsGooglePay.js +35 -0
  128. package/lib/models/PayInPaymentDetailsIdeal.js +25 -0
  129. package/lib/models/PayInPaymentDetailsKlarna.js +36 -0
  130. package/lib/models/PayInPaymentDetailsMbway.js +20 -0
  131. package/lib/models/PayInPaymentDetailsMultibanco.js +14 -0
  132. package/lib/models/PayInPaymentDetailsPayByBank.js +71 -0
  133. package/lib/models/PayInPaymentDetailsPayPal.js +63 -0
  134. package/lib/models/PayInPaymentDetailsPayconiq.js +23 -0
  135. package/lib/models/PayInPaymentDetailsPreAuthorized.js +10 -0
  136. package/lib/models/PayInPaymentDetailsSatispay.js +19 -0
  137. package/lib/models/PayInPaymentDetailsSwish.js +35 -0
  138. package/lib/models/PayInPaymentDetailsTwint.js +15 -0
  139. package/lib/models/PayInPaymentType.js +21 -0
  140. package/lib/models/PayInRecurringRegistration.js +64 -0
  141. package/lib/models/PayInTemplateURLOptions.js +10 -0
  142. package/lib/models/PayOut.js +24 -0
  143. package/lib/models/PayOutPaymentDetails.js +7 -0
  144. package/lib/models/PayOutPaymentDetailsBankWire.js +32 -0
  145. package/lib/models/PayOutPaymentType.js +3 -0
  146. package/lib/models/PaymentData.js +20 -0
  147. package/lib/models/PaymentMethodMetadata.js +38 -0
  148. package/lib/models/PayoutMethods.js +7 -0
  149. package/lib/models/PendingUserAction.js +16 -0
  150. package/lib/models/PersonType.js +5 -0
  151. package/lib/models/PlatformCategorization.js +16 -0
  152. package/lib/models/PlatformType.js +10 -0
  153. package/lib/models/Quote.js +11 -0
  154. package/lib/models/Recipient.js +20 -0
  155. package/lib/models/RecipientSchema.js +17 -0
  156. package/lib/models/RecurringPayIn.js +10 -0
  157. package/lib/models/RecurringPayInCIT.js +32 -0
  158. package/lib/models/RecurringPayInCurrentState.js +24 -0
  159. package/lib/models/RecurringPayInMIT.js +27 -0
  160. package/lib/models/RecurringPayInPut.js +24 -0
  161. package/lib/models/Refund.js +26 -0
  162. package/lib/models/RefundReasonDetails.js +10 -0
  163. package/lib/models/Report.js +54 -0
  164. package/lib/models/ReportFilter.js +52 -0
  165. package/lib/models/ReportFilterV2.js +11 -0
  166. package/lib/models/ReportV2.js +28 -0
  167. package/lib/models/Repudiation.js +51 -0
  168. package/lib/models/SecurityInfo.js +12 -0
  169. package/lib/models/Settlement.js +16 -0
  170. package/lib/models/SettlementTransfer.js +37 -0
  171. package/lib/models/Shipping.js +14 -0
  172. package/lib/models/ShippingAddress.js +25 -0
  173. package/lib/models/ShippingPreference.js +5 -0
  174. package/lib/models/Transaction.js +50 -0
  175. package/lib/models/Transfer.js +13 -0
  176. package/lib/models/Ubo.js +19 -0
  177. package/lib/models/UboDeclaration.js +42 -0
  178. package/lib/models/UboDeclarationRefusedReasonType.js +23 -0
  179. package/lib/models/UboDeclarationStatus.js +26 -0
  180. package/lib/models/UboRefusedReasonType.js +14 -0
  181. package/lib/models/User.js +66 -0
  182. package/lib/models/UserCategory.js +5 -0
  183. package/lib/models/UserConsent.js +7 -0
  184. package/lib/models/UserDataFormatValidation.js +7 -0
  185. package/lib/models/UserEnrollmentResult.js +7 -0
  186. package/lib/models/UserLegal.js +65 -0
  187. package/lib/models/UserLegalOwner.js +66 -0
  188. package/lib/models/UserLegalPayer.js +66 -0
  189. package/lib/models/UserLegalSca.js +57 -0
  190. package/lib/models/UserNatural.js +51 -0
  191. package/lib/models/UserNaturalCapacity.js +13 -0
  192. package/lib/models/UserNaturalOwner.js +55 -0
  193. package/lib/models/UserNaturalPayer.js +55 -0
  194. package/lib/models/UserNaturalPut.js +49 -0
  195. package/lib/models/UserNaturalSca.js +56 -0
  196. package/lib/models/VirtualAccount.js +22 -0
  197. package/lib/models/Wallet.js +32 -0
  198. package/lib/models/index.js +102 -0
  199. package/lib/service.js +14 -0
  200. package/lib/services/BankAccounts.js +31 -0
  201. package/lib/services/BankingAliases.js +137 -0
  202. package/lib/services/CardPreAuthorizations.js +75 -0
  203. package/lib/services/CardRegistrations.js +64 -0
  204. package/lib/services/Cards.js +168 -0
  205. package/lib/services/Clients.js +196 -0
  206. package/lib/services/Conversions.js +155 -0
  207. package/lib/services/Deposits.js +109 -0
  208. package/lib/services/DisputeDocuments.js +65 -0
  209. package/lib/services/Disputes.js +409 -0
  210. package/lib/services/Events.js +24 -0
  211. package/lib/services/Hooks.js +81 -0
  212. package/lib/services/Idempotency.js +17 -0
  213. package/lib/services/IdentityVerifications.js +48 -0
  214. package/lib/services/KycDocuments.js +66 -0
  215. package/lib/services/Mandates.js +161 -0
  216. package/lib/services/OptionsHelper.js +20 -0
  217. package/lib/services/PayIns.js +690 -0
  218. package/lib/services/PayOuts.js +110 -0
  219. package/lib/services/Recipients.js +117 -0
  220. package/lib/services/Refunds.js +29 -0
  221. package/lib/services/Regulatory.js +29 -0
  222. package/lib/services/Reports.js +61 -0
  223. package/lib/services/ReportsV2.js +55 -0
  224. package/lib/services/Repudiations.js +33 -0
  225. package/lib/services/Responses.js +23 -0
  226. package/lib/services/Settlements.js +74 -0
  227. package/lib/services/Transfers.js +87 -0
  228. package/lib/services/UboDeclarations.js +135 -0
  229. package/lib/services/Users.js +831 -0
  230. package/lib/services/VirtualAccounts.js +99 -0
  231. package/lib/services/Wallets.js +85 -0
  232. package/lib/services/index.js +34 -0
  233. package/lib/utils.js +36 -0
  234. package/package.json +40 -0
  235. package/test/TestKycPageFile.png +0 -0
  236. package/test/helpers.js +1431 -0
  237. package/test/main.js +10 -0
  238. package/test/mocha.opts +3 -0
  239. package/test/services/BankAccounts.js +46 -0
  240. package/test/services/BankingAliases.js +89 -0
  241. package/test/services/CardPreAuthorizations.js +70 -0
  242. package/test/services/CardRegistrations.js +239 -0
  243. package/test/services/Cards.js +54 -0
  244. package/test/services/Clients.js +235 -0
  245. package/test/services/Conversions.js +308 -0
  246. package/test/services/Deposits.js +148 -0
  247. package/test/services/Disputes.js +542 -0
  248. package/test/services/EMoney.js +54 -0
  249. package/test/services/Events.js +143 -0
  250. package/test/services/Hooks.js +109 -0
  251. package/test/services/Idempotency.js +46 -0
  252. package/test/services/IdentityVerifications.js +68 -0
  253. package/test/services/KycDocuments.js +73 -0
  254. package/test/services/Mandates.js +256 -0
  255. package/test/services/PayIns.js +2553 -0
  256. package/test/services/PayOuts.js +106 -0
  257. package/test/services/RateLimit.js +48 -0
  258. package/test/services/Recipients.js +234 -0
  259. package/test/services/Refunds.js +123 -0
  260. package/test/services/Regulatory.js +45 -0
  261. package/test/services/Reports.js +114 -0
  262. package/test/services/ReportsV2.js +306 -0
  263. package/test/services/Repudiations.js +22 -0
  264. package/test/services/Settlements.js +58 -0
  265. package/test/services/Tokens.js +55 -0
  266. package/test/services/Transfers.js +137 -0
  267. package/test/services/UboDeclarations.js +135 -0
  268. package/test/services/Users.js +1303 -0
  269. package/test/services/VirtualAccounts.js +105 -0
  270. package/test/services/Wallets.js +132 -0
  271. package/test/settlement_sample.csv +8 -0
  272. package/typings/base.d.ts +308 -0
  273. package/typings/enums.d.ts +204 -0
  274. package/typings/index.d.ts +885 -0
  275. package/typings/index.test-d.ts +1535 -0
  276. package/typings/models/address.d.ts +70 -0
  277. package/typings/models/bankAccount.d.ts +235 -0
  278. package/typings/models/bankingAlias.d.ts +97 -0
  279. package/typings/models/billing.d.ts +42 -0
  280. package/typings/models/birthplace.d.ts +9 -0
  281. package/typings/models/card.d.ts +119 -0
  282. package/typings/models/cardPreauthorization.d.ts +157 -0
  283. package/typings/models/cardRegistration.d.ts +83 -0
  284. package/typings/models/cardValidation.d.ts +125 -0
  285. package/typings/models/client.d.ts +208 -0
  286. package/typings/models/conversion.d.ts +225 -0
  287. package/typings/models/conversionRate.d.ts +29 -0
  288. package/typings/models/countryAuthorization.d.ts +16 -0
  289. package/typings/models/deposit.d.ts +104 -0
  290. package/typings/models/dispute.d.ts +116 -0
  291. package/typings/models/disputeDocument.d.ts +119 -0
  292. package/typings/models/entityBase.d.ts +9 -0
  293. package/typings/models/event.d.ts +142 -0
  294. package/typings/models/hook.d.ts +39 -0
  295. package/typings/models/idempotency.d.ts +36 -0
  296. package/typings/models/identityVerification.d.ts +98 -0
  297. package/typings/models/kycDocument.d.ts +114 -0
  298. package/typings/models/mandate.d.ts +93 -0
  299. package/typings/models/money.d.ts +45 -0
  300. package/typings/models/payIn.d.ts +3742 -0
  301. package/typings/models/payOut.d.ts +144 -0
  302. package/typings/models/recipient.d.ts +242 -0
  303. package/typings/models/refund.d.ts +92 -0
  304. package/typings/models/report.d.ts +234 -0
  305. package/typings/models/reportV2.d.ts +145 -0
  306. package/typings/models/repudiation.d.ts +26 -0
  307. package/typings/models/securityInfo.d.ts +12 -0
  308. package/typings/models/settlement.d.ts +50 -0
  309. package/typings/models/settlementTransfer.d.ts +37 -0
  310. package/typings/models/shipping.d.ts +37 -0
  311. package/typings/models/shippingAddress.d.ts +15 -0
  312. package/typings/models/transaction.d.ts +85 -0
  313. package/typings/models/transfer.d.ts +119 -0
  314. package/typings/models/uboDeclaration.d.ts +100 -0
  315. package/typings/models/user.d.ts +1001 -0
  316. package/typings/models/virtualAccount.d.ts +182 -0
  317. package/typings/models/wallet.d.ts +46 -0
  318. package/typings/models.d.ts +74 -0
  319. package/typings/services/BankAccounts.d.ts +12 -0
  320. package/typings/services/BankingAliases.d.ts +51 -0
  321. package/typings/services/CardPreauthorizations.d.ts +44 -0
  322. package/typings/services/CardRegistrations.d.ts +43 -0
  323. package/typings/services/Cards.d.ts +80 -0
  324. package/typings/services/Clients.d.ts +77 -0
  325. package/typings/services/Conversions.d.ts +23 -0
  326. package/typings/services/Deposits.d.ts +20 -0
  327. package/typings/services/DisputeDocuments.d.ts +27 -0
  328. package/typings/services/Disputes.d.ts +169 -0
  329. package/typings/services/Events.d.ts +11 -0
  330. package/typings/services/Hooks.d.ts +33 -0
  331. package/typings/services/Idempotency.d.ts +7 -0
  332. package/typings/services/IdentityVerifications.d.ts +29 -0
  333. package/typings/services/KycDocuments.d.ts +38 -0
  334. package/typings/services/Mandates.d.ts +59 -0
  335. package/typings/services/OptionsHelper.d.ts +11 -0
  336. package/typings/services/PayIns.d.ts +319 -0
  337. package/typings/services/PayOuts.d.ts +34 -0
  338. package/typings/services/Recipients.d.ts +55 -0
  339. package/typings/services/Refunds.d.ts +12 -0
  340. package/typings/services/Regulatory.d.ts +17 -0
  341. package/typings/services/Reports.d.ts +26 -0
  342. package/typings/services/ReportsV2.d.ts +26 -0
  343. package/typings/services/Repudiations.d.ts +12 -0
  344. package/typings/services/Responses.d.ts +10 -0
  345. package/typings/services/Settlements.d.ts +28 -0
  346. package/typings/services/Transfers.d.ts +38 -0
  347. package/typings/services/UboDeclarations.d.ts +81 -0
  348. package/typings/services/Users.d.ts +308 -0
  349. package/typings/services/VirtualAccounts.d.ts +42 -0
  350. package/typings/services/Wallets.d.ts +36 -0
  351. package/typings/tsconfig.json +20 -0
  352. package/typings/tslint.json +11 -0
  353. package/typings/types.d.ts +652 -0
@@ -0,0 +1,2553 @@
1
+ var expect = require('chai').expect;
2
+
3
+ var helpers = require('../helpers');
4
+ var mangopay = require('../../index');
5
+
6
+ var api = global.api = new mangopay({
7
+ clientId: 'sdk-unit-tests',
8
+ clientApiKey: 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
9
+ });
10
+
11
+ describe('PayIns', function () {
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
+ describe('Card Web', function () {
22
+
23
+ before(function (done) {
24
+ helpers.getNewPayInCardWeb(api, john, function (data, response) {
25
+ payIn = data;
26
+ done();
27
+ });
28
+ });
29
+
30
+ describe('Create', function () {
31
+ it('should create the PayIn', function () {
32
+ expect(payIn.Id).not.to.be.undefined;
33
+ expect(payIn.PaymentType).to.equal('CARD');
34
+ expect(payIn.ExecutionType).to.equal('WEB');
35
+ });
36
+ });
37
+
38
+ describe('Get', function () {
39
+ var getPayIn;
40
+ before(function (done) {
41
+ api.PayIns.get(payIn.Id, function (data, response) {
42
+ getPayIn = data;
43
+ done()
44
+ });
45
+ });
46
+
47
+ it('should get the PayIn', function () {
48
+ expect(getPayIn.Id).not.to.be.undefined;
49
+ expect(getPayIn.PaymentType).to.equal('CARD');
50
+ expect(getPayIn.ExecutionType).to.equal('WEB');
51
+ expect(getPayIn.Status).to.equal('CREATED');
52
+ expect(getPayIn.ExecutionDate).to.be.null;
53
+ expect(getPayIn.RedirectURL).not.to.be.undefined;
54
+ expect(getPayIn.ReturnURL).not.to.be.undefined;
55
+ });
56
+ });
57
+
58
+ describe.skip('Get extended details', function () {
59
+ console.warn('Cannot be tested because a Succeeded Card Web PayIn cannot be generated from the tests');
60
+ var extendedDetails;
61
+ before(function (done) {
62
+ api.PayIns.getCardWebPayInExtendedDetails(payIn.Id, function (data, response) {
63
+ extendedDetails = data;
64
+ done();
65
+ });
66
+ });
67
+
68
+ it('should get the PayIn', function () {
69
+ expect(extendedDetails.Id).not.to.be.undefined;
70
+ expect(extendedDetails.PaymentType).to.equal('CARD');
71
+ expect(extendedDetails.ExecutionType).to.equal('WEB');
72
+ });
73
+ });
74
+ });
75
+
76
+ describe('Card Direct', function () {
77
+ var payIn;
78
+
79
+ before(function (done) {
80
+ helpers.getNewPayInCardDirect(api, john, function (data, response) {
81
+ payIn = data;
82
+ done();
83
+ });
84
+ });
85
+
86
+ describe('Create', function () {
87
+ it('should create the PayIn', function () {
88
+ expect(payIn.Id).not.to.be.undefined;
89
+ expect(payIn.PaymentType).to.equal('CARD');
90
+ expect(payIn.ExecutionType).to.equal('DIRECT');
91
+ expect(payIn.AuthorId).to.equal(john.Id);
92
+ expect(payIn.Status).to.equal('SUCCEEDED');
93
+ expect(payIn.Type).to.equal('PAYIN');
94
+ expect(payIn.SecurityInfo.AVSResult).to.equal('NO_CHECK');
95
+ expect(payIn.CardInfo).not.to.be.undefined;
96
+ });
97
+ });
98
+
99
+ describe('Get', function () {
100
+ var getPayIn;
101
+ before(function (done) {
102
+ api.PayIns.get(payIn.Id, function (data, response) {
103
+ getPayIn = data;
104
+ done()
105
+ });
106
+ });
107
+
108
+ it('should get the PayIn', function () {
109
+ expect(getPayIn.Id).to.equal(payIn.Id);
110
+ expect(getPayIn.PaymentType).to.equal('CARD');
111
+ expect(getPayIn.ExecutionType).to.equal('DIRECT');
112
+ expect(getPayIn.CardId).not.to.be.null;
113
+ });
114
+ });
115
+
116
+ describe('Create Refund', function () {
117
+ var refund;
118
+
119
+ before(function (done) {
120
+ helpers.getNewRefundForPayIn(api, john, payIn, function (data, response) {
121
+ refund = data;
122
+ done();
123
+ });
124
+ });
125
+
126
+ it('should succeed', function () {
127
+ expect(refund.DebitedFunds).to.eql(payIn.DebitedFunds);
128
+ expect(refund.Type).to.equal('PAYOUT');
129
+ expect(refund.Nature).to.equal('REFUND');
130
+ });
131
+ });
132
+
133
+ describe('Create Partial Refund', function () {
134
+ var refund;
135
+
136
+ before(function (done) {
137
+ helpers.getPartialRefundForPayIn(api, john, payIn, function (data, response) {
138
+ refund = data;
139
+ done();
140
+ });
141
+ });
142
+
143
+ it('should succeed', function () {
144
+ expect(refund.Id).to.not.be.null;
145
+ expect(refund.Type).to.equal('PAYOUT');
146
+ expect(refund.Nature).to.equal('REFUND');
147
+ });
148
+ });
149
+ });
150
+
151
+ describe('PreAuthorizedDirect', function () {
152
+ var preAuthorization, payIn, wallet;
153
+ var transactionsData;
154
+
155
+ before(function (done) {
156
+ helpers.getUserCardPreAuthorization(api, john, function (data, response) {
157
+ preAuthorization = data;
158
+
159
+ wallet = {
160
+ Owners: [john.Id],
161
+ Currency: 'EUR',
162
+ Description: 'WALLET IN EUR'
163
+ };
164
+
165
+ api.Wallets.create(wallet).then(function () {
166
+ payIn = {
167
+ CreditedWalletId: wallet.Id,
168
+ AuthorId: john.Id,
169
+ DebitedFunds: {
170
+ Amount: 1000,
171
+ Currency: 'EUR'
172
+ },
173
+ Fees: {
174
+ Amount: 0,
175
+ Currency: 'EUR'
176
+ },
177
+ CardId: preAuthorization.CardId,
178
+ SecureModeReturnURL: 'http://test.com',
179
+ PaymentType: 'PREAUTHORIZED',
180
+ ExecutionType: 'DIRECT',
181
+ PreauthorizationId: preAuthorization.Id
182
+ };
183
+
184
+ api.PayIns.create(payIn, async function (data, response) {
185
+ // wait 2 seconds for the transactions to be created by the API
186
+ const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
187
+ await delay(2000);
188
+ done();
189
+ });
190
+ });
191
+ });
192
+ });
193
+
194
+ it('should succeed', function () {
195
+ expect(payIn.Id).not.to.be.undefined;
196
+ expect(payIn.data.AuthorId).to.equal(john.Id);
197
+ expect(payIn.data.PaymentType).to.equal('PREAUTHORIZED');
198
+ expect(payIn.data.ExecutionType).to.equal('DIRECT');
199
+ expect(payIn.data.CardId).not.to.be.null;
200
+ expect(payIn.data.Type).to.equal('PAYIN');
201
+ expect(payIn.data.Status).to.equal('SUCCEEDED');
202
+ });
203
+
204
+ before(function(done){
205
+ api.CardPreAuthorizations.getTransactions(preAuthorization.Id, function(data, response){
206
+ transactionsData = data;
207
+ done();
208
+ });
209
+ });
210
+
211
+ it('should get transactions', function () {
212
+ expect(transactionsData[0].Status).to.not.equal('FAILED');
213
+ });
214
+ });
215
+
216
+ describe('BankWireDirect', function () {
217
+ var payIn, wallet;
218
+
219
+ before(function (done) {
220
+ wallet = {
221
+ Owners: [john.Id],
222
+ Currency: 'EUR',
223
+ Description: 'WALLET IN EUR'
224
+ };
225
+
226
+ api.Wallets.create(wallet).then(function () {
227
+ done();
228
+ });
229
+ });
230
+
231
+ describe('Create', function () {
232
+ before(function (done) {
233
+ payIn = {
234
+ CreditedWalletId: wallet.Id,
235
+ AuthorId: john.Id,
236
+ DeclaredDebitedFunds: {
237
+ Amount: 10000,
238
+ Currency: 'EUR'
239
+ },
240
+ DeclaredFees: {
241
+ Amount: 0,
242
+ Currency: 'EUR'
243
+ },
244
+ PaymentType: 'BANK_WIRE',
245
+ ExecutionType: 'DIRECT'
246
+ };
247
+
248
+ api.PayIns.create(payIn, function (data, response) {
249
+ done();
250
+ });
251
+ });
252
+
253
+ it('should succeed', function () {
254
+ expect(payIn.Id).not.to.be.undefined;
255
+ expect(payIn.data.AuthorId).to.equal(john.Id);
256
+ expect(payIn.data.PaymentType).to.equal('BANK_WIRE');
257
+ expect(payIn.data.ExecutionType).to.equal('DIRECT');
258
+ expect(payIn.data.Type).to.equal('PAYIN');
259
+ expect(payIn.data.Status).to.equal('CREATED');
260
+ });
261
+ });
262
+
263
+ describe('Get', function () {
264
+ var getPayIn;
265
+
266
+ before(function (done) {
267
+ api.PayIns.get(payIn.Id, function (data, response) {
268
+ getPayIn = data;
269
+ done();
270
+ });
271
+ });
272
+
273
+ it('should succeed', function () {
274
+ expect(getPayIn.Id).to.equal(payIn.Id);
275
+ expect(getPayIn.BankAccount.Type).to.equal('IBAN');
276
+ expect(getPayIn.AuthorId).to.equal(john.Id);
277
+ expect(getPayIn.ExecutionType).to.equal('DIRECT');
278
+ expect(getPayIn.Type).to.equal('PAYIN');
279
+ expect(getPayIn.Status).to.equal('CREATED');
280
+ });
281
+ });
282
+ });
283
+
284
+ describe('DirectDebitWeb', function () {
285
+ var payIn, wallet;
286
+
287
+ before(function (done) {
288
+ wallet = {
289
+ Owners: [john.Id],
290
+ Currency: 'EUR',
291
+ Description: 'WALLET IN EUR'
292
+ };
293
+
294
+ api.Wallets.create(wallet).then(function () {
295
+ done();
296
+ });
297
+ });
298
+
299
+ describe('Create', function () {
300
+ before(function (done) {
301
+ payIn = {
302
+ CreditedWalletId: wallet.Id,
303
+ AuthorId: john.Id,
304
+ DebitedFunds: {
305
+ Amount: 10000,
306
+ Currency: 'EUR'
307
+ },
308
+ Fees: {
309
+ Amount: 100,
310
+ Currency: 'EUR'
311
+ },
312
+ PaymentType: 'DIRECT_DEBIT',
313
+ ExecutionType: 'WEB',
314
+ DirectDebitType: 'GIROPAY',
315
+ ReturnURL: 'http://www.mysite.com/returnURL/',
316
+ Culture: 'FR',
317
+ PAYLINE: 'https://www.maysite.com/payline_template/'
318
+ };
319
+
320
+ api.PayIns.create(payIn, function (data, response) {
321
+ done();
322
+ });
323
+ });
324
+
325
+ it('should succeed', function () {
326
+ expect(payIn.Id).not.to.be.undefined;
327
+ expect(payIn.data.AuthorId).to.equal(john.Id);
328
+ expect(payIn.data.PaymentType).to.equal('DIRECT_DEBIT');
329
+ expect(payIn.data.ExecutionType).to.equal('WEB');
330
+ expect(payIn.data.CardId).not.to.be.null;
331
+ expect(payIn.data.Type).to.equal('PAYIN');
332
+ expect(payIn.data.Status).to.equal('CREATED');
333
+ });
334
+ });
335
+ });
336
+
337
+ describe('PayPalWeb', function () {
338
+ var payIn, wallet;
339
+
340
+ before(function (done) {
341
+ wallet = {
342
+ Owners: [john.Id],
343
+ Currency: 'EUR',
344
+ Description: 'WALLET IN EUR'
345
+ };
346
+
347
+ api.Wallets.create(wallet).then(function () {
348
+ done();
349
+ });
350
+ });
351
+
352
+ describe('Create', function () {
353
+ var shippingAddress = {
354
+ RecipientName: "Mangopay Test",
355
+ Address: {
356
+ "AddressLine1": "4101 Reservoir Rd NW",
357
+ "AddressLine2": "",
358
+ "City": "Washington",
359
+ "Region": "District of Columbia",
360
+ "PostalCode": "20007",
361
+ "Country": "US"
362
+ }
363
+ };
364
+
365
+ before(function (done) {
366
+ payIn = {
367
+ CreditedWalletId: wallet.Id,
368
+ AuthorId: john.Id,
369
+ CreditedUserId: john.Id,
370
+ DebitedFunds: {
371
+ Amount: 10000,
372
+ Currency: 'EUR'
373
+ },
374
+ Fees: {
375
+ Amount: 100,
376
+ Currency: 'EUR'
377
+ },
378
+ PaymentType: 'PAYPAL',
379
+ ExecutionType: 'WEB',
380
+ ReturnURL: 'http://www.mysite.com/returnURL/',
381
+ ShippingAddress: shippingAddress
382
+ };
383
+
384
+ api.PayIns.create(payIn, function (data, response) {
385
+ done();
386
+ });
387
+ });
388
+
389
+ it('should be created', function () {
390
+ expect(payIn.Id).not.to.be.undefined;
391
+ expect(payIn.data.AuthorId).to.equal(john.Id);
392
+ expect(payIn.data.PaymentType).to.equal('PAYPAL');
393
+ expect(payIn.data.ExecutionType).to.equal('WEB');
394
+ expect(payIn.data.CardId).not.to.be.null;
395
+ expect(payIn.data.Type).to.equal('PAYIN');
396
+ expect(payIn.data.Status).to.equal('CREATED');
397
+ });
398
+
399
+ describe('Get', function () {
400
+ var getPayIn;
401
+
402
+ before(function (done) {
403
+ api.PayIns.get(payIn.Id, function (data, response) {
404
+ getPayIn = data;
405
+ done();
406
+ });
407
+ });
408
+
409
+ it('should be retrieved', function () {
410
+ expect(getPayIn.Id).not.to.be.undefined;
411
+ expect(getPayIn.Id).to.equal(payIn.Id);
412
+ expect(getPayIn.ShippingAddress).not.to.be.undefined;
413
+ expect(getPayIn.ShippingAddress).to.deep.equal(shippingAddress);
414
+ });
415
+ });
416
+ });
417
+
418
+ describe.skip("Get with Email", function () {
419
+ console.warn("Cannot be tested. PayIn ID expired.");
420
+ var payInId = "54088959";
421
+ var accountEmail = "paypal-buyer-user@mangopay.com";
422
+ var payinWithEmail;
423
+
424
+ before(function (done) {
425
+ api.PayIns.get(payInId, function (data, response) {
426
+ payinWithEmail = data;
427
+ done();
428
+ });
429
+ });
430
+
431
+ it("should contain buyer's email", function () {
432
+ expect(payinWithEmail).not.to.be.undefined;
433
+ expect(payinWithEmail.Id).to.equal(payInId);
434
+ expect(payinWithEmail.PaypalBuyerAccountEmail).not.to.be.undefined;
435
+ expect(payinWithEmail.PaypalBuyerAccountEmail).to.equal(accountEmail);
436
+ });
437
+ });
438
+
439
+ });
440
+
441
+ // describe('ApplePay', function () {
442
+ // var applePayPayIn, wallet;
443
+
444
+ // before(function (done) {
445
+ // wallet = {
446
+ // Owners: [john.Id],
447
+ // Currency: 'EUR',
448
+ // Description: 'WALLET IN EUR'
449
+ // };
450
+
451
+ // api.Wallets.create(wallet).then(function () {
452
+ // done();
453
+ // });
454
+ // });
455
+
456
+ // describe('Create', function () {
457
+
458
+ // var paymentData = {
459
+ // TransactionId: '061EB32181A2D9CA42AD16031B476EEBAA62A9A095AD660E2759FBA52B51A61',
460
+ // Network: 'VISA',
461
+ // TokenData: "{\"version\":\"EC_v1\",\"data\":\"w4HMBVqNC9ghPP4zncTA\/0oQAsduERfsx78oxgniynNjZLANTL6+0koEtkQnW\/K38Zew8qV1GLp+fLHo+qCBpiKCIwlz3eoFBTbZU+8pYcjaeIYBX9SOxcwxXsNGrGLk+kBUqnpiSIPaAG1E+WPT8R1kjOCnGvtdombvricwRTQkGjtovPfzZo8LzD3ZQJnHMsWJ8QYDLyr\/ZN9gtLAtsBAMvwManwiaG3pOIWpyeOQOb01YcEVO16EZBjaY4x4C\/oyFLWDuKGvhbJwZqWh1d1o9JT29QVmvy3Oq2JEjq3c3NutYut4rwDEP4owqI40Nb7mP2ebmdNgnYyWfPmkRfDCRHIWtbMC35IPg5313B1dgXZ2BmyZRXD5p+mr67vAk7iFfjEpu3GieFqwZrTl3\/pI5V8Sxe3SIYKgT5Hr7ow==\",\"signature\":\"MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCAMIID5jCCA4ugAwIBAgIIaGD2mdnMpw8wCgYIKoZIzj0EAwIwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMB4XDTE2MDYwMzE4MTY0MFoXDTIxMDYwMjE4MTY0MFowYjEoMCYGA1UEAwwfZWNjLXNtcC1icm9rZXItc2lnbl9VQzQtU0FOREJPWDEUMBIGA1UECwwLaU9TIFN5c3RlbXMxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEgjD9q8Oc914gLFDZm0US5jfiqQHdbLPgsc1LUmeY+M9OvegaJajCHkwz3c6OKpbC9q+hkwNFxOh6RCbOlRsSlaOCAhEwggINMEUGCCsGAQUFBwEBBDkwNzA1BggrBgEFBQcwAYYpaHR0cDovL29jc3AuYXBwbGUuY29tL29jc3AwNC1hcHBsZWFpY2EzMDIwHQYDVR0OBBYEFAIkMAua7u1GMZekplopnkJxghxFMAwGA1UdEwEB\/wQCMAAwHwYDVR0jBBgwFoAUI\/JJxE+T5O8n5sT2KGw\/orv9LkswggEdBgNVHSAEggEUMIIBEDCCAQwGCSqGSIb3Y2QFATCB\/jCBwwYIKwYBBQUHAgIwgbYMgbNSZWxpYW5jZSBvbiB0aGlzIGNlcnRpZmljYXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRlIHBvbGljeSBhbmQgY2VydGlmaWNhdGlvbiBwcmFjdGljZSBzdGF0ZW1lbnRzLjA2BggrBgEFBQcCARYqaHR0cDovL3d3dy5hcHBsZS5jb20vY2VydGlmaWNhdGVhdXRob3JpdHkvMDQGA1UdHwQtMCswKaAnoCWGI2h0dHA6Ly9jcmwuYXBwbGUuY29tL2FwcGxlYWljYTMuY3JsMA4GA1UdDwEB\/wQEAwIHgDAPBgkqhkiG92NkBh0EAgUAMAoGCCqGSM49BAMCA0kAMEYCIQDaHGOui+X2T44R6GVpN7m2nEcr6T6sMjOhZ5NuSo1egwIhAL1a+\/hp88DKJ0sv3eT3FxWcs71xmbLKD\/QJ3mWagrJNMIIC7jCCAnWgAwIBAgIISW0vvzqY2pcwCgYIKoZIzj0EAwIwZzEbMBkGA1UEAwwSQXBwbGUgUm9vdCBDQSAtIEczMSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMwHhcNMTQwNTA2MjM0NjMwWhcNMjkwNTA2MjM0NjMwWjB6MS4wLAYDVQQDDCVBcHBsZSBBcHBsaWNhdGlvbiBJbnRlZ3JhdGlvbiBDQSAtIEczMSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATwFxGEGddkhdUaXiWBB3bogKLv3nuuTeCN\/EuT4TNW1WZbNa4i0Jd2DSJOe7oI\/XYXzojLdrtmcL7I6CmE\/1RFo4H3MIH0MEYGCCsGAQUFBwEBBDowODA2BggrBgEFBQcwAYYqaHR0cDovL29jc3AuYXBwbGUuY29tL29jc3AwNC1hcHBsZXJvb3RjYWczMB0GA1UdDgQWBBQj8knET5Pk7yfmxPYobD+iu\/0uSzAPBgNVHRMBAf8EBTADAQH\/MB8GA1UdIwQYMBaAFLuw3qFYM4iapIqZ3r6966\/ayySrMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHA6Ly9jcmwuYXBwbGUuY29tL2FwcGxlcm9vdGNhZzMuY3JsMA4GA1UdDwEB\/wQEAwIBBjAQBgoqhkiG92NkBgIOBAIFADAKBggqhkjOPQQDAgNnADBkAjA6z3KDURaZsYb7NcNWymK\/9Bft2Q91TaKOvvGcgV5Ct4n4mPebWZ+Y1UENj53pwv4CMDIt1UQhsKMFd2xd8zg7kGf9F3wsIW2WT8ZyaYISb1T4en0bmcubCYkhYQaZDwmSHQAAMYIBizCCAYcCAQEwgYYwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTAghoYPaZ2cynDzANBglghkgBZQMEAgEFAKCBlTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xOTA1MjMxMTA1MDdaMCoGCSqGSIb3DQEJNDEdMBswDQYJYIZIAWUDBAIBBQChCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIIvfGVQYBeOilcB7GNI8m8+FBVZ28QfA6BIXaggBja2PMAoGCCqGSM49BAMCBEYwRAIgU01yYfjlx9bvGeC5CU2RS5KBEG+15HH9tz\/sg3qmQ14CID4F4ZJwAz+tXAUcAIzoMpYSnM8YBlnGJSTSp+LhspenAAAAAAAA\",\"header\":{\"ephemeralPublicKey\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE0rs3wRpirXjPbFDQfPRdfEzRIZDWm0qn7Y0HB0PNzV1DDKfpYrnhRb4GEhBF\/oEXBOe452PxbCnN1qAlqcSUWw==\",\"publicKeyHash\":\"saPRAqS7TZ4bAYwzBj8ezDDC55ZolyH1FL+Xc8fd93o=\",\"transactionId\":\"b061eb32181a2d9ca42ad16031b476eebaa62a9a095ad660e2759fba52b51a61\"}}"
462
+ // };
463
+
464
+ // before(function (done) {
465
+ // applePayPayIn = {
466
+ // CreditedWalletId: wallet.Id,
467
+ // AuthorId: john.Id,
468
+ // CreditedUserId: john.Id,
469
+ // DebitedFunds: {
470
+ // Amount: 199,
471
+ // Currency: 'EUR'
472
+ // },
473
+ // Fees: {
474
+ // Amount: 1,
475
+ // Currency: 'EUR'
476
+ // },
477
+ // PaymentType: 'APPLEPAY',
478
+ // ExecutionType: 'DIRECT',
479
+ // PaymentData: paymentData,
480
+ // Tag: "Create an ApplePay card direct Payin",
481
+ // StatementDescriptor: "php"
482
+ // };
483
+
484
+ // api.PayIns.create(applePayPayIn, function (data, response) {
485
+ // done();
486
+ // });
487
+ // });
488
+
489
+ // it('should be created', function () {
490
+ // expect(applePayPayIn.Id).not.to.be.undefined;
491
+ // expect(applePayPayIn.data.AuthorId).to.equal(john.Id);
492
+ // expect(applePayPayIn.data.PaymentType).to.equal('APPLEPAY');
493
+ // expect(applePayPayIn.data.ExecutionType).to.equal('DIRECT');
494
+ // expect(applePayPayIn.data.Type).to.equal('PAYIN');
495
+ // expect(applePayPayIn.data.Status).to.equal('SUCCEEDED');
496
+ // });
497
+ // });
498
+ // });
499
+
500
+ describe.skip('GooglePay', function () {
501
+ var googlePayIn, wallet;
502
+
503
+ before(function (done) {
504
+ wallet = {
505
+ Owners: [john.Id],
506
+ Currency: 'EUR',
507
+ Description: 'WALLET IN EUR'
508
+ };
509
+
510
+ api.Wallets.create(wallet).then(function () {
511
+ done();
512
+ });
513
+ });
514
+
515
+ describe('Create', function () {
516
+
517
+ var paymentData = {
518
+ TransactionId: 'placeholder',
519
+ Network: 'placeholder',
520
+ TokenData: "placeholder"
521
+ };
522
+
523
+ before(function (done) {
524
+ googlePayIn = {
525
+ CreditedWalletId: wallet.Id,
526
+ AuthorId: john.Id,
527
+ CreditedUserId: john.Id,
528
+ DebitedFunds: {
529
+ Amount: 199,
530
+ Currency: 'EUR'
531
+ },
532
+ Fees: {
533
+ Amount: 1,
534
+ Currency: 'EUR'
535
+ },
536
+ PaymentType: 'GOOGLEPAY',
537
+ ExecutionType: 'DIRECT',
538
+ PaymentData: paymentData,
539
+ Tag: "Create an GooglePay card direct Payin",
540
+ StatementDescriptor: "php"
541
+ };
542
+
543
+ api.PayIns.create(googlePayIn, function (data, response) {
544
+ done();
545
+ });
546
+ });
547
+
548
+ it('should be created', function () {
549
+ expect(googlePayIn.Id).not.to.be.undefined;
550
+ expect(googlePayIn.data.AuthorId).to.equal(john.Id);
551
+ expect(googlePayIn.data.PaymentType).to.equal('GOOGLEPAY');
552
+ expect(googlePayIn.data.ExecutionType).to.equal('DIRECT');
553
+ expect(googlePayIn.data.Type).to.equal('PAYIN');
554
+ expect(googlePayIn.data.Status).to.equal('SUCCEEDED');
555
+ });
556
+ });
557
+ });
558
+
559
+ describe('Get Refunds', function () {
560
+ var getRefunds;
561
+
562
+ before(function (done) {
563
+ api.PayIns.getRefunds(payIn.Id, function (data, response) {
564
+ getRefunds = data;
565
+ done();
566
+ });
567
+ });
568
+
569
+ it('should be retrieved', function () {
570
+ expect(getRefunds).not.to.be.undefined;
571
+ expect(getRefunds).to.be.an('array');
572
+ });
573
+ });
574
+
575
+ describe('ExetrnalInstructionIBAN', function () {
576
+
577
+ describe('Get', function () {
578
+ var getPayIn;
579
+ before(function (done) {
580
+ api.PayIns.get("payin_m_01JFA5CSPT3QBECGYDX6AKQ3QD", function (data, response) {
581
+ getPayIn = data;
582
+ done()
583
+ });
584
+ });
585
+
586
+ it('should get the PayIn', function () {
587
+ expect(getPayIn.PaymentType).to.equal('BANK_WIRE');
588
+ expect(getPayIn.ExecutionType).to.equal('EXTERNAL_INSTRUCTION');
589
+ expect(getPayIn.DebitedBankAccount.Type).to.equal('IBAN');
590
+ expect(getPayIn.DebitedBankAccount.IBAN).not.to.be.null;
591
+ expect(getPayIn.DebitedBankAccount.AccountNumber).to.be.null;
592
+ });
593
+ });
594
+ });
595
+
596
+ /*
597
+ describe('ExetrnalInstructionAccountNumber', function () {
598
+
599
+ describe('Get', function () {
600
+ var getPayIn;
601
+ before(function (done) {
602
+ api.PayIns.get("74981216", function (data, response) {
603
+ getPayIn = data;
604
+ done()
605
+ });
606
+ });
607
+
608
+ it('should get the PayIn', function () {
609
+ expect(getPayIn.PaymentType).to.equal('BANK_WIRE');
610
+ expect(getPayIn.ExecutionType).to.equal('EXTERNAL_INSTRUCTION');
611
+ expect(getPayIn.DebitedBankAccount.Type).to.equal('OTHER');
612
+ expect(getPayIn.DebitedBankAccount.IBAN).to.be.null;
613
+ expect(getPayIn.DebitedBankAccount.AccountNumber).not.to.be.null;
614
+ });
615
+ });
616
+ });
617
+ */
618
+
619
+ describe('Recurring Payments', function() {
620
+ var cardId;
621
+ var walletId;
622
+ var createdPayPalCit;
623
+ before('Create a wallet with money and a card', function(done){
624
+ wallet = {
625
+ Owners: [john.Id],
626
+ Currency: 'EUR',
627
+ Description: 'WALLET IN EUR'
628
+ };
629
+ cardRegistration = {
630
+ UserId: john.Id,
631
+ Currency: 'EUR'
632
+ };
633
+ api.Wallets.create(wallet).then(function(){
634
+ api.CardRegistrations.create(cardRegistration, function() {
635
+ helpers.getPaylineCorrectRegistartionData(cardRegistration, function(data, response){
636
+ cardRegistration.RegistrationData = data;
637
+ api.CardRegistrations.update(cardRegistration).then(function(data){
638
+ updatedCardRegistration = data;
639
+ cardId = updatedCardRegistration.CardId;
640
+ walletId = wallet.Id;
641
+ api.Cards.get(cardRegistration.CardId, function(data, response) {
642
+ card = data;
643
+ api.PayIns.create({
644
+ CreditedWalletId: wallet.Id,
645
+ AuthorId: john.Id,
646
+ DebitedFunds: {
647
+ Amount: 100,
648
+ Currency: 'EUR'
649
+ },
650
+ Fees: {
651
+ Amount: 0,
652
+ Currency: 'EUR'
653
+ },
654
+ CardId: card.Id,
655
+ SecureMode: 'DEFAULT',
656
+ SecureModeReturnURL: 'https://test.com',
657
+ PaymentType: 'CARD',
658
+ ExecutionType: 'DIRECT',
659
+ BrowserInfo: {
660
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
661
+ JavaEnabled: true,
662
+ Language: "FR-FR",
663
+ ColorDepth: 4,
664
+ ScreenHeight: 1800,
665
+ ScreenWidth: 400,
666
+ JavascriptEnabled: true,
667
+ TimeZoneOffset: "+60",
668
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
669
+ },
670
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C"
671
+ }, function(data, response) {
672
+ done();
673
+ });
674
+ });
675
+ });
676
+ });
677
+ });
678
+ });
679
+ });
680
+
681
+ describe('Create a Recurring Payment', function() {
682
+ var recurring;
683
+ before(function(done){
684
+ recurringPayin = {
685
+ AuthorId: john.Id,
686
+ CardId: cardId,
687
+ CreditedUserId: john.Id,
688
+ CreditedWalletId: walletId,
689
+ FirstTransactionDebitedFunds: {
690
+ Amount: 10,
691
+ Currency: 'EUR'
692
+ },
693
+ FirstTransactionFees: {
694
+ Amount: 1,
695
+ Currency: 'EUR'
696
+ },
697
+ Billing: {
698
+ FirstName: 'Joe',
699
+ LastName: 'Blogs',
700
+ Address: {
701
+ AddressLine1: '1 MangoPay Street',
702
+ AddressLine2: 'The Loop',
703
+ City: 'Paris',
704
+ Region: 'Ile de France',
705
+ PostalCode: '75001',
706
+ Country: 'FR'
707
+ }
708
+ },
709
+ Shipping: {
710
+ FirstName: 'Joe',
711
+ LastName: 'Blogs',
712
+ Address: {
713
+ AddressLine1: '1 MangoPay Street',
714
+ AddressLine2: 'The Loop',
715
+ City: 'Paris',
716
+ Region: 'Ile de France',
717
+ PostalCode: '75001',
718
+ Country: 'FR'
719
+ }
720
+ },
721
+ FreeCycles: 0
722
+ };
723
+
724
+ api.PayIns.createRecurringPayment(recurringPayin, function(data, response){
725
+ recurring = data;
726
+ }).then(function(){
727
+ cit = {
728
+ RecurringPayinRegistrationId: recurring.Id,
729
+ BrowserInfo: {
730
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
731
+ JavaEnabled: true,
732
+ Language: "FR-FR",
733
+ ColorDepth: 4,
734
+ ScreenHeight: 1800,
735
+ ScreenWidth: 400,
736
+ JavascriptEnabled: true,
737
+ TimeZoneOffset: "+60",
738
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
739
+ },
740
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
741
+ SecureModeReturnURL: "http://www.my-site.com/returnurl",
742
+ StatementDescriptor: "lorem",
743
+ Tag: "custom meta",
744
+ DebitedFunds: {
745
+ Amount: 10,
746
+ Currency: 'EUR'
747
+ },
748
+ Fees: {
749
+ Amount: 1,
750
+ Currency: 'EUR'
751
+ },
752
+ };
753
+
754
+ api.PayIns.createRecurringPayInRegistrationCIT(cit, function(data, response){
755
+ createCit = data;
756
+ done();
757
+ })
758
+ })
759
+ })
760
+
761
+ it('should be created', function() {
762
+ expect(recurring).to.not.be.null;
763
+ expect(recurring.FreeCycles).to.not.be.null;
764
+ expect(createCit).to.not.be.null;
765
+ })
766
+ })
767
+
768
+ describe('Create a PayPal Recurring Payment CIT', function() {
769
+ var recurring;
770
+ before(function(done){
771
+ var recurringPayinRegistration = {
772
+ AuthorId: john.Id,
773
+ CreditedWalletId: walletId,
774
+ FirstTransactionDebitedFunds: {
775
+ Amount: 1000,
776
+ Currency: 'EUR'
777
+ },
778
+ FirstTransactionFees: {
779
+ Amount: 1,
780
+ Currency: 'EUR'
781
+ },
782
+ Billing: {
783
+ FirstName: 'Joe',
784
+ LastName: 'Blogs',
785
+ Address: {
786
+ AddressLine1: '1 MangoPay Street',
787
+ AddressLine2: 'The Loop',
788
+ City: 'Paris',
789
+ Region: 'Ile de France',
790
+ PostalCode: '75001',
791
+ Country: 'FR'
792
+ }
793
+ },
794
+ Shipping: {
795
+ FirstName: 'Joe',
796
+ LastName: 'Blogs',
797
+ Address: {
798
+ AddressLine1: '1 MangoPay Street',
799
+ AddressLine2: 'The Loop',
800
+ City: 'Paris',
801
+ Region: 'Ile de France',
802
+ PostalCode: '75001',
803
+ Country: 'FR'
804
+ }
805
+ },
806
+ PaymentType: 'PAYPAL'
807
+ };
808
+
809
+ api.PayIns.createRecurringPayment(recurringPayinRegistration, function(data, response){
810
+ recurringPayinRegistration = data;
811
+ }).then(function(){
812
+ var cit = {
813
+ RecurringPayinRegistrationId: recurringPayinRegistration.Id,
814
+ StatementDescriptor: "lorem",
815
+ Tag: "custom meta",
816
+ LineItems: [
817
+ {
818
+ Name: "running shoes",
819
+ Quantity: 1,
820
+ UnitAmount: 1000,
821
+ TaxAmount: 0,
822
+ Description: "seller1 ID"
823
+ }
824
+ ],
825
+ ReturnURL: 'http://example.com',
826
+ CancelURL: 'http://example.net',
827
+ ShippingPreference: 'SET_PROVIDED_ADDRESS',
828
+ Reference: 'abcd-efgh-ijkl'
829
+ };
830
+
831
+ api.PayIns.createRecurringPayPalPayInCIT(cit, function(data){
832
+ createdPayPalCit = data;
833
+ done();
834
+ });
835
+ });
836
+ });
837
+
838
+ it('should be created', function() {
839
+ expect(createdPayPalCit).to.not.be.null;
840
+ // expect(createdPayPalCit.Status).to.eq('CREATED');
841
+ expect(createdPayPalCit.PaymentType).to.eq('PAYPAL');
842
+ expect(createdPayPalCit.ExecutionType).to.eq('WEB');
843
+ });
844
+ });
845
+
846
+ describe('Create a Recurring Payment Check Card Info', function() {
847
+ var recurring;
848
+ before(function(done){
849
+ recurringPayin = {
850
+ AuthorId: john.Id,
851
+ CardId: cardId,
852
+ CreditedUserId: john.Id,
853
+ CreditedWalletId: walletId,
854
+ FirstTransactionDebitedFunds: {
855
+ Amount: 10,
856
+ Currency: 'EUR'
857
+ },
858
+ FirstTransactionFees: {
859
+ Amount: 1,
860
+ Currency: 'EUR'
861
+ },
862
+ Billing: {
863
+ FirstName: 'Joe',
864
+ LastName: 'Blogs',
865
+ Address: {
866
+ AddressLine1: '1 MangoPay Street',
867
+ AddressLine2: 'The Loop',
868
+ City: 'Paris',
869
+ Region: 'Ile de France',
870
+ PostalCode: '75001',
871
+ Country: 'FR'
872
+ }
873
+ },
874
+ Shipping: {
875
+ FirstName: 'Joe',
876
+ LastName: 'Blogs',
877
+ Address: {
878
+ AddressLine1: '1 MangoPay Street',
879
+ AddressLine2: 'The Loop',
880
+ City: 'Paris',
881
+ Region: 'Ile de France',
882
+ PostalCode: '75001',
883
+ Country: 'FR'
884
+ }
885
+ },
886
+ FreeCycles: 0
887
+ };
888
+
889
+ api.PayIns.createRecurringPayment(recurringPayin, function(data, response){
890
+ recurring = data;
891
+ }).then(function(){
892
+ cit = {
893
+ RecurringPayinRegistrationId: recurring.Id,
894
+ BrowserInfo: {
895
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
896
+ JavaEnabled: true,
897
+ Language: "FR-FR",
898
+ ColorDepth: 4,
899
+ ScreenHeight: 1800,
900
+ ScreenWidth: 400,
901
+ JavascriptEnabled: true,
902
+ TimeZoneOffset: "+60",
903
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
904
+ },
905
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
906
+ SecureModeReturnURL: "http://www.my-site.com/returnurl",
907
+ StatementDescriptor: "lorem",
908
+ Tag: "custom meta",
909
+ DebitedFunds: {
910
+ Amount: 10,
911
+ Currency: 'EUR'
912
+ },
913
+ Fees: {
914
+ Amount: 1,
915
+ Currency: 'EUR'
916
+ },
917
+ };
918
+
919
+ api.PayIns.createRecurringPayInRegistrationCIT(cit, function(data, response){
920
+ createCit = data;
921
+ done();
922
+ });
923
+ });
924
+ });
925
+
926
+ it('should be created', function() {
927
+ expect(createCit.CardInfo).to.not.be.null;
928
+ // expect(createCit.CardInfo.Type).to.not.be.null;
929
+ // expect(createCit.CardInfo.Brand).to.not.be.null;
930
+ // expect(createCit.CardInfo.IssuingBank).to.not.be.null;
931
+ // expect(createCit.CardInfo.BIN).to.not.be.null;
932
+ });
933
+ });
934
+
935
+ describe('Get Recurring Payment', function () {
936
+ var recurring;
937
+ before(function(done){
938
+ recurringPayin = {
939
+ AuthorId: john.Id,
940
+ CardId: cardId,
941
+ CreditedUserId: john.Id,
942
+ CreditedWalletId: walletId,
943
+ FirstTransactionDebitedFunds: {
944
+ Amount: 10,
945
+ Currency: 'EUR'
946
+ },
947
+ FirstTransactionFees: {
948
+ Amount: 1,
949
+ Currency: 'EUR'
950
+ },
951
+ Billing: {
952
+ FirstName: 'Joe',
953
+ LastName: 'Blogs',
954
+ Address: {
955
+ AddressLine1: '1 MangoPay Street',
956
+ AddressLine2: 'The Loop',
957
+ City: 'Paris',
958
+ Region: 'Ile de France',
959
+ PostalCode: '75001',
960
+ Country: 'FR'
961
+ }
962
+ },
963
+ Shipping: {
964
+ FirstName: 'Joe',
965
+ LastName: 'Blogs',
966
+ Address: {
967
+ AddressLine1: '1 MangoPay Street',
968
+ AddressLine2: 'The Loop',
969
+ City: 'Paris',
970
+ Region: 'Ile de France',
971
+ PostalCode: '75001',
972
+ Country: 'FR'
973
+ }
974
+ },
975
+ FreeCycles: 0
976
+ };
977
+
978
+ api.PayIns.createRecurringPayment(recurringPayin, function(data, response){
979
+ recurring = data;
980
+ }).then(function(){
981
+ api.PayIns.getRecurringPayin(recurring.Id, function (data, response) {
982
+ getRecurring = data;
983
+ done();
984
+ });
985
+ });
986
+ });
987
+
988
+ it('should get the RecurringPayin', function () {
989
+ expect(getRecurring.Id).not.to.be.undefined;
990
+ expect(getRecurring.Status).not.to.be.undefined;
991
+ expect(getRecurring.FreeCycles).not.to.be.undefined;
992
+ });
993
+ });
994
+
995
+ describe('Update Recurring Payment', function () {
996
+ var recurring, updateRec;
997
+ before(function(done){
998
+ recurringPayin = {
999
+ AuthorId: john.Id,
1000
+ CardId: cardId,
1001
+ CreditedUserId: john.Id,
1002
+ CreditedWalletId: walletId,
1003
+ FirstTransactionDebitedFunds: {
1004
+ Amount: 10,
1005
+ Currency: 'EUR'
1006
+ },
1007
+ FirstTransactionFees: {
1008
+ Amount: 1,
1009
+ Currency: 'EUR'
1010
+ },
1011
+ Billing: {
1012
+ FirstName: 'Joe',
1013
+ LastName: 'Blogs',
1014
+ Address: {
1015
+ AddressLine1: '1 MangoPay Street',
1016
+ AddressLine2: 'The Loop',
1017
+ City: 'Paris',
1018
+ Region: 'Ile de France',
1019
+ PostalCode: '75001',
1020
+ Country: 'FR'
1021
+ }
1022
+ },
1023
+ Shipping: {
1024
+ FirstName: 'Joe',
1025
+ LastName: 'Blogs',
1026
+ Address: {
1027
+ AddressLine1: '1 MangoPay Street',
1028
+ AddressLine2: 'The Loop',
1029
+ City: 'Paris',
1030
+ Region: 'Ile de France',
1031
+ PostalCode: '75001',
1032
+ Country: 'FR'
1033
+ }
1034
+ }
1035
+ };
1036
+
1037
+ api.PayIns.createRecurringPayment(recurringPayin, function (data, response) {
1038
+ recurring = data;
1039
+ }).then(function () {
1040
+ updateObj = {
1041
+ Billing: {
1042
+ FirstName: 'TEST',
1043
+ LastName: 'TEST',
1044
+ Address: {
1045
+ AddressLine1: '1 MangoPay Street',
1046
+ AddressLine2: 'The Loop',
1047
+ City: 'Paris',
1048
+ Region: 'Ile de France',
1049
+ PostalCode: '75001',
1050
+ Country: 'FR'
1051
+ }
1052
+ },
1053
+ Shipping: {
1054
+ FirstName: 'TEST',
1055
+ LastName: 'TEST',
1056
+ Address: {
1057
+ AddressLine1: '1 MangoPay Street',
1058
+ AddressLine2: 'The Loop',
1059
+ City: 'Paris',
1060
+ Region: 'Ile de France',
1061
+ PostalCode: '75001',
1062
+ Country: 'FR'
1063
+ }
1064
+ },
1065
+ Status: "ENDED"
1066
+ };
1067
+
1068
+ api.PayIns.updateRecurringPayin(recurring.Id, updateObj, function (data, response) {
1069
+ updateRec = data;
1070
+ done();
1071
+ });
1072
+ });
1073
+ });
1074
+
1075
+ it('should get the updated RecurringPayin', function () {
1076
+ expect(updateRec.Id).not.to.be.undefined;
1077
+ expect(updateRec.Status).not.to.be.undefined;
1078
+ expect(updateRec.Status).to.equal("ENDED");
1079
+ });
1080
+ });
1081
+ });
1082
+
1083
+ describe('Payconiq Web', function () {
1084
+ var payIn, wallet;
1085
+
1086
+ before(function (done) {
1087
+ wallet = {
1088
+ Owners: [john.Id],
1089
+ Currency: 'EUR',
1090
+ Description: 'WALLET IN EUR'
1091
+ };
1092
+
1093
+ api.Wallets.create(wallet).then(function () {
1094
+ payIn = {
1095
+ Tag: 'custom meta',
1096
+ CreditedWalletId: wallet.Id,
1097
+ AuthorId: john.Id,
1098
+ DebitedFunds: {
1099
+ Amount: 1000,
1100
+ Currency: 'EUR'
1101
+ },
1102
+ Fees: {
1103
+ Amount: 0,
1104
+ Currency: 'EUR'
1105
+ },
1106
+ PaymentType: 'PAYCONIQ',
1107
+ ExecutionType: 'WEB',
1108
+ ReturnURL: 'http://www.my-site.com/returnURL',
1109
+ Country: 'BE'
1110
+ };
1111
+
1112
+ api.PayIns.create(payIn, function (data, response) {
1113
+ payIn = data;
1114
+ done();
1115
+ });
1116
+ });
1117
+ });
1118
+
1119
+ describe('Create', function () {
1120
+ it('should create the PayIn', function () {
1121
+ expect(payIn.Id).not.to.be.undefined;
1122
+ expect(payIn.PaymentType).to.equal('PAYCONIQ');
1123
+ expect(payIn.ExecutionType).to.equal('WEB');
1124
+ expect(payIn.Status).to.equal('CREATED');
1125
+ expect(payIn.RedirectURL).not.to.be.undefined;
1126
+ expect(payIn.DeepLinkURL).not.to.be.undefined;
1127
+ });
1128
+ });
1129
+
1130
+ describe('Get', function () {
1131
+ var getPayIn;
1132
+ before(function (done) {
1133
+ api.PayIns.get(payIn.Id, function (data, response) {
1134
+ getPayIn = data;
1135
+ done()
1136
+ });
1137
+ });
1138
+
1139
+ it('should get the PayIn', function () {
1140
+ expect(getPayIn.Id).not.to.be.undefined;
1141
+ expect(getPayIn.PaymentType).to.equal('PAYCONIQ');
1142
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1143
+ expect(getPayIn.Status).to.equal('CREATED');
1144
+ expect(payIn.RedirectURL).not.to.be.undefined;
1145
+ expect(payIn.DeepLinkURL).not.to.be.undefined;
1146
+ });
1147
+ });
1148
+ });
1149
+
1150
+ describe('Payconiq Web V2', function () {
1151
+ var payIn, wallet;
1152
+
1153
+ before(function (done) {
1154
+ wallet = {
1155
+ Owners: [john.Id],
1156
+ Currency: 'EUR',
1157
+ Description: 'WALLET IN EUR'
1158
+ };
1159
+
1160
+ api.Wallets.create(wallet).then(function () {
1161
+ payIn = {
1162
+ Tag: 'custom meta',
1163
+ CreditedWalletId: wallet.Id,
1164
+ AuthorId: john.Id,
1165
+ DebitedFunds: {
1166
+ Amount: 100,
1167
+ Currency: 'EUR'
1168
+ },
1169
+ Fees: {
1170
+ Amount: 0,
1171
+ Currency: 'EUR'
1172
+ },
1173
+ PaymentType: 'PAYCONIQ',
1174
+ ExecutionType: 'WEB',
1175
+ ReturnURL: 'http://www.my-site.com/returnURL',
1176
+ Country: 'BE'
1177
+ };
1178
+
1179
+ api.PayIns.createPayconiq(payIn, function (data, response) {
1180
+ payIn = data;
1181
+ done();
1182
+ });
1183
+ });
1184
+ });
1185
+
1186
+ describe('Create', function () {
1187
+ it('should create the PayIn', function () {
1188
+ expect(payIn.Id).not.to.be.undefined;
1189
+ expect(payIn.PaymentType).to.equal('PAYCONIQ');
1190
+ expect(payIn.ExecutionType).to.equal('WEB');
1191
+ expect(payIn.Status).to.equal('CREATED');
1192
+ expect(payIn.RedirectURL).not.to.be.undefined;
1193
+ expect(payIn.DeepLinkURL).not.to.be.undefined;
1194
+ expect(payIn.QRCodeURL).not.to.be.undefined;
1195
+ });
1196
+ });
1197
+ });
1198
+
1199
+ describe('Mbway Web', function () {
1200
+ var payIn;
1201
+
1202
+ before(function (done) {
1203
+ helpers.getNewPayInMbwayWeb(api, john, function (data, response) {
1204
+ payIn = data;
1205
+ done();
1206
+ });
1207
+ });
1208
+
1209
+ describe('Create', function () {
1210
+ it('should create the PayIn', function () {
1211
+ expect(payIn.Id).not.to.be.undefined;
1212
+ expect(payIn.PaymentType).to.equal('MBWAY');
1213
+ expect(payIn.ExecutionType).to.equal('WEB');
1214
+ expect(payIn.AuthorId).to.equal(john.Id);
1215
+ expect(payIn.Status).to.equal('CREATED');
1216
+ expect(payIn.Type).to.equal('PAYIN');
1217
+ expect(payIn.Phone).not.to.be.null;
1218
+ });
1219
+ });
1220
+
1221
+ describe('Get', function () {
1222
+ var getPayIn;
1223
+ before(function (done) {
1224
+ api.PayIns.get(payIn.Id, function (data, response) {
1225
+ getPayIn = data;
1226
+ done()
1227
+ });
1228
+ });
1229
+
1230
+ it('should get the PayIn', function () {
1231
+ expect(getPayIn.Id).to.equal(payIn.Id);
1232
+ expect(getPayIn.PaymentType).to.equal('MBWAY');
1233
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1234
+ expect(getPayIn.Phone).not.to.be.null;
1235
+ });
1236
+ });
1237
+ });
1238
+
1239
+ describe('Bancontact Web', function () {
1240
+ var payIn;
1241
+
1242
+ before(function (done) {
1243
+ helpers.getNewPayInBancontactWeb(api, john, function (data, response) {
1244
+ payIn = data;
1245
+ done();
1246
+ });
1247
+ });
1248
+
1249
+ describe('Create', function () {
1250
+ it('should create the PayIn', function () {
1251
+ expect(payIn.Id).not.to.be.undefined;
1252
+ expect(payIn.PaymentType).to.equal('BCMC');
1253
+ expect(payIn.ExecutionType).to.equal('WEB');
1254
+ expect(payIn.AuthorId).to.equal(john.Id);
1255
+ expect(payIn.Status).to.equal('CREATED');
1256
+ expect(payIn.Type).to.equal('PAYIN');
1257
+ expect(payIn.Recurring).not.to.be.null;
1258
+ });
1259
+ });
1260
+
1261
+ describe('Get', function () {
1262
+ var getPayIn;
1263
+ before(function (done) {
1264
+ api.PayIns.get(payIn.Id, function (data, response) {
1265
+ getPayIn = data;
1266
+ done()
1267
+ });
1268
+ });
1269
+
1270
+ it('should get the PayIn', function () {
1271
+ expect(getPayIn.Id).to.equal(payIn.Id);
1272
+ expect(getPayIn.PaymentType).to.equal('BCMC');
1273
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1274
+ expect(getPayIn.Phone).not.to.be.null;
1275
+ });
1276
+ });
1277
+ });
1278
+
1279
+ describe('Bizum Web', function () {
1280
+ var payInWithPhone;
1281
+ var payInWithReturnUrl;
1282
+
1283
+ before(function (done) {
1284
+ helpers.getNewPayInBizumWebWithPhone(api, john, function (data, response) {
1285
+ payInWithPhone = data;
1286
+ helpers.getNewPayInBizumWebWithReturnUrl(api, john, function (data) {
1287
+ payInWithReturnUrl = data;
1288
+ done();
1289
+ });
1290
+ });
1291
+ });
1292
+
1293
+ describe('Create', function () {
1294
+ it('should create Bizum PayIn with Phone', function () {
1295
+ expect(payInWithPhone.Id).not.to.be.undefined;
1296
+ expect(payInWithPhone.PaymentType).to.equal('BIZUM');
1297
+ expect(payInWithPhone.ExecutionType).to.equal('WEB');
1298
+ expect(payInWithPhone.AuthorId).to.equal(john.Id);
1299
+ expect(payInWithPhone.Status).to.equal('CREATED');
1300
+ expect(payInWithPhone.Type).to.equal('PAYIN');
1301
+ expect(payInWithPhone.Phone).not.to.be.null;
1302
+ expect(payInWithPhone.ReturnURL).to.be.undefined;
1303
+ });
1304
+ it('should create Bizum PayIn with ReturnUrl', function () {
1305
+ expect(payInWithReturnUrl.Id).not.to.be.undefined;
1306
+ expect(payInWithReturnUrl.PaymentType).to.equal('BIZUM');
1307
+ expect(payInWithReturnUrl.ExecutionType).to.equal('WEB');
1308
+ expect(payInWithReturnUrl.AuthorId).to.equal(john.Id);
1309
+ expect(payInWithReturnUrl.Status).to.equal('CREATED');
1310
+ expect(payInWithReturnUrl.Type).to.equal('PAYIN');
1311
+ expect(payInWithReturnUrl.Phone).to.be.null;
1312
+ expect(payInWithReturnUrl.ReturnURL).not.to.be.null;
1313
+ });
1314
+ });
1315
+
1316
+ describe('Get', function () {
1317
+ var getPayInWithPhone;
1318
+ var getPayInWithReturnUrl;
1319
+
1320
+ before(function (done) {
1321
+ api.PayIns.get(payInWithPhone.Id, function (data, response) {
1322
+ getPayInWithPhone = data;
1323
+ api.PayIns.get(payInWithReturnUrl.Id, function (data, response) {
1324
+ getPayInWithReturnUrl = data;
1325
+ done();
1326
+ });
1327
+ });
1328
+ });
1329
+
1330
+ it('should get Bizum PayIn with Phone', function () {
1331
+ expect(getPayInWithPhone.Id).to.equal(payInWithPhone.Id);
1332
+ expect(getPayInWithPhone.PaymentType).to.equal('BIZUM');
1333
+ expect(getPayInWithPhone.ExecutionType).to.equal('WEB');
1334
+ expect(getPayInWithPhone.Phone).not.to.be.null;
1335
+ expect(getPayInWithPhone.Phone).to.equal(payInWithPhone.Phone);
1336
+ expect(getPayInWithPhone.ReturnURL).to.equal(payInWithPhone.ReturnURL);
1337
+ expect(getPayInWithPhone.ReturnURL).to.be.undefined;
1338
+ });
1339
+
1340
+ it('should get the Bizum with ReturnUrl', function () {
1341
+ expect(getPayInWithReturnUrl.Id).to.equal(payInWithReturnUrl.Id);
1342
+ expect(getPayInWithReturnUrl.PaymentType).to.equal('BIZUM');
1343
+ expect(getPayInWithReturnUrl.ExecutionType).to.equal('WEB');
1344
+ expect(getPayInWithReturnUrl.Phone).to.be.null;
1345
+ expect(getPayInWithReturnUrl.ReturnURL).not.to.be.null;
1346
+ expect(getPayInWithReturnUrl.ReturnURL).to.equal(payInWithReturnUrl.ReturnURL);
1347
+ });
1348
+ });
1349
+ });
1350
+
1351
+ describe('PayPal Web V2', function () {
1352
+ var payIn;
1353
+
1354
+ before(function (done) {
1355
+ helpers.getNewPayInPayPalWeb(api, john, function (data, response) {
1356
+ payIn = data;
1357
+ done();
1358
+ });
1359
+ });
1360
+
1361
+ describe('Create', function () {
1362
+ it('should create the PayIn', function () {
1363
+ expect(payIn.Id).not.to.be.undefined;
1364
+ expect(payIn.PaymentType).to.equal('PAYPAL');
1365
+ expect(payIn.ExecutionType).to.equal('WEB');
1366
+ expect(payIn.AuthorId).to.equal(john.Id);
1367
+ // expect(payIn.Status).to.equal('CREATED');
1368
+ expect(payIn.Type).to.equal('PAYIN');
1369
+ expect(payIn.LineItems).not.to.be.null;
1370
+ });
1371
+ });
1372
+
1373
+ describe('Get', function () {
1374
+ var getPayIn;
1375
+ before(function (done) {
1376
+ api.PayIns.get(payIn.Id, function (data, response) {
1377
+ getPayIn = data;
1378
+ done()
1379
+ });
1380
+ });
1381
+
1382
+ it('should get the PayIn', function () {
1383
+ expect(getPayIn.Id).to.equal(payIn.Id);
1384
+ expect(getPayIn.PaymentType).to.equal('PAYPAL');
1385
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1386
+ });
1387
+ });
1388
+ })
1389
+
1390
+ describe('Multibanco Web', function () {
1391
+ var payIn;
1392
+
1393
+ before(function (done) {
1394
+ helpers.getNewPayInMultibancoWeb(api, john, function (data) {
1395
+ payIn = data;
1396
+ done();
1397
+ });
1398
+ });
1399
+
1400
+ describe('Create', function () {
1401
+ it('should create the PayIn', function () {
1402
+ expect(payIn.Id).not.to.be.undefined;
1403
+ expect(payIn.PaymentType).to.equal('MULTIBANCO');
1404
+ expect(payIn.ExecutionType).to.equal('WEB');
1405
+ expect(payIn.AuthorId).to.equal(john.Id);
1406
+ expect(payIn.Status).to.equal('CREATED');
1407
+ expect(payIn.Type).to.equal('PAYIN');
1408
+ expect(payIn.Phone).not.to.be.null;
1409
+ });
1410
+ });
1411
+
1412
+ describe('Get', function () {
1413
+ var getPayIn;
1414
+ before(function (done) {
1415
+ api.PayIns.get(payIn.Id, function (data, response) {
1416
+ getPayIn = data;
1417
+ done()
1418
+ });
1419
+ });
1420
+
1421
+ it('should get the PayIn', function () {
1422
+ expect(getPayIn.Id).to.equal(payIn.Id);
1423
+ expect(getPayIn.PaymentType).to.equal('MULTIBANCO');
1424
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1425
+ expect(getPayIn.Phone).not.to.be.null;
1426
+ });
1427
+ });
1428
+ });
1429
+
1430
+ describe('Satispay Web', function () {
1431
+ var payIn;
1432
+
1433
+ before(function (done) {
1434
+ helpers.getNewPayInSatispayWeb(api, john, function (data) {
1435
+ payIn = data;
1436
+ done();
1437
+ });
1438
+ });
1439
+
1440
+ describe('Create', function () {
1441
+ it('should create the PayIn', function () {
1442
+ expect(payIn.Id).not.to.be.undefined;
1443
+ expect(payIn.PaymentType).to.equal('SATISPAY');
1444
+ expect(payIn.ExecutionType).to.equal('WEB');
1445
+ expect(payIn.AuthorId).to.equal(john.Id);
1446
+ expect(payIn.Status).to.equal('CREATED');
1447
+ expect(payIn.Type).to.equal('PAYIN');
1448
+ expect(payIn.Phone).not.to.be.null;
1449
+ });
1450
+ });
1451
+
1452
+ describe('Get', function () {
1453
+ var getPayIn;
1454
+ before(function (done) {
1455
+ api.PayIns.get(payIn.Id, function (data, response) {
1456
+ getPayIn = data;
1457
+ done()
1458
+ });
1459
+ });
1460
+
1461
+ it('should get the PayIn', function () {
1462
+ expect(getPayIn.Id).to.equal(payIn.Id);
1463
+ expect(getPayIn.PaymentType).to.equal('SATISPAY');
1464
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1465
+ expect(getPayIn.Phone).not.to.be.null;
1466
+ });
1467
+ });
1468
+ });
1469
+
1470
+ describe('Blik Web', function () {
1471
+ var payIn;
1472
+ var payInWithCode;
1473
+
1474
+ before(function (done) {
1475
+ helpers.getNewPayInBlikWeb(api, john, function (data) {
1476
+ payIn = data;
1477
+ helpers.getNewPayInBlikWebWithCode(api, john, function (data) {
1478
+ payInWithCode = data;
1479
+ done();
1480
+ });
1481
+ });
1482
+ });
1483
+
1484
+ describe('Create', function () {
1485
+ it('should create the PayIn', function () {
1486
+ expect(payIn.Id).not.to.be.undefined;
1487
+ expect(payIn.PaymentType).to.equal('BLIK');
1488
+ expect(payIn.ExecutionType).to.equal('WEB');
1489
+ expect(payIn.AuthorId).to.equal(john.Id);
1490
+ expect(payIn.Status).to.equal('CREATED');
1491
+ expect(payIn.Type).to.equal('PAYIN');
1492
+ expect(payIn.Phone).not.to.be.null;
1493
+ });
1494
+
1495
+ it('should create the PayIn with code', function () {
1496
+ expect(payIn.Id).not.to.be.undefined;
1497
+ expect(payIn.PaymentType).to.equal('BLIK');
1498
+ expect(payIn.ExecutionType).to.equal('WEB');
1499
+ expect(payIn.Code).not.to.be.undefined;
1500
+ expect(payIn.IpAddress).not.to.be.undefined;
1501
+ expect(payIn.BrowserInfo).not.to.be.undefined;
1502
+ });
1503
+ });
1504
+
1505
+ describe('Get', function () {
1506
+ var getPayIn;
1507
+ before(function (done) {
1508
+ api.PayIns.get(payIn.Id, function (data, response) {
1509
+ getPayIn = data;
1510
+ done()
1511
+ });
1512
+ });
1513
+
1514
+ it('should get the PayIn', function () {
1515
+ expect(getPayIn.Id).to.equal(payIn.Id);
1516
+ expect(getPayIn.PaymentType).to.equal('BLIK');
1517
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1518
+ expect(getPayIn.Phone).not.to.be.null;
1519
+ });
1520
+ });
1521
+ });
1522
+
1523
+ describe('Klarna Web', function () {
1524
+ var payIn;
1525
+
1526
+ before(function (done) {
1527
+ helpers.getNewPayInKlarnaWeb(api, john, function (data) {
1528
+ payIn = data;
1529
+ done();
1530
+ });
1531
+ });
1532
+
1533
+ describe('Create', function () {
1534
+ it('should create the PayIn', function () {
1535
+ expect(payIn.Id).not.to.be.undefined;
1536
+ expect(payIn.PaymentType).to.equal('KLARNA');
1537
+ expect(payIn.ExecutionType).to.equal('WEB');
1538
+ expect(payIn.AuthorId).to.equal(john.Id);
1539
+ expect(payIn.Type).to.equal('PAYIN');
1540
+ expect(payIn.Phone).not.to.be.null;
1541
+ });
1542
+ });
1543
+
1544
+ describe('Get', function () {
1545
+ var getPayIn;
1546
+ before(function (done) {
1547
+ api.PayIns.get(payIn.Id, function (data, response) {
1548
+ getPayIn = data;
1549
+ done()
1550
+ });
1551
+ });
1552
+
1553
+ it('should get the PayIn', function () {
1554
+ expect(getPayIn.Id).to.equal(payIn.Id);
1555
+ expect(getPayIn.PaymentType).to.equal('KLARNA');
1556
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1557
+ expect(getPayIn.Phone).not.to.be.null;
1558
+ });
1559
+ });
1560
+ });
1561
+
1562
+ describe('Ideal Web', function () {
1563
+ var payIn;
1564
+
1565
+ before(function (done) {
1566
+ helpers.getNewPayInIdealWeb(api, john, function (data) {
1567
+ payIn = data;
1568
+ done();
1569
+ });
1570
+ });
1571
+
1572
+ describe('Create', function () {
1573
+ it('should create the PayIn', function () {
1574
+ expect(payIn.Id).not.to.be.undefined;
1575
+ expect(payIn.PaymentType).to.equal('IDEAL');
1576
+ expect(payIn.ExecutionType).to.equal('WEB');
1577
+ expect(payIn.AuthorId).to.equal(john.Id);
1578
+ expect(payIn.Type).to.equal('PAYIN');
1579
+ expect(payIn.Phone).not.to.be.null;
1580
+ });
1581
+ });
1582
+
1583
+ describe('Get', function () {
1584
+ var getPayIn;
1585
+ before(function (done) {
1586
+ api.PayIns.get(payIn.Id, function (data, response) {
1587
+ getPayIn = data;
1588
+ done()
1589
+ });
1590
+ });
1591
+
1592
+ it('should get the PayIn', function () {
1593
+ expect(getPayIn.Id).to.equal(payIn.Id);
1594
+ expect(getPayIn.PaymentType).to.equal('IDEAL');
1595
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1596
+ expect(getPayIn.Phone).not.to.be.null;
1597
+ });
1598
+ });
1599
+ });
1600
+
1601
+ describe('Giropay Web', function () {
1602
+ var payIn;
1603
+
1604
+ before(function (done) {
1605
+ helpers.getNewPayInGiropayWeb(api, john, function (data) {
1606
+ payIn = data;
1607
+ done();
1608
+ });
1609
+ });
1610
+
1611
+ describe('Create', function () {
1612
+ it('should create the PayIn', function () {
1613
+ expect(payIn.Id).not.to.be.undefined;
1614
+ expect(payIn.PaymentType).to.equal('GIROPAY');
1615
+ expect(payIn.ExecutionType).to.equal('WEB');
1616
+ expect(payIn.AuthorId).to.equal(john.Id);
1617
+ expect(payIn.Type).to.equal('PAYIN');
1618
+ expect(payIn.Phone).not.to.be.null;
1619
+ });
1620
+ });
1621
+
1622
+ describe('Get', function () {
1623
+ var getPayIn;
1624
+ before(function (done) {
1625
+ api.PayIns.get(payIn.Id, function (data, response) {
1626
+ getPayIn = data;
1627
+ done();
1628
+ });
1629
+ });
1630
+
1631
+ it('should get the PayIn', function () {
1632
+ expect(getPayIn.Id).to.equal(payIn.Id);
1633
+ expect(getPayIn.PaymentType).to.equal('GIROPAY');
1634
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1635
+ expect(getPayIn.Phone).not.to.be.null;
1636
+ });
1637
+ });
1638
+ });
1639
+
1640
+ describe('Swish Web', function () {
1641
+ var payIn;
1642
+
1643
+ before(function (done) {
1644
+ helpers.getNewPayInSwishWeb(api, john, function (data) {
1645
+ payIn = data;
1646
+ done();
1647
+ });
1648
+ });
1649
+
1650
+ describe('Create', function () {
1651
+ it('should create the PayIn', function () {
1652
+ expect(payIn.Id).not.to.be.undefined;
1653
+ expect(payIn.PaymentType).to.equal('SWISH');
1654
+ expect(payIn.ExecutionType).to.equal('WEB');
1655
+ expect(payIn.AuthorId).to.equal(john.Id);
1656
+ expect(payIn.Type).to.equal('PAYIN');
1657
+ expect(payIn.Phone).not.to.be.null;
1658
+ });
1659
+ });
1660
+
1661
+ describe('Get', function () {
1662
+ var getPayIn;
1663
+ before(function (done) {
1664
+ api.PayIns.get(payIn.Id, function (data, response) {
1665
+ getPayIn = data;
1666
+ done();
1667
+ });
1668
+ });
1669
+
1670
+ it('should get the PayIn', function () {
1671
+ expect(getPayIn.Id).to.equal(payIn.Id);
1672
+ expect(getPayIn.PaymentType).to.equal('SWISH');
1673
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1674
+ expect(getPayIn.Phone).not.to.be.null;
1675
+ });
1676
+ });
1677
+ });
1678
+
1679
+ describe('Twint Web', function () {
1680
+ var payIn;
1681
+
1682
+ before(function (done) {
1683
+ helpers.getNewPayInTwintWeb(api, john, function (data) {
1684
+ payIn = data;
1685
+ done();
1686
+ });
1687
+ });
1688
+
1689
+ describe('Create', function () {
1690
+ it('should create the PayIn', function () {
1691
+ expect(payIn.Id).not.to.be.undefined;
1692
+ expect(payIn.PaymentType).to.equal('TWINT');
1693
+ expect(payIn.ExecutionType).to.equal('WEB');
1694
+ expect(payIn.AuthorId).to.equal(john.Id);
1695
+ expect(payIn.Type).to.equal('PAYIN');
1696
+ expect(payIn.Phone).not.to.be.null;
1697
+ });
1698
+ });
1699
+
1700
+ describe('Get', function () {
1701
+ var getPayIn;
1702
+ before(function (done) {
1703
+ api.PayIns.get(payIn.Id, function (data, response) {
1704
+ getPayIn = data;
1705
+ done();
1706
+ });
1707
+ });
1708
+
1709
+ it('should get the PayIn', function () {
1710
+ expect(getPayIn.Id).to.equal(payIn.Id);
1711
+ expect(getPayIn.PaymentType).to.equal('TWINT');
1712
+ expect(getPayIn.ExecutionType).to.equal('WEB');
1713
+ expect(getPayIn.Phone).not.to.be.null;
1714
+ });
1715
+ });
1716
+ });
1717
+
1718
+ describe('Ideal Legacy Web', function () {
1719
+ var payIn;
1720
+
1721
+ before(function (done) {
1722
+ helpers.getLegacyPayInIdealCardWeb(api, john, function (data) {
1723
+ payIn = data;
1724
+ done();
1725
+ });
1726
+ });
1727
+
1728
+ describe('Create', function () {
1729
+ it('should create the legacy PayIn', function () {
1730
+ expect(payIn.Id).not.to.be.undefined;
1731
+ expect(payIn.BankName).not.to.be.null;
1732
+ expect(payIn.CardType).to.equal('IDEAL');
1733
+ expect(payIn.PaymentType).to.equal('CARD');
1734
+ expect(payIn.ExecutionType).to.equal('WEB');
1735
+ expect(payIn.AuthorId).to.equal(john.Id);
1736
+ expect(payIn.Type).to.equal('PAYIN');
1737
+ expect(payIn.Phone).not.to.be.null;
1738
+ });
1739
+ });
1740
+ });
1741
+
1742
+ // skip because we cannot generate new paymentData in the tests
1743
+ describe.skip('GooglePay V2', function () {
1744
+ var googlePayIn, wallet;
1745
+
1746
+ before(function (done) {
1747
+ wallet = {
1748
+ Owners: [john.Id],
1749
+ Currency: 'EUR',
1750
+ Description: 'WALLET IN EUR'
1751
+ };
1752
+
1753
+ api.Wallets.create(wallet).then(function () {
1754
+ done();
1755
+ });
1756
+ });
1757
+
1758
+ describe('Create', function () {
1759
+
1760
+ var paymentData = "{\"signature\":\"MEUCIQCLXOan2Y9DobLVSOeD5V64Peayvz0ZAWisdz/1iTdthAIgVFb4Hve4EhtW81k46S" +
1761
+ "iMlnXLIiCn1h2+vVQGjHe+sSo\\u003d\",\"intermediateSigningKey\":{\"signedKey\":\"{\\\"keyValue\\\":\\\"M" +
1762
+ "FkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEDGRER6R6PH6K39YTIYX+CpDNej6gQgvi/Wx19SOPtiDnkjAl4/LF9pXlvZYe+aJH0Dy" +
1763
+ "095I6BlfY8bNBB5gjPg\\\\u003d\\\\u003d\\\",\\\"keyExpiration\\\":\\\"1688521049102\\\"}\"," +
1764
+ "\"signatures\":[\"MEYCIQDup1B+rkiPAWmpg7RmqY0NfgdGhmdyL8wvAX+6C1aOU2QIhAIZACSDQ/ZexIyEia5KrRlG2B+y3AnK" +
1765
+ "NlhRzumRcnNOR\"]},\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"YSSG" +
1766
+ "K9yFdKP+mJB5+wAjnOujnThPM1E/KbbJxd3MDzPVI66ip1DBESldvQXYjjeLq6Rf1tKE9oLwwaj6u0/gU7Z9t3g1MoW+9YoEE1bs1" +
1767
+ "IxImif7IQGAosfYjjbBBfDkOaqEs2JJC5qt6xjKO9lQ/E6JPkPFGqF7+OJ1vzmD83Pi3sHWkVge5MhxXQ3yBNhrjus3kV7zUoYA+u" +
1768
+ "qNrciWcWypc1NndF/tiwSkvUTzM6n4dS8X84fkJiSO7PZ65C0yw0mdybRRnyL2fFdWGssve1zZFAvYfzcpNamyuZGGlu/SCoayit" +
1769
+ "ojmMsqe5Cu0efD9+WvvDr9PA+Vo1gzuz7LmiZe81SGvdFhRoq62FBAUiwSsi2A3pWinZxM2XbYNph+HJ5FCNspWhz4ur9JG4ZMLem" +
1770
+ "CXuaybvL++W6PWywAtoiE0mQcBIX3vhOq5itv0RkaKVe6nbcAS2UryRz2u /nDCJLKpIv2Wi11NtCUT2mgD8F6qfcXhvVZHyeLqZ1O" +
1771
+ "LgCudTTSdKirzezbgPTg4tQpW++KufeD7bgG+01XhCWt+7/ftqcSf8n//gSRINne8j2G6w+2\\\",\\" +
1772
+ "\"ephemeralPublicKey\\\":\\\"BLY2+R8C0T+BSf/W3HEq305qH63IGmJxMVmbfJ6+x1V7GQg9W9v7eHc3j+8TeypVn+nRl" +
1773
+ "Pu98tivuMXECg+rWZs\\\\u003d\\\",\\\"tag\\\":\\\"MmEjNdLfsDNfYd/FRUjoJ4/IfLypNRqx8zgHfa6Ftmo\\\\u003d\\\"}\"}"
1774
+
1775
+ before(function (done) {
1776
+ googlePayIn = {
1777
+ AuthorId: john.Id,
1778
+ CreditedWalletId: wallet.Id,
1779
+ DebitedFunds: {
1780
+ Amount: 199,
1781
+ Currency: 'EUR'
1782
+ },
1783
+ Fees: {
1784
+ Amount: 1,
1785
+ Currency: 'EUR'
1786
+ },
1787
+ PaymentType: 'GOOGLE_PAY',
1788
+ ExecutionType: 'DIRECT',
1789
+ PaymentData: paymentData,
1790
+ Tag: "Create an GooglePay card direct Payin",
1791
+ StatementDescriptor: "php",
1792
+ BrowserInfo: {
1793
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
1794
+ JavaEnabled: true,
1795
+ Language: "FR-FR",
1796
+ ColorDepth: 4,
1797
+ ScreenHeight: 1800,
1798
+ ScreenWidth: 400,
1799
+ JavascriptEnabled: true,
1800
+ TimeZoneOffset: "+60",
1801
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
1802
+ },
1803
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
1804
+ SecureModeReturnURL: "http://www.my-site.com/returnurl",
1805
+ SecureMode: "DEFAULT",
1806
+ ReturnURL: "http://test.com",
1807
+ Billing: {
1808
+ FirstName: 'Joe',
1809
+ LastName: 'Blogs',
1810
+ Address: {
1811
+ AddressLine1: '1 MangoPay Street',
1812
+ AddressLine2: 'The Loop',
1813
+ City: 'Paris',
1814
+ Region: 'Ile de France',
1815
+ PostalCode: '75001',
1816
+ Country: 'FR'
1817
+ }
1818
+ },
1819
+ Shipping: {
1820
+ FirstName: 'Joe',
1821
+ LastName: 'Blogs',
1822
+ Address: {
1823
+ AddressLine1: '1 MangoPay Street',
1824
+ AddressLine2: 'The Loop',
1825
+ City: 'Paris',
1826
+ Region: 'Ile de France',
1827
+ PostalCode: '75001',
1828
+ Country: 'FR'
1829
+ }
1830
+ }
1831
+ };
1832
+
1833
+ api.PayIns.createGooglePay(googlePayIn, function (data, response) {
1834
+ googlePayIn = data;
1835
+ done();
1836
+ });
1837
+ });
1838
+
1839
+ it('should be created', function () {
1840
+ expect(googlePayIn.Id).not.to.be.undefined;
1841
+ expect(googlePayIn.AuthorId).to.equal(john.Id);
1842
+ expect(googlePayIn.PaymentType).to.equal('GOOGLE_PAY');
1843
+ expect(googlePayIn.ExecutionType).to.equal('DIRECT');
1844
+ expect(googlePayIn.Type).to.equal('PAYIN');
1845
+ });
1846
+ });
1847
+ });
1848
+
1849
+ describe('Payment Method Metadata', function () {
1850
+ var metadata;
1851
+ var payIn;
1852
+
1853
+ before(function (done) {
1854
+ helpers.getNewPayInCardDirect(api, john, function (createdPayIn) {
1855
+ payIn = createdPayIn
1856
+ var metadataPost = {
1857
+ Type: "BIN",
1858
+ Bin: payIn.CardInfo.BIN
1859
+ }
1860
+
1861
+ api.PayIns.getPaymentMethodMetadata(metadataPost, function (data) {
1862
+ metadata = data;
1863
+ done();
1864
+ });
1865
+ });
1866
+ });
1867
+
1868
+ describe('Fetch Metadata', function () {
1869
+ it('should fetch the payment method metadata', function () {
1870
+ expect(metadata.Type).to.equal('BIN')
1871
+ expect(metadata.Bin).to.equal(payIn.CardInfo.BIN);
1872
+ });
1873
+ });
1874
+
1875
+ });
1876
+
1877
+ describe('Card PreAuthorized Deposit', function () {
1878
+ var payIn;
1879
+
1880
+ before(function (done) {
1881
+ helpers.createNewCardPreAuthorizedDepositPayIn(function (data, response) {
1882
+ payIn = data;
1883
+ done();
1884
+ });
1885
+ });
1886
+
1887
+ it('should be created', function () {
1888
+ expect(payIn).not.to.be.undefined;
1889
+ expect(payIn.Status).to.equal('SUCCEEDED');
1890
+ expect(payIn.PaymentType).to.equal('PREAUTHORIZED');
1891
+ expect(payIn.ExecutionType).to.equal('DIRECT');
1892
+ expect(payIn.DepositId).not.to.be.undefined;
1893
+ });
1894
+ });
1895
+
1896
+ describe('Card PreAuthorized Deposit prior to complement', function () {
1897
+ var payIn;
1898
+
1899
+ before(function (done) {
1900
+ helpers.createNewDeposit(function (data, response) {
1901
+ var deposit = data;
1902
+ var wallet = {
1903
+ Owners: [deposit.AuthorId],
1904
+ Currency: 'EUR',
1905
+ Description: 'WALLET IN EUR'
1906
+ };
1907
+
1908
+ api.Wallets.create(wallet).then(function(data) {
1909
+ var payInDto = {
1910
+ AuthorId: deposit.AuthorId,
1911
+ CreditedWalletId: wallet.Id,
1912
+ DebitedFunds: {
1913
+ Currency: 'EUR',
1914
+ Amount: 1000
1915
+ },
1916
+ Fees: {
1917
+ Currency: 'EUR',
1918
+ Amount: 0
1919
+ },
1920
+ DepositId: deposit.Id
1921
+ };
1922
+
1923
+ api.PayIns.createDepositPreauthorizedPayInPriorToComplement(payInDto).then(function(data) {
1924
+ payIn = data;
1925
+ done();
1926
+ });
1927
+ });
1928
+ });
1929
+ });
1930
+
1931
+ it('should be created', function () {
1932
+ expect(payIn).not.to.be.undefined;
1933
+ expect(payIn.Status).to.equal('SUCCEEDED');
1934
+ expect(payIn.PaymentType).to.equal('PREAUTHORIZED');
1935
+ expect(payIn.ExecutionType).to.equal('DIRECT');
1936
+ expect(payIn.DepositId).not.to.be.undefined;
1937
+ });
1938
+ });
1939
+
1940
+ describe.skip('Card PreAuthorized Deposit complement', function () {
1941
+ // skipped because of PSP configuration error
1942
+ var payIn;
1943
+
1944
+ before(function (done) {
1945
+ helpers.createNewDeposit(function (data, response) {
1946
+ var deposit = data;
1947
+ var wallet = {
1948
+ Owners: [deposit.AuthorId],
1949
+ Currency: 'EUR',
1950
+ Description: 'WALLET IN EUR'
1951
+ };
1952
+
1953
+ api.Wallets.create(wallet).then(function(data) {
1954
+ var depositUpdate = {
1955
+ Id: deposit.Id,
1956
+ PaymentStatus: "NO_SHOW_REQUESTED"
1957
+ };
1958
+
1959
+ api.Deposits.update(depositUpdate).then(function(data) {
1960
+ var payInDto = {
1961
+ AuthorId: deposit.AuthorId,
1962
+ CreditedWalletId: wallet.Id,
1963
+ DebitedFunds: {
1964
+ Currency: 'EUR',
1965
+ Amount: 1000
1966
+ },
1967
+ Fees: {
1968
+ Currency: 'EUR',
1969
+ Amount: 0
1970
+ },
1971
+ DepositId: deposit.Id
1972
+ };
1973
+
1974
+ api.PayIns.createDepositPreauthorizedPayInComplement(payInDto).then(function(data) {
1975
+ payIn = data;
1976
+ done();
1977
+ });
1978
+ });
1979
+ });
1980
+ });
1981
+ });
1982
+
1983
+ it('should be created', function () {
1984
+ expect(payIn).not.to.be.undefined;
1985
+ expect(payIn.Status).to.equal('SUCCEEDED');
1986
+ expect(payIn.PaymentType).to.equal('PREAUTHORIZED');
1987
+ expect(payIn.ExecutionType).to.equal('DIRECT');
1988
+ expect(payIn.DepositId).not.to.be.undefined;
1989
+ });
1990
+ });
1991
+
1992
+ describe('Pay by Bank Web', function () {
1993
+ var payIn;
1994
+
1995
+ before(function (done) {
1996
+ helpers.getNewPayInPayByBankWeb(api, john, function (data) {
1997
+ payIn = data;
1998
+ done();
1999
+ });
2000
+ });
2001
+
2002
+ describe('Create', function () {
2003
+ it('should create the PayIn', function () {
2004
+ expect(payIn.Id).not.to.be.undefined;
2005
+ expect(payIn.PaymentType).to.equal('PAY_BY_BANK');
2006
+ expect(payIn.ExecutionType).to.equal('WEB');
2007
+ expect(payIn.AuthorId).to.equal(john.Id);
2008
+ expect(payIn.Type).to.equal('PAYIN');
2009
+ expect(payIn.Country).not.to.be.null;
2010
+ expect(payIn.RedirectURL).not.to.be.null;
2011
+ expect(payIn.ReturnURL).not.to.be.null;
2012
+ expect(payIn.IBAN).not.to.be.null;
2013
+ expect(payIn.BIC).not.to.be.null;
2014
+ expect(payIn.PaymentFlow).not.to.be.null;
2015
+ expect(payIn.BankName).not.to.be.null;
2016
+ expect(payIn.Culture).not.to.be.null;
2017
+ expect(payIn.Scheme).not.to.be.null;
2018
+ });
2019
+ });
2020
+
2021
+ describe('Get', function () {
2022
+ var getPayIn;
2023
+ before(function (done) {
2024
+ api.PayIns.get(payIn.Id, function (data, response) {
2025
+ getPayIn = data;
2026
+ done();
2027
+ });
2028
+ });
2029
+
2030
+ it('should get the PayIn', function () {
2031
+ expect(getPayIn.Id).to.equal(payIn.Id);
2032
+ expect(getPayIn.PaymentType).to.equal('PAY_BY_BANK');
2033
+ expect(getPayIn.ExecutionType).to.equal('WEB');
2034
+ });
2035
+ });
2036
+
2037
+ describe('Get supported banks', function () {
2038
+ var withoutFilterAndPagination;
2039
+ var withFilter;
2040
+ var withPagination;
2041
+ var withFilterAndPagination;
2042
+
2043
+ before(function (done) {
2044
+ api.PayIns.getPayByBankSupportedBanks(function (data, response) {
2045
+ withoutFilterAndPagination = data;
2046
+ done();
2047
+ });
2048
+ });
2049
+
2050
+ before(function (done) {
2051
+ api.PayIns.getPayByBankSupportedBanks(function (data, response) {
2052
+ withFilter = data;
2053
+ done();
2054
+ }, {
2055
+ CountryCodes: "DE"
2056
+ });
2057
+ });
2058
+
2059
+ before(function (done) {
2060
+ api.PayIns.getPayByBankSupportedBanks(function (data, response) {
2061
+ withPagination = data;
2062
+ done();
2063
+ }, {
2064
+ per_page: 2,
2065
+ page: 1
2066
+ });
2067
+ });
2068
+
2069
+ before(function (done) {
2070
+ api.PayIns.getPayByBankSupportedBanks(function (data, response) {
2071
+ withFilterAndPagination = data;
2072
+ done();
2073
+ }, {
2074
+ per_page: 2,
2075
+ page: 1,
2076
+ CountryCodes: "DE"
2077
+ });
2078
+ });
2079
+
2080
+ it('should get the supported banks', function () {
2081
+ expect(withoutFilterAndPagination).not.to.be.undefined;
2082
+ expect(withoutFilterAndPagination.SupportedBanks.Countries.length).to.be.above(0);
2083
+
2084
+ expect(withoutFilterAndPagination.SupportedBanks.Countries.length)
2085
+ .to.be.greaterThan(withFilter.SupportedBanks.Countries.length);
2086
+ expect(withFilter.SupportedBanks.Countries[0].Banks.length).to.eq(5);
2087
+
2088
+ expect(withPagination.SupportedBanks.Countries[0].Banks.length).to.eq(2);
2089
+
2090
+ expect(withoutFilterAndPagination.SupportedBanks.Countries.length)
2091
+ .to.be.greaterThan(withFilterAndPagination.SupportedBanks.Countries.length);
2092
+ expect(withFilterAndPagination.SupportedBanks.Countries[0].Banks.length).to.eq(2);
2093
+ });
2094
+ });
2095
+ });
2096
+
2097
+ describe('PayIn Intent', function () {
2098
+ describe('Create intent authorization', function () {
2099
+ var payInIntent;
2100
+
2101
+ before(function (done) {
2102
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2103
+ payInIntent = data;
2104
+ done();
2105
+ });
2106
+ });
2107
+
2108
+ it('should create the PayInIntent Authorization', function () {
2109
+ expect(payInIntent.Id).not.to.be.undefined;
2110
+ expect(payInIntent.Status).to.equal('AUTHORIZED');
2111
+ });
2112
+ });
2113
+
2114
+ describe('Create full capture', function () {
2115
+ var payInIntent;
2116
+
2117
+ before(function (done) {
2118
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2119
+ const toCreate = {
2120
+ "ExternalData" : {
2121
+ "ExternalProcessingDate" : 1727788165,
2122
+ "ExternalProviderReference" : Math.random().toString(),
2123
+ "ExternalMerchantReference" : "Order-xyz-35e8490e-2ec9-4c82-978e-c712a3f5ba16",
2124
+ "ExternalProviderName" : "Stripe",
2125
+ "ExternalProviderPaymentMethod" : "PAYPAL"
2126
+ }
2127
+ };
2128
+ api.PayIns.createPayInIntentFullCapture(data.Id, toCreate, function(data) {
2129
+ payInIntent = data;
2130
+ done();
2131
+ });
2132
+ });
2133
+ });
2134
+
2135
+ it('should create the PayInIntent Full Capture', function () {
2136
+ expect(payInIntent.Id).not.to.be.undefined;
2137
+ expect(payInIntent.Status).to.equal('CAPTURED');
2138
+ });
2139
+ });
2140
+
2141
+ describe('Create partial capture', function () {
2142
+ var payInIntent;
2143
+
2144
+ before(function (done) {
2145
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2146
+ const toCreate = {
2147
+ "Amount" : 1000,
2148
+ "Currency" : "EUR",
2149
+ "PlatformFeesAmount": 0,
2150
+ "ExternalData" : {
2151
+ "ExternalProcessingDate" : 1727788165,
2152
+ "ExternalProviderReference" : Math.random().toString(),
2153
+ "ExternalMerchantReference" : "Order-xyz-35e8490e-2ec9-4c82-978e-c712a3f5ba16",
2154
+ "ExternalProviderName" : "Stripe",
2155
+ "ExternalProviderPaymentMethod" : "PAYPAL"
2156
+ },
2157
+ "LineItems": [
2158
+ {
2159
+ "Amount": 1000,
2160
+ "Id": data.LineItems[0].Id
2161
+ }
2162
+ ]
2163
+ };
2164
+ api.PayIns.createPayInIntentPartialCapture(data.Id, toCreate, function(data) {
2165
+ payInIntent = data;
2166
+ done();
2167
+ });
2168
+ });
2169
+ });
2170
+
2171
+ it('should create the PayInIntent Partial Capture', function () {
2172
+ expect(payInIntent.Id).not.to.be.undefined;
2173
+ expect(payInIntent.Status).to.equal('CAPTURED');
2174
+ });
2175
+ });
2176
+
2177
+ describe('Get intent', function () {
2178
+ var fetched;
2179
+ var created;
2180
+
2181
+ before(function (done) {
2182
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2183
+ created = data;
2184
+ api.PayIns.getPayInIntent(created.Id, function(data) {
2185
+ fetched = data;
2186
+ done();
2187
+ });
2188
+ });
2189
+ });
2190
+
2191
+ it('should get the intent', function () {
2192
+ expect(fetched.Id).to.equal(created.Id);
2193
+ expect(fetched.Status).to.equal(created.Status);
2194
+ });
2195
+ });
2196
+
2197
+ describe('Cancel intent', function () {
2198
+ var canceled;
2199
+ var created;
2200
+
2201
+ before(function (done) {
2202
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2203
+ created = data;
2204
+ const cancelDetails = {
2205
+ "ExternalData" : {
2206
+ "ExternalProcessingDate" : 1728133765,
2207
+ "ExternalProviderReference" : Math.random().toString(),
2208
+ }
2209
+ };
2210
+ api.PayIns.fullCancelPayInIntent(created.Id, cancelDetails, function(data) {
2211
+ canceled = data;
2212
+ done();
2213
+ });
2214
+ });
2215
+ });
2216
+
2217
+ it('should cancel the intent', function () {
2218
+ expect(canceled.Status).to.equal('CANCELLED');
2219
+ });
2220
+ });
2221
+
2222
+ describe('Create splits', function () {
2223
+ var payInIntent;
2224
+ var splitsResult;
2225
+
2226
+ before(function (done) {
2227
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2228
+ payInIntent = data;
2229
+ const fullCapture = {
2230
+ "ExternalData" : {
2231
+ "ExternalProcessingDate" : 1727788165,
2232
+ "ExternalProviderReference" : Math.random().toString(),
2233
+ "ExternalMerchantReference" : "Order-xyz-35e8490e-2ec9-4c82-978e-c712a3f5ba16",
2234
+ "ExternalProviderName" : "Stripe",
2235
+ "ExternalProviderPaymentMethod" : "PAYPAL"
2236
+ }
2237
+ };
2238
+ api.PayIns.createPayInIntentFullCapture(payInIntent.Id, fullCapture, function(data) {
2239
+ const splits = {
2240
+ Splits: [
2241
+ {
2242
+ LineItemId: payInIntent.LineItems[0].Id,
2243
+ SplitAmount: 10
2244
+ }
2245
+ ]
2246
+ };
2247
+ api.PayIns.createPayInIntentSplits(payInIntent.Id, splits, function(data) {
2248
+ splitsResult = data;
2249
+ done();
2250
+ });
2251
+ });
2252
+ });
2253
+ });
2254
+
2255
+ it('should create the Splits', function () {
2256
+ expect(splitsResult.Splits[0].Status).to.equal('CREATED');
2257
+ });
2258
+ });
2259
+ });
2260
+
2261
+ describe('PayIn Intent', function () {
2262
+ describe('Create intent authorization', function () {
2263
+ var payInIntent;
2264
+
2265
+ before(function (done) {
2266
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2267
+ payInIntent = data;
2268
+ done();
2269
+ });
2270
+ });
2271
+
2272
+ it('should create the PayInIntent Authorization', function () {
2273
+ expect(payInIntent.Id).not.to.be.undefined;
2274
+ expect(payInIntent.Status).to.equal('AUTHORIZED');
2275
+ });
2276
+ });
2277
+
2278
+ describe('Create full capture', function () {
2279
+ var payInIntent;
2280
+
2281
+ before(function (done) {
2282
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2283
+ const toCreate = {
2284
+ "ExternalData" : {
2285
+ "ExternalProcessingDate" : 1727788165,
2286
+ "ExternalProviderReference" : Math.random().toString(),
2287
+ "ExternalMerchantReference" : "Order-xyz-35e8490e-2ec9-4c82-978e-c712a3f5ba16",
2288
+ "ExternalProviderName" : "Stripe",
2289
+ "ExternalProviderPaymentMethod" : "PAYPAL"
2290
+ }
2291
+ };
2292
+ api.PayIns.createPayInIntentFullCapture(data.Id, toCreate, function(data) {
2293
+ payInIntent = data;
2294
+ done();
2295
+ });
2296
+ });
2297
+ });
2298
+
2299
+ it('should create the PayInIntent Full Capture', function () {
2300
+ expect(payInIntent.Id).not.to.be.undefined;
2301
+ expect(payInIntent.Status).to.equal('CAPTURED');
2302
+ });
2303
+ });
2304
+
2305
+ describe('Create partial capture', function () {
2306
+ var payInIntent;
2307
+
2308
+ before(function (done) {
2309
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2310
+ const toCreate = {
2311
+ "Amount" : 1000,
2312
+ "Currency" : "EUR",
2313
+ "PlatformFeesAmount": 0,
2314
+ "ExternalData" : {
2315
+ "ExternalProcessingDate" : 1727788165,
2316
+ "ExternalProviderReference" : Math.random().toString(),
2317
+ "ExternalMerchantReference" : "Order-xyz-35e8490e-2ec9-4c82-978e-c712a3f5ba16",
2318
+ "ExternalProviderName" : "Stripe",
2319
+ "ExternalProviderPaymentMethod" : "PAYPAL"
2320
+ },
2321
+ "LineItems": [
2322
+ {
2323
+ "Amount": 1000,
2324
+ "Id": data.LineItems[0].Id
2325
+ }
2326
+ ]
2327
+ };
2328
+ api.PayIns.createPayInIntentPartialCapture(data.Id, toCreate, function(data) {
2329
+ payInIntent = data;
2330
+ done();
2331
+ });
2332
+ });
2333
+ });
2334
+
2335
+ it('should create the PayInIntent Partial Capture', function () {
2336
+ expect(payInIntent.Id).not.to.be.undefined;
2337
+ expect(payInIntent.Status).to.equal('CAPTURED');
2338
+ });
2339
+ });
2340
+
2341
+ describe('Get intent', function () {
2342
+ var fetched;
2343
+ var created;
2344
+
2345
+ before(function (done) {
2346
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2347
+ created = data;
2348
+ api.PayIns.getPayInIntent(created.Id, function(data) {
2349
+ fetched = data;
2350
+ done();
2351
+ });
2352
+ });
2353
+ });
2354
+
2355
+ it('should get the intent', function () {
2356
+ expect(fetched.Id).to.equal(created.Id);
2357
+ expect(fetched.Status).to.equal(created.Status);
2358
+ });
2359
+ });
2360
+
2361
+ // describe('Cancel intent', function () {
2362
+ // var canceled;
2363
+ // var created;
2364
+ //
2365
+ // before(function (done) {
2366
+ // helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2367
+ // created = data;
2368
+ // const cancelDetails = {
2369
+ // "ExternalData" : {
2370
+ // "ExternalProcessingDate" : 1728133765,
2371
+ // "ExternalProviderReference" : Math.random().toString(),
2372
+ // }
2373
+ // };
2374
+ // api.PayIns.fullCancelPayInIntent(created.Id, cancelDetails, function(data) {
2375
+ // canceled = data;
2376
+ // done();
2377
+ // });
2378
+ // });
2379
+ // });
2380
+ //
2381
+ // it('should cancel the intent', function () {
2382
+ // expect(canceled.Status).to.equal('CANCELED');
2383
+ // });
2384
+ // });
2385
+
2386
+ describe('Create splits', function () {
2387
+ var payInIntent;
2388
+ var splitsResult;
2389
+
2390
+ before(function (done) {
2391
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2392
+ payInIntent = data;
2393
+ helpers.getNewPayInIntentSplit(api, payInIntent, function(data) {
2394
+ splitsResult = data;
2395
+ done();
2396
+ });
2397
+ });
2398
+ });
2399
+
2400
+ it('should create the Splits', function () {
2401
+ expect(splitsResult.Splits[0].Status).to.equal('CREATED');
2402
+ });
2403
+ });
2404
+
2405
+ describe('Execute split', function () {
2406
+ var payInIntent;
2407
+ var error;
2408
+
2409
+ before(function (done) {
2410
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2411
+ payInIntent = data;
2412
+ helpers.getNewPayInIntentSplit(api, data, function (data) {
2413
+ api.PayIns.executePayInIntentSplit(payInIntent.Id, data.Splits[0].Id, function (data) {
2414
+ })
2415
+ .catch(function (err) {
2416
+ error = err;
2417
+ done();
2418
+ });
2419
+ });
2420
+ });
2421
+ });
2422
+
2423
+ it('should return error while trying to execute the Split', function () {
2424
+ // expect error. A success use case cannot be automated because it needs a PayIn to be created manually
2425
+ expect(error.Errors.Split).to.contain("Execute split requires a status in [AVAILABLE, REJECTED]");
2426
+ });
2427
+ });
2428
+
2429
+ describe('Reverse split', function () {
2430
+ var payInIntent;
2431
+ var reversedSplit;
2432
+
2433
+ before(function (done) {
2434
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2435
+ payInIntent = data;
2436
+ helpers.getNewPayInIntentSplit(api, data, function (data) {
2437
+ api.PayIns.reversePayInIntentSplit(payInIntent.Id, data.Splits[0].Id, function (data) {
2438
+ reversedSplit = data;
2439
+ done();
2440
+ });
2441
+ });
2442
+ });
2443
+ });
2444
+
2445
+ it('should return error while trying to reverse the Split', function () {
2446
+ // expect error. A success use case cannot be automated because it needs a PayIn to be created manually
2447
+ expect(reversedSplit.Status).to.eq("REVERSED");
2448
+ });
2449
+ });
2450
+
2451
+ describe('Get split', function () {
2452
+ var payInIntent;
2453
+ var fetched;
2454
+
2455
+ before(function (done) {
2456
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2457
+ payInIntent = data;
2458
+ helpers.getNewPayInIntentSplit(api, data, function (data) {
2459
+ api.PayIns.getPayInIntentSplit(payInIntent.Id, data.Splits[0].Id, function (data) {
2460
+ fetched = data;
2461
+ done();
2462
+ });
2463
+ });
2464
+ });
2465
+ });
2466
+
2467
+ it('should get the Split', function () {
2468
+ expect(fetched.Status).to.equal('CREATED');
2469
+ });
2470
+ });
2471
+
2472
+ describe('Update split', function () {
2473
+ var payInIntent;
2474
+ var updated;
2475
+
2476
+ before(function (done) {
2477
+ helpers.getNewPayInIntentAuthorization(api, john, function (data) {
2478
+ payInIntent = data;
2479
+ helpers.getNewPayInIntentSplit(api, data, function (data) {
2480
+ const dto = {
2481
+ LineItemId: data.Splits[0].LineItemId,
2482
+ Description: "updated description"
2483
+ };
2484
+ api.PayIns.updatePayInIntentSplit(payInIntent.Id, data.Splits[0].Id, dto, function (data) {
2485
+ updated = data;
2486
+ done();
2487
+ });
2488
+ });
2489
+ });
2490
+ });
2491
+
2492
+ it('should update the Split', function () {
2493
+ expect(updated.Description).to.equal("updated description");
2494
+ });
2495
+ });
2496
+ });
2497
+
2498
+ describe('PayPal Data Collection', function () {
2499
+ var dataCollection;
2500
+
2501
+ before(function (done) {
2502
+ const toCreate = {
2503
+ "sender_account_id" : "A12345N343",
2504
+ "sender_first_name" : "Jane",
2505
+ "sender_last_name" : "Doe",
2506
+ "sender_email" : "jane.doe@sample.com",
2507
+ "sender_phone" : "(042) 1123 4567",
2508
+ "sender_address_zip" : "75009",
2509
+ "sender_country_code" : "FR",
2510
+ "sender_create_date" : "2012-12-09T19:14:55.277-0:00",
2511
+ "sender_signup_ip" : "10.220.90.20",
2512
+ "sender_popularity_score" : "high",
2513
+ "receiver_account_id" : "A12345N344",
2514
+ "receiver_create_date" : "2012-12-09T19:14:55.277-0:00",
2515
+ "receiver_email" : "jane@sample.com",
2516
+ "receiver_address_country_code" : "FR",
2517
+ "business_name" : "Jane Ltd",
2518
+ "recipient_popularity_score" : "high",
2519
+ "first_interaction_date" : "2012-12-09T19:14:55.277-0:00",
2520
+ "txn_count_total" : "34",
2521
+ "vertical" : "Household goods",
2522
+ "transaction_is_tangible" : "0"
2523
+ };
2524
+ api.PayIns.createPayPalDataCollection(toCreate, function(data) {
2525
+ dataCollection = data;
2526
+ done();
2527
+ });
2528
+ });
2529
+
2530
+ describe('Create', function () {
2531
+ it('should create the data collection', function () {
2532
+ expect(dataCollection).not.to.be.undefined;
2533
+ expect(dataCollection.dataCollectionId).not.to.be.undefined;
2534
+ });
2535
+ });
2536
+
2537
+ describe('Get', function () {
2538
+ var getDataCollection;
2539
+ before(function (done) {
2540
+ api.PayIns.getPayPalDataCollection(dataCollection.dataCollectionId, function (data, response) {
2541
+ getDataCollection = data;
2542
+ done();
2543
+ });
2544
+ });
2545
+
2546
+ it('should get the data collection', function () {
2547
+ expect(getDataCollection.dataCollectionId).to.equal(dataCollection.dataCollectionId);
2548
+ expect(getDataCollection.sender_first_name).to.equal("Jane");
2549
+ expect(getDataCollection.sender_last_name).to.equal("Doe");
2550
+ });
2551
+ });
2552
+ });
2553
+ });