Skip to content

Commit f909881

Browse files
iulian03Iulian Masar
andauthored
handle intent reports (#490)
Co-authored-by: Iulian Masar <iulian.masar@codegile.com>
1 parent ad50b2b commit f909881

File tree

2 files changed

+235
-0
lines changed

2 files changed

+235
-0
lines changed

test/services/ReportsV2.js

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,227 @@ describe('Reports V2 (2025)', function () {
8080
expect(allReports.length).to.be.above(0);
8181
});
8282
});
83+
84+
describe('Create intent report', function () {
85+
var report;
86+
87+
before(function (done) {
88+
var reportPost = {
89+
"DownloadFormat" : "CSV",
90+
"ReportType" : "ECHO_INTENT",
91+
"AfterDate" : 1748782023,
92+
"BeforeDate" : 1753102013,
93+
"Filters" : {
94+
"PaymentMethod" : "PAYPAL",
95+
"Status" : "CAPTURED",
96+
"Type" : "PAYIN"
97+
},
98+
"Columns" : [
99+
"Id",
100+
"Status",
101+
"Amount",
102+
"Currency",
103+
"FeesAmount",
104+
"FeesCurrency",
105+
"Type",
106+
"PaymentMethod",
107+
"BuyerId",
108+
"SellerId"
109+
]
110+
};
111+
api.ReportsV2.create(reportPost).then(function (data) {
112+
report = data;
113+
done();
114+
});
115+
});
116+
117+
it('should be correctly fetched', function () {
118+
expect(report.Id).to.exist;
119+
expect(report.ReportType).to.equal("ECHO_INTENT");
120+
expect(report.DownloadFormat).to.equal("CSV");
121+
expect(report.Status).to.equal("PENDING");
122+
expect(report.Filters.Status).to.equal("CAPTURED");
123+
expect(report.Columns.length).to.equal(10);
124+
});
125+
});
126+
127+
describe('Create intent action report', function () {
128+
var report;
129+
130+
before(function (done) {
131+
var reportPost = {
132+
"DownloadFormat" : "CSV",
133+
"ReportType" : "ECHO_INTENT_ACTION",
134+
"AfterDate" : 1748782023,
135+
"BeforeDate" : 1753102013,
136+
"Filters" : {
137+
"PaymentMethod" : "PAYPAL",
138+
"Status" : "CAPTURED",
139+
"Type" : "PAYIN"
140+
},
141+
"Columns" : [
142+
"IntentId",
143+
"Id",
144+
"ExternalProcessingDate",
145+
"ExternalProviderReference",
146+
"ExternalMerchantReference",
147+
"Status",
148+
"Amount",
149+
"Currency",
150+
"FeesAmount",
151+
"FeesCurrency",
152+
"Type",
153+
"PaymentMethod",
154+
"BuyerId",
155+
"SellerId"
156+
]
157+
};
158+
api.ReportsV2.create(reportPost).then(function (data) {
159+
report = data;
160+
done();
161+
});
162+
});
163+
164+
it('should be correctly fetched', function () {
165+
expect(report.Id).to.exist;
166+
expect(report.ReportType).to.equal("ECHO_INTENT_ACTION");
167+
expect(report.DownloadFormat).to.equal("CSV");
168+
expect(report.Status).to.equal("PENDING");
169+
expect(report.Filters.Status).to.equal("CAPTURED");
170+
expect(report.Columns.length).to.equal(14);
171+
});
172+
});
173+
174+
describe('Create settlement report', function () {
175+
var report;
176+
177+
before(function (done) {
178+
var reportPost = {
179+
"DownloadFormat" : "CSV",
180+
"ReportType" : "ECHO_SETTLEMENT",
181+
"AfterDate" : 1748782023,
182+
"BeforeDate" : 1753102013,
183+
"Filters" : {
184+
"Status" : "RECONCILED",
185+
"ExternalProviderName" : "PAYPAL"
186+
},
187+
"Columns" : [
188+
"Id",
189+
"CreationDate",
190+
"FileName",
191+
"SettlementCurrency",
192+
"Status",
193+
"SettledTransactionCount",
194+
"UnsettledTransactionCount",
195+
"SettledAmount",
196+
"DeclaredAmount",
197+
"DeficitAmount"
198+
]
199+
};
200+
api.ReportsV2.create(reportPost).then(function (data) {
201+
report = data;
202+
done();
203+
});
204+
});
205+
206+
it('should be correctly fetched', function () {
207+
expect(report.Id).to.exist;
208+
expect(report.ReportType).to.equal("ECHO_SETTLEMENT");
209+
expect(report.DownloadFormat).to.equal("CSV");
210+
expect(report.Status).to.equal("PENDING");
211+
expect(report.Filters.Status).to.equal("RECONCILED");
212+
expect(report.Columns.length).to.equal(10);
213+
});
214+
});
215+
216+
describe('Create settlement report', function () {
217+
var report;
218+
219+
before(function (done) {
220+
var reportPost = {
221+
"DownloadFormat" : "CSV",
222+
"ReportType" : "ECHO_SETTLEMENT",
223+
"AfterDate" : 1748782023,
224+
"BeforeDate" : 1753102013,
225+
"Filters" : {
226+
"Status" : "RECONCILED",
227+
"ExternalProviderName" : "PAYPAL"
228+
},
229+
"Columns" : [
230+
"Id",
231+
"CreationDate",
232+
"FileName",
233+
"SettlementCurrency",
234+
"Status",
235+
"SettledTransactionCount",
236+
"UnsettledTransactionCount",
237+
"SettledAmount",
238+
"DeclaredAmount",
239+
"DeficitAmount"
240+
]
241+
};
242+
api.ReportsV2.create(reportPost).then(function (data) {
243+
report = data;
244+
done();
245+
});
246+
});
247+
248+
it('should be correctly fetched', function () {
249+
expect(report.Id).to.exist;
250+
expect(report.ReportType).to.equal("ECHO_SETTLEMENT");
251+
expect(report.DownloadFormat).to.equal("CSV");
252+
expect(report.Status).to.equal("PENDING");
253+
expect(report.Filters.Status).to.equal("RECONCILED");
254+
expect(report.Columns.length).to.equal(10);
255+
});
256+
});
257+
258+
describe('Create split report', function () {
259+
var report;
260+
261+
before(function (done) {
262+
var reportPost = {
263+
"Tag" : "Creating a report using new Mangopay system",
264+
"DownloadFormat" : "CSV",
265+
"ReportType" : "ECHO_SPLIT",
266+
"AfterDate" : 1748782023,
267+
"BeforeDate" : 1753102013,
268+
"Filters" : {
269+
"Status" : "COMPLETED",
270+
"IntentId" : "int_0197f975-63f6-714e-8fc6-4451e128170f",
271+
"Scheduled": false
272+
},
273+
"Columns" : [
274+
"Id",
275+
"IntentId",
276+
"AuthorId",
277+
"Amount",
278+
"Currency",
279+
"FeesAmount",
280+
"FeesCurrency",
281+
"Status",
282+
"Description",
283+
"CreditedWalletId",
284+
"DebitedWalletId",
285+
"Scheduled",
286+
"CreationDate",
287+
"ExecutionDate"
288+
]
289+
};
290+
api.ReportsV2.create(reportPost).then(function (data) {
291+
report = data;
292+
done();
293+
});
294+
});
295+
296+
it('should be correctly fetched', function () {
297+
expect(report.Id).to.exist;
298+
expect(report.ReportType).to.equal("ECHO_SPLIT");
299+
expect(report.DownloadFormat).to.equal("CSV");
300+
expect(report.Status).to.equal("PENDING");
301+
expect(report.Filters.Status).to.equal("COMPLETED");
302+
expect(report.Filters.IntentId).to.equal("int_0197f975-63f6-714e-8fc6-4451e128170f");
303+
expect(report.Columns.length).to.equal(14);
304+
});
305+
});
83306
});

typings/models/reportV2.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ export namespace reportV2 {
1717
* The unique identifier of the wallet referenced as the DebitedWalletId or CreditedWalletId of the transaction.
1818
*/
1919
WalletId?: string;
20+
21+
PaymentMethod?: string;
22+
23+
Status?: string;
24+
25+
Type?: string;
26+
27+
IntentId?: string;
28+
29+
ExternalProviderName?: string;
30+
31+
Scheduled?: boolean;
2032
}
2133

2234
interface ReportDataV2 extends entityBase.EntityBaseData {

0 commit comments

Comments
 (0)