Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 0597eb9

Browse files
IngenicoEPaymentsjenkins
authored andcommitted
Release 4.1.0.
1 parent 2bb6312 commit 0597eb9

File tree

9 files changed

+111
-15
lines changed

9 files changed

+111
-15
lines changed

__tests__/integration/idempotence.test.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* eslint-disable @typescript-eslint/no-non-null-assertion */
22

33
import * as uuid from "uuid";
4-
import { CreatePaymentResponse } from "../../src/model/domain/payment";
4+
import { SdkResponse } from "../../src/model";
5+
import { CreatePaymentResponse, PaymentErrorResponse } from "../../src/model/domain/payment";
6+
import { CreatePaymentResult } from "../../src/model/domain/payment/definitions";
57
import connectSdk, { config } from "./init";
68

79
/**
@@ -38,29 +40,39 @@ describe("Idempotence", () => {
3840
}
3941
};
4042

43+
function extractPaymentResult(response: SdkResponse): CreatePaymentResult {
44+
// For this test it doesn't matter if the response is successful or declined,
45+
// as long as idempotence is handled correctly
46+
if (response.status === 201) {
47+
return response.body as CreatePaymentResponse;
48+
} else {
49+
const responseBody = response.body as PaymentErrorResponse;
50+
return responseBody.paymentResult!;
51+
}
52+
}
53+
4154
connectSdk.payments.create(config.merchantId, body, paymentContext, (error, response) => {
4255
expect(error).toBeNull();
4356

4457
expect(response).not.toBeNull();
45-
expect(response!.status).toBe(201);
46-
expect(response!.body).not.toBe(null);
58+
expect(response!.body).toBeTruthy();
4759

48-
const responseBody = response!.body as CreatePaymentResponse;
49-
expect(responseBody.payment).not.toBe(null);
50-
expect(responseBody.payment!.id).not.toBe(null);
60+
const paymentResult = extractPaymentResult(response!);
61+
expect(paymentResult.payment).toBeTruthy();
62+
expect(paymentResult.payment!.id).toBeTruthy();
5163
expect(paymentContext.idemPotence.key).toBe(idemPotenceKey);
5264
expect(connectSdk.context.getIdempotenceRequestTimestamp()).toBeUndefined();
5365

5466
connectSdk.payments.create(config.merchantId, body, paymentContext, (error2, response2) => {
5567
expect(error2).toBeNull();
5668

5769
expect(response2).not.toBeNull();
58-
expect(response2!.status).toBe(201);
59-
expect(response2!.body).not.toBe(null);
70+
expect(response2!.status).toBe(response!.status);
71+
expect(response2!.body).toBeTruthy();
6072

61-
const responseBody2 = response2!.body as CreatePaymentResponse;
62-
expect(responseBody2.payment).not.toBe(null);
63-
expect(responseBody2.payment!.id).toBe(responseBody.payment!.id);
73+
const paymentResult2 = extractPaymentResult(response2!);
74+
expect(paymentResult2.payment).toBeTruthy();
75+
expect(paymentResult2.payment!.id).toBe(paymentResult.payment!.id);
6476
expect(paymentContext.idemPotence.key).toBe(idemPotenceKey);
6577
expect(connectSdk.context.getIdempotenceRequestTimestamp()).not.toBeUndefined();
6678
expect(connectSdk.context.getIdempotenceRequestTimestamp()).not.toBeNull();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "connect-sdk-nodejs",
3-
"version": "4.0.0",
3+
"version": "4.1.0",
44
"description": "SDK to communicate with the Ingenico ePayments platform using the Ingenico Connect Server API",
55
"homepage": "https://github.com/Ingenico-ePayments/connect-sdk-nodejs#readme",
66
"bugs": {

schemas/payment/CreatePaymentRequest.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,15 @@
541541
"paymentProduct1504SpecificInput" : {
542542
"$ref" : "#/definitions/CashPaymentProduct1504SpecificInput"
543543
},
544+
"paymentProduct1506SpecificInput" : {
545+
"$ref" : "#/definitions/CashPaymentProduct1506SpecificInput"
546+
},
547+
"paymentProduct1508SpecificInput" : {
548+
"$ref" : "#/definitions/CashPaymentProduct1508SpecificInput"
549+
},
550+
"paymentProduct1511SpecificInput" : {
551+
"$ref" : "#/definitions/CashPaymentProduct1511SpecificInput"
552+
},
544553
"paymentProduct1521SpecificInput" : {
545554
"$ref" : "#/definitions/CashPaymentProduct1521SpecificInput"
546555
},
@@ -581,6 +590,33 @@
581590
},
582591
"additionalProperties" : false
583592
},
593+
"CashPaymentProduct1506SpecificInput" : {
594+
"type" : "object",
595+
"properties" : {
596+
"returnUrl" : {
597+
"type" : "string"
598+
}
599+
},
600+
"additionalProperties" : false
601+
},
602+
"CashPaymentProduct1508SpecificInput" : {
603+
"type" : "object",
604+
"properties" : {
605+
"returnUrl" : {
606+
"type" : "string"
607+
}
608+
},
609+
"additionalProperties" : false
610+
},
611+
"CashPaymentProduct1511SpecificInput" : {
612+
"type" : "object",
613+
"properties" : {
614+
"returnUrl" : {
615+
"type" : "string"
616+
}
617+
},
618+
"additionalProperties" : false
619+
},
584620
"CashPaymentProduct1521SpecificInput" : {
585621
"type" : "object",
586622
"properties" : {

src/model/domain/payment/definitions/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ export interface CashPaymentMethodSpecificInput extends AbstractCashPaymentMetho
219219
*/
220220
paymentProduct1503SpecificInput?: CashPaymentProduct1503SpecificInput | null;
221221
paymentProduct1504SpecificInput?: CashPaymentProduct1504SpecificInput | null;
222+
paymentProduct1506SpecificInput?: CashPaymentProduct1506SpecificInput | null;
223+
paymentProduct1508SpecificInput?: CashPaymentProduct1508SpecificInput | null;
224+
paymentProduct1511SpecificInput?: CashPaymentProduct1511SpecificInput | null;
222225
paymentProduct1521SpecificInput?: CashPaymentProduct1521SpecificInput | null;
223226
paymentProduct1522SpecificInput?: CashPaymentProduct1522SpecificInput | null;
224227
paymentProduct1523SpecificInput?: CashPaymentProduct1523SpecificInput | null;
@@ -247,6 +250,18 @@ export interface CashPaymentProduct1504SpecificInput {
247250
returnUrl?: string | null;
248251
}
249252

253+
export interface CashPaymentProduct1506SpecificInput {
254+
returnUrl?: string | null;
255+
}
256+
257+
export interface CashPaymentProduct1508SpecificInput {
258+
returnUrl?: string | null;
259+
}
260+
261+
export interface CashPaymentProduct1511SpecificInput {
262+
returnUrl?: string | null;
263+
}
264+
250265
export interface CashPaymentProduct1521SpecificInput {
251266
returnUrl?: string | null;
252267
}

src/model/domain/services/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This file was auto-generated from the API references found at
33
* https://epayments-api.developer-ingenico.com/s2sapi/v1/
44
*/
5-
import { BankAccountBban, BankAccountIban } from "../definitions";
5+
import { AmountOfMoney, BankAccountBban, BankAccountIban } from "../definitions";
66
import { BankData, BankDetails, IINDetail, PaymentContext, Swift } from "./definitions";
77

88
// eslint-disable-next-line @typescript-eslint/no-empty-interface
@@ -35,6 +35,13 @@ export interface GetPrivacyPolicyResponse {
3535
htmlContent?: string | null;
3636
}
3737

38+
export interface SettlementDetails {
39+
acquirerReferenceNumber?: string | null;
40+
amountOfMoney?: AmountOfMoney | null;
41+
paymentId?: string | null;
42+
retrievalReferenceNumber?: string | null;
43+
}
44+
3845
export interface TestConnection {
3946
result?: string | null;
4047
}

src/model/services/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ export interface ServicesClient {
4141
* If the call was not successful, the response body type will be {@link ErrorResponse}.
4242
*/
4343
testconnection(merchantId: string, paymentContext: PaymentContext | null, cb: SdkCallback): void;
44+
/**
45+
* Resource /{merchantId}/services/settlementdetails/{paymentId} - <a href="https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/nodejs/services/settlementdetails.html">Get Settlement details</a>
46+
* @param cb The callback for the response.
47+
* If the call was successfull, the response body type will be {@link SettlementDetails}.
48+
* If the call was not successful, the response body type will be {@link ErrorResponse}.
49+
*/
50+
settlementdetails(merchantId: string, paymentId: string, paymentContext: PaymentContext | null, cb: SdkCallback): void;
4451
}
4552

4653
export interface ConvertAmountParams extends PaymentContext {

src/services/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import bankaccount = require("./bankaccount");
77
import getIINdetails = require("./getIINdetails");
88
import privacypolicy = require("./privacypolicy");
99
import testconnection = require("./testconnection");
10+
import settlementdetails = require("./settlementdetails");
1011
import { ServicesClient } from "../model/services";
1112

1213
const servicesClient: ServicesClient = {
1314
convertAmount: convertAmount,
1415
bankaccount: bankaccount,
1516
getIINdetails: getIINdetails,
1617
privacypolicy: privacypolicy,
17-
testconnection: testconnection
18+
testconnection: testconnection,
19+
settlementdetails: settlementdetails
1820
};
1921
export = servicesClient;

src/services/settlementdetails.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* This file was auto-generated from the API references found at
3+
* https://epayments-api.developer-ingenico.com/s2sapi/v1/
4+
*/
5+
import communicator = require("../utils/communicator");
6+
import { PaymentContext, SdkCallback } from "../model";
7+
8+
const getSettlementDetails = function(merchantId: string, paymentId: string, paymentContext: PaymentContext | null, cb: SdkCallback): void {
9+
communicator.json({
10+
method: "GET",
11+
modulePath: "/v1/" + merchantId + "/services/settlementdetails/" + paymentId,
12+
body: null,
13+
paymentContext: paymentContext,
14+
cb: cb
15+
});
16+
};
17+
export = getSettlementDetails;

src/utils/headers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface ServerMetaInfo {
1818
export function serverMetaInfo(sdkContext: SdkContext): Header {
1919
const info: ServerMetaInfo = {
2020
sdkCreator: "Ingenico",
21-
sdkIdentifier: "NodejsServerSDK/v4.0.0",
21+
sdkIdentifier: "NodejsServerSDK/v4.1.0",
2222
platformIdentifier: process.env["OS"] + " Node.js/" + process.versions.node
2323
};
2424
if (sdkContext.getIntegrator() !== null) {

0 commit comments

Comments
 (0)