Skip to content

Commit 23dd113

Browse files
committed
Add container when attribute is array of enums
1 parent 30b66fb commit 23dd113

File tree

7 files changed

+57
-10
lines changed

7 files changed

+57
-10
lines changed

src/__tests__/checkout.spec.ts

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ function getPaymentLinkSuccess(expiresAt: Date): checkout.PaymentLinkResponse {
8181
url: "PaymentLinkResponse.url",
8282
id: "mocked_id",
8383
merchantAccount,
84-
status: checkout.PaymentLinkResponse.StatusEnum.Active
85-
};
84+
status: checkout.PaymentLinkResponse.StatusEnum.Active,
85+
requiredShopperFields: [
86+
checkout.PaymentLinkResponse.RequiredShopperFieldsEnum.BillingAddress,
87+
checkout.PaymentLinkResponse.RequiredShopperFieldsEnum.ShopperEmail]
88+
};
8689
}
8790

8891
function createPaymentLinkRequest(): checkout.PaymentLinkRequest {
@@ -110,7 +113,10 @@ function createPaymentLinkRequest(): checkout.PaymentLinkRequest {
110113
country: "BR",
111114
stateOrProvince: "SP"
112115
},
113-
reference
116+
reference,
117+
requiredShopperFields: [
118+
checkout.PaymentLinkRequest.RequiredShopperFieldsEnum.BillingAddress,
119+
checkout.PaymentLinkRequest.RequiredShopperFieldsEnum.ShopperEmail]
114120
};
115121
}
116122

@@ -312,7 +318,7 @@ describe("Checkout", (): void => {
312318
}
313319
});
314320

315-
test("should have valid payment link", async (): Promise<void> => {
321+
test("should create valid payment link", async (): Promise<void> => {
316322
const expiresAt = "2019-12-17T10:05:29Z";
317323
const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(new Date(expiresAt));
318324

@@ -322,6 +328,28 @@ describe("Checkout", (): void => {
322328
expect(paymentSuccessLinkResponse).toBeTruthy();
323329
});
324330

331+
test("should create valid payment link with installmentOptions", async (): Promise<void> => {
332+
const expiresAt = "2019-12-17T10:05:29Z";
333+
const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(new Date(expiresAt));
334+
335+
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
336+
337+
const request : checkout.PaymentLinkRequest = createPaymentLinkRequest();
338+
request.installmentOptions = {
339+
card: {
340+
plans: [
341+
checkout.CheckoutSessionInstallmentOption.PlansEnum.Bonus,
342+
checkout.CheckoutSessionInstallmentOption.PlansEnum.BuynowPaylater
343+
]
344+
}
345+
};
346+
const paymentSuccessLinkResponse = await checkoutService.PaymentLinksApi.paymentLinks(request);
347+
expect(paymentSuccessLinkResponse).toBeTruthy();
348+
expect(paymentSuccessLinkResponse.id).toBeTruthy();
349+
expect(paymentSuccessLinkResponse.id).toBe("mocked_id");
350+
expect(paymentSuccessLinkResponse.requiredShopperFields?.length).toBe(2);
351+
});
352+
325353
test("should get payment link", async (): Promise<void> => {
326354
const expiresAt = "2019-12-17T10:05:29Z";
327355
const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(new Date(expiresAt));
@@ -549,6 +577,25 @@ describe("Checkout", (): void => {
549577
expect(sessionsResponse.expiresAt.getFullYear()).toBeGreaterThan(0);
550578
});
551579

580+
test("should create a session with installmentOptions.", async (): Promise<void> => {
581+
scope.post("/sessions")
582+
.reply(200, sessionsSuccess);
583+
584+
const sessionsRequest: checkout.CreateCheckoutSessionRequest = createSessionRequest();
585+
sessionsRequest.installmentOptions = {
586+
card: {
587+
plans: [
588+
checkout.CheckoutSessionInstallmentOption.PlansEnum.Bonus,
589+
checkout.CheckoutSessionInstallmentOption.PlansEnum.BuynowPaylater
590+
]
591+
}
592+
};
593+
const sessionsResponse: checkout.CreateCheckoutSessionResponse = await checkoutService.PaymentsApi.sessions(sessionsRequest);
594+
expect(sessionsResponse.sessionData).toBeTruthy();
595+
expect(sessionsResponse.expiresAt).toBeInstanceOf(Date);
596+
expect(sessionsResponse.expiresAt.getFullYear()).toBeGreaterThan(0);
597+
});
598+
552599
test("Should get card details", async (): Promise<void> => {
553600
scope.post("/cardDetails")
554601
.reply(200, {

src/typings/checkout/checkoutSessionInstallmentOption.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class CheckoutSessionInstallmentOption {
1212
/**
1313
* Defines the type of installment plan. If not set, defaults to **regular**. Possible values: * **regular** * **revolving*** **bonus** * **with_interest** * **buynow_paylater** * **nointerest_bonus** * **interest_bonus** * **refund_prctg** * **nointeres_refund_prctg** * **interes_refund_prctg**
1414
*/
15-
"plans"?: CheckoutSessionInstallmentOption.PlansEnum;
15+
"plans"?: Array<CheckoutSessionInstallmentOption.PlansEnum>;
1616
/**
1717
* Preselected number of installments offered for this payment method.
1818
*/

src/typings/checkout/deviceRenderOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class DeviceRenderOptions {
1616
/**
1717
* UI types supported for displaying specific challenges. Allowed values: * text * singleSelect * outOfBand * otherHtml * multiSelect
1818
*/
19-
"sdkUiType"?: DeviceRenderOptions.SdkUiTypeEnum;
19+
"sdkUiType"?: Array<DeviceRenderOptions.SdkUiTypeEnum>;
2020

2121
static readonly discriminator: string | undefined = undefined;
2222

src/typings/checkout/installmentOption.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class InstallmentOption {
1616
/**
1717
* Defines the type of installment plan. If not set, defaults to **regular**. Possible values: * **regular** * **revolving**
1818
*/
19-
"plans"?: InstallmentOption.PlansEnum;
19+
"plans"?: Array<InstallmentOption.PlansEnum>;
2020
/**
2121
* Preselected number of installments offered for this payment method.
2222
*/

src/typings/checkout/paymentLinkRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class PaymentLinkRequest {
100100
/**
101101
* List of fields that the shopper has to provide on the payment page before completing the payment. For more information, refer to [Provide shopper information](https://docs.adyen.com/unified-commerce/pay-by-link/payment-links/api#shopper-information). Possible values: * **billingAddress** – The address where to send the invoice. * **deliveryAddress** – The address where the purchased goods should be delivered. * **shopperEmail** – The shopper\'s email address. * **shopperName** – The shopper\'s full name. * **telephoneNumber** – The shopper\'s phone number.
102102
*/
103-
"requiredShopperFields"?: PaymentLinkRequest.RequiredShopperFieldsEnum;
103+
"requiredShopperFields"?: Array<PaymentLinkRequest.RequiredShopperFieldsEnum>;
104104
/**
105105
* Website URL used for redirection after payment is completed. If provided, a **Continue** button will be shown on the payment page. If shoppers select the button, they are redirected to the specified URL.
106106
*/

src/typings/checkout/paymentLinkResponse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class PaymentLinkResponse {
104104
/**
105105
* List of fields that the shopper has to provide on the payment page before completing the payment. For more information, refer to [Provide shopper information](https://docs.adyen.com/unified-commerce/pay-by-link/payment-links/api#shopper-information). Possible values: * **billingAddress** – The address where to send the invoice. * **deliveryAddress** – The address where the purchased goods should be delivered. * **shopperEmail** – The shopper\'s email address. * **shopperName** – The shopper\'s full name. * **telephoneNumber** – The shopper\'s phone number.
106106
*/
107-
"requiredShopperFields"?: PaymentLinkResponse.RequiredShopperFieldsEnum;
107+
"requiredShopperFields"?: Array<PaymentLinkResponse.RequiredShopperFieldsEnum>;
108108
/**
109109
* Website URL used for redirection after payment is completed. If provided, a **Continue** button will be shown on the payment page. If shoppers select the button, they are redirected to the specified URL.
110110
*/

templates-v7/typescript/model/model.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
3737
*/
3838
{{/deprecated}}
3939
{{/description}}
40-
"{{name}}"{{^required}}?{{/required}}: {{#isEnum}}{{{classname}}}.{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} | null{{/isNullable}};
40+
"{{name}}"{{^required}}?{{/required}}: {{#isEnum}}{{#containerTypeMapped}}{{{.}}}<{{/containerTypeMapped}}{{{classname}}}.{{{enumName}}}{{#containerTypeMapped}}>{{/containerTypeMapped}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} | null{{/isNullable}};
4141
{{/vars}}
4242

4343
{{#discriminator}}

0 commit comments

Comments
 (0)