Skip to content

Commit 5ee100e

Browse files
authored
Merge pull request #1502 from Adyen/mandatory-query-param-fix
Checkout: mark mandatory query parameters
2 parents 13a351d + 60baf9c commit 5ee100e

File tree

6 files changed

+19
-31
lines changed

6 files changed

+19
-31
lines changed

src/__tests__/checkout.spec.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -563,27 +563,15 @@ describe("Checkout", (): void => {
563563
});
564564

565565
test("Should delete stored paymentMethod", async (): Promise<void> => {
566-
scope.delete("/storedPaymentMethods/12321")
566+
scope.delete("/storedPaymentMethods/12321?shopperReference=myShopperReference&merchantAccount=myMerchantAccount")
567567
.reply(200);
568568

569569
await expect(
570-
checkoutService.RecurringApi.deleteTokenForStoredPaymentDetails("12321"),
570+
checkoutService.RecurringApi.deleteTokenForStoredPaymentDetails("12321", "myShopperReference", "myMerchantAccount"),
571571
).resolves.not.toThrowError();
572572

573573
});
574574

575-
test("Should handle request without query parameters for getResultOfPaymentSession", async(): Promise<void> => {
576-
scope.get("/sessions/mySessionIdMock")
577-
.reply(200, {
578-
"id": "CS12345678",
579-
"status": "completed"
580-
});
581-
582-
const resultOfPaymentSessionResponse = await checkoutService.PaymentsApi.getResultOfPaymentSession("mySessionIdMock");
583-
expect(resultOfPaymentSessionResponse.id).toEqual("CS12345678");
584-
expect(resultOfPaymentSessionResponse.status).toEqual(SessionResultResponse.StatusEnum.Completed);
585-
});
586-
587575
test("Should handle query parameters for getResultOfPaymentSession", async(): Promise<void> => {
588576
scope.get("/sessions/mySessionIdMock?sessionResult=sessionResult")
589577
.reply(200, {

src/__tests__/httpClient.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,21 @@ describe("HTTP Client", function (): void {
116116

117117
const scope = nock("https://checkout-test.adyen.com/v71", {
118118
reqheaders: {
119-
'adyen-library-name': (headerValue) => {
119+
"adyen-library-name": (headerValue) => {
120120
expect(headerValue).toBeTruthy();
121121
expect(headerValue).toEqual(expectedLibraryName);
122122
return true;
123123
},
124-
'adyen-library-version': (headerValue) => {
124+
"adyen-library-version": (headerValue) => {
125125
expect(headerValue).toBeTruthy();
126126
expect(headerValue).toEqual(expectedLibraryVersion);
127-
expect
127+
expect;
128128
return true;
129129
},
130-
'user-agent': (headerValue) => {
130+
"user-agent": (headerValue) => {
131131
expect(headerValue).toBeTruthy();
132132
expect(headerValue).toEqual(expectedUserAgent);
133-
expect
133+
expect;
134134
return true;
135135
}
136136
}
@@ -153,21 +153,21 @@ describe("HTTP Client", function (): void {
153153

154154
const scope = nock("https://checkout-test.adyen.com/v71", {
155155
reqheaders: {
156-
'adyen-library-name': (headerValue) => {
156+
"adyen-library-name": (headerValue) => {
157157
expect(headerValue).toBeTruthy();
158158
expect(headerValue).toEqual(expectedLibraryName);
159159
return true;
160160
},
161-
'adyen-library-version': (headerValue) => {
161+
"adyen-library-version": (headerValue) => {
162162
expect(headerValue).toBeTruthy();
163163
expect(headerValue).toEqual(expectedLibraryVersion);
164-
expect
164+
expect;
165165
return true;
166166
},
167-
'user-agent': (headerValue) => {
167+
"user-agent": (headerValue) => {
168168
expect(headerValue).toBeTruthy();
169169
expect(headerValue).toEqual(expectedUserAgent);
170-
expect
170+
expect;
171171
return true;
172172
}
173173
}
@@ -181,18 +181,18 @@ describe("HTTP Client", function (): void {
181181

182182
});
183183

184-
describe('Config class', () => {
184+
describe("Config class", () => {
185185
const DEFAULT_TIMEOUT = 30000; // Define the default timeout value
186186

187-
test('should set default timeout when no timeout is provided', () => {
187+
test("should set default timeout when no timeout is provided", () => {
188188
// Instantiate the Config class without passing a timeout
189189
const config = new Config();
190190

191191
// Expect that the timeout is set to the default value (30000)
192192
expect(config.connectionTimeoutMillis).toBe(DEFAULT_TIMEOUT);
193193
});
194194

195-
test('should set custom timeout when provided', () => {
195+
test("should set custom timeout when provided", () => {
196196
// Instantiate the Config class with a custom timeout
197197
const customTimeout = 50000;
198198
const config = new Config({ connectionTimeoutMillis: customTimeout });

src/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Service {
5151
throw new Error("Please provide your unique live url prefix on the setEnvironment() call on the Client.");
5252
}
5353

54-
if (url.includes('/possdk/v68')) {
54+
if (url.includes("/possdk/v68")) {
5555
return url.replace("https://checkout-test.adyen.com/",
5656
`https://${this.client.liveEndpointUrlPrefix}-checkout-live.adyenpayments.com/`);
5757
}

src/services/checkout/paymentsApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class PaymentsApi extends Service {
6262
* @param sessionResult {@link string } The &#x60;sessionResult&#x60; value from the Drop-in or Component.
6363
* @return {@link SessionResultResponse }
6464
*/
65-
public async getResultOfPaymentSession(sessionId: string, sessionResult?: string, requestOptions?: IRequest.Options): Promise<SessionResultResponse> {
65+
public async getResultOfPaymentSession(sessionId: string, sessionResult: string, requestOptions?: IRequest.Options): Promise<SessionResultResponse> {
6666
const endpoint = `${this.baseUrl}/sessions/{sessionId}`
6767
.replace("{" + "sessionId" + "}", encodeURIComponent(String(sessionId)));
6868
const resource = new Resource(this, endpoint);

src/services/checkout/recurringApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class RecurringApi extends Service {
3636
* @param shopperReference {@link string } Your reference to uniquely identify this shopper, for example user ID or account ID. Minimum length: 3 characters. &gt; Your reference must not include personally identifiable information (PII), for example name or email address.
3737
* @param merchantAccount {@link string } Your merchant account.
3838
*/
39-
public async deleteTokenForStoredPaymentDetails(storedPaymentMethodId: string, shopperReference?: string, merchantAccount?: string, requestOptions?: IRequest.Options): Promise<void> {
39+
public async deleteTokenForStoredPaymentDetails(storedPaymentMethodId: string, shopperReference: string, merchantAccount: string, requestOptions?: IRequest.Options): Promise<void> {
4040
const endpoint = `${this.baseUrl}/storedPaymentMethods/{storedPaymentMethodId}`
4141
.replace("{" + "storedPaymentMethodId" + "}", encodeURIComponent(String(storedPaymentMethodId)));
4242
const resource = new Resource(this, endpoint);

templates/typescript/api-single.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class {{classname}} extends Service {
2424
{{#operation}}
2525

2626
{{>api_summary}}
27-
public async {{#vendorExtensions.x-methodName}}{{.}}{{/vendorExtensions.x-methodName}}{{^vendorExtensions.x-methodName}}{{nickname}}{{/vendorExtensions.x-methodName}}({{#pathParams}}{{paramName}}: {{{dataType}}}, {{/pathParams}}{{#bodyParams}}{{paramName}}: {{{dataType}}}, {{/bodyParams}}{{#queryParams}}{{paramName}}?: {{{dataType}}}, {{/queryParams}}requestOptions?: IRequest.Options): Promise<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
27+
public async {{#vendorExtensions.x-methodName}}{{.}}{{/vendorExtensions.x-methodName}}{{^vendorExtensions.x-methodName}}{{nickname}}{{/vendorExtensions.x-methodName}}({{#pathParams}}{{paramName}}: {{{dataType}}}, {{/pathParams}}{{#bodyParams}}{{paramName}}: {{{dataType}}}, {{/bodyParams}}{{#queryParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/queryParams}}requestOptions?: IRequest.Options): Promise<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
2828
const endpoint = `${this.baseUrl}{{{path}}}`{{#pathParams}}
2929
.replace("{" + "{{baseName}}" + "}", encodeURIComponent(String({{paramName}}))){{/pathParams}};
3030
const resource = new Resource(this, endpoint);

0 commit comments

Comments
 (0)