Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sdk-generation-log/checkout.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"service": "checkout",
"project": "node",
"generatedAt": "2026-07-13T09:45:25Z",
"openapiCommitSha": "334900842b135eb9fc1a17afebd46a4f07793aec",
"automationCommitSha": "5d4b281c0c2fc1bf24530386ae54ce50888f6ae4",
"libraryCommitSha": "378939eea344043a2d17f4717865ff5b35abc05d"
"generatedAt": "2026-08-21T14:01:52Z",
"openapiCommitSha": "bee086f2cd666ac7cb5b5ba2813a8b5dc943c2d2",
"automationCommitSha": "8d09e0f762f7b00c707748d84d0d002964410c0f",
"libraryCommitSha": "3b84a188ef071064636a19f53f95f8aa7112dd91"
}
270 changes: 270 additions & 0 deletions src/__tests__/checkout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,259 @@ describe("Checkout", (): void => {
expect(paymentsResponse.pspReference).toBeTruthy();
});

test("should make a payment with nested lodging enhanced scheme data.", async (): Promise<void> => {
const paymentsRequest: Types.checkout.PaymentRequest = {
amount: createAmountObject("USD", 20000),
reference: "YOUR_ORDER_NUMBER",
paymentMethod: {
type: Types.checkout.CardDetails.TypeEnum.Scheme,
cvc: "737",
expiryMonth: "03",
expiryYear: "2030",
holderName: "John Smith",
number: "4444333322221111",
},
returnUrl: "https://your-company.example.com/...",
merchantAccount,
enhancedSchemeData: {
lodging: {
checkInDate: "2023-03-12",
checkOutDate: "2023-03-14",
customerServicePhoneNumber: "8001122334",
fireSafetyCompliance: true,
folio: {
cashAdvances: 100,
number: "AB12345",
},
foodBeverageCharges: 1000,
noShow: true,
prepaidExpenses: 500,
propertyPhoneNumber: "8001122334",
rooms: [{
numberOfNights: 2,
rate: 50,
}],
totalRoomTax: 400,
},
},
};
scope.post("/payments", (body) => {
expect(body).toEqual(paymentsRequest);
return true;
})
.matchHeader("Idempotency-Key", "YOUR_IDEMPOTENCY_KEY")
.reply(200, paymentsSuccess);

const response = await checkoutService.PaymentsApi.payments(
paymentsRequest,
{idempotencyKey: "YOUR_IDEMPOTENCY_KEY"},
);

expect(response.pspReference).toBeTruthy();
});

test("should make a payment with nested airline enhanced scheme data.", async (): Promise<void> => {
const paymentsRequest: Types.checkout.PaymentRequest = {
amount: createAmountObject("USD", 20000),
reference: "YOUR_ORDER_NUMBER",
paymentMethod: {
type: Types.checkout.CardDetails.TypeEnum.Scheme,
cvc: "737",
expiryMonth: "03",
expiryYear: "2030",
holderName: "John Smith",
number: "4444333322221111",
},
returnUrl: "https://your-company.example.com/...",
merchantAccount,
enhancedSchemeData: {
airline: {
code: "074",
computerizedReservationSystem: "SABR",
documentType: "01",
flightDate: new Date("2023-03-22T11:00:00.000Z"),
passengerName: "John Smith",
ticket: {
issueAddress: "Amsterdam",
number: "AIRLINE_TICKET_NUMBER",
},
travelAgency: {
code: "12345678",
name: "TRAVEL_AGENCY_NAME",
},
legs: [
{
carrierCode: "KL",
classOfTravel: "F",
dateOfTravel: new Date("2023-03-22T11:00:00.000Z"),
departureAirportCode: "AMS",
departureTax: 100,
destinationAirportCode: "CDG",
fareBasisCode: "F",
flightNumber: "1234",
stopOverCode: "X",
},
{
carrierCode: "AF",
classOfTravel: "Y",
dateOfTravel: new Date("2023-03-24T16:00:00.000Z"),
departureAirportCode: "CDG",
departureTax: 100,
destinationAirportCode: "AMS",
fareBasisCode: "Y",
flightNumber: "4321",
stopOverCode: "X",
},
],
},
},
};
scope.post("/payments", (body) => {
expect(body.additionalData).toBeUndefined();
expect(body.enhancedSchemeData).toEqual({
airline: {
code: "074",
computerizedReservationSystem: "SABR",
documentType: "01",
flightDate: "2023-03-22T11:00:00.000Z",
legs: [
{
carrierCode: "KL",
classOfTravel: "F",
dateOfTravel: "2023-03-22T11:00:00.000Z",
departureAirportCode: "AMS",
departureTax: 100,
destinationAirportCode: "CDG",
fareBasisCode: "F",
flightNumber: "1234",
stopOverCode: "X",
},
{
carrierCode: "AF",
classOfTravel: "Y",
dateOfTravel: "2023-03-24T16:00:00.000Z",
departureAirportCode: "CDG",
departureTax: 100,
destinationAirportCode: "AMS",
fareBasisCode: "Y",
flightNumber: "4321",
stopOverCode: "X",
},
],
passengerName: "John Smith",
ticket: {
issueAddress: "Amsterdam",
number: "AIRLINE_TICKET_NUMBER",
},
travelAgency: {
code: "12345678",
name: "TRAVEL_AGENCY_NAME",
},
},
});
return true;
})
.matchHeader("Idempotency-Key", "YOUR_IDEMPOTENCY_KEY")
.reply(200, paymentsSuccess);

const response = await checkoutService.PaymentsApi.payments(
paymentsRequest,
{idempotencyKey: "YOUR_IDEMPOTENCY_KEY"},
);

expect(response.pspReference).toBeTruthy();
});

test("should make a payment with nested level 2/3 enhanced scheme data.", async (): Promise<void> => {
const levelTwoThree: Types.checkout.LevelTwoThree = {
customerReferenceNumber: "101",
destination: {
countryCode: "USA",
postalCode: "10003",
stateOrProvince: "NYC",
},
dutyAmount: 5000,
freightAmount: 10000,
itemDetailLines: [
{
commodityCode: "COMMCODE1",
description: "T15 Test products 1",
discountAmount: 5000,
productCode: "TEST120",
quantity: 9,
totalAmount: 85000,
unitOfMeasure: "m",
unitPrice: 10000,
},
{
commodityCode: "COMMCODE2",
description: "T15 Test products 2",
discountAmount: 5000,
productCode: "TEST120",
quantity: 9,
totalAmount: 85000,
unitOfMeasure: "m",
unitPrice: 10000,
},
],
orderDate: "2023-01-01",
shipFromPostalCode: "1011DJ",
totalTaxAmount: 20000,
};
const paymentsRequest: Types.checkout.PaymentRequest = {
amount: createAmountObject("USD", 200000),
reference: "YOUR_ORDER_NUMBER",
paymentMethod: {
type: Types.checkout.CardDetails.TypeEnum.Scheme,
cvc: "737",
expiryMonth: "03",
expiryYear: "2030",
holderName: "John Smith",
number: "5555555555554444",
},
returnUrl: "https://your-company.example.com/...",
merchantAccount,
enhancedSchemeData: {levelTwoThree},
};
scope.post("/payments", (body) => {
expect(body.additionalData).toBeUndefined();
expect(body.enhancedSchemeData).toEqual({levelTwoThree});
return true;
})
.matchHeader("Idempotency-Key", "YOUR_IDEMPOTENCY_KEY")
.reply(200, {
pspReference: "8915844059375211",
resultCode: "Authorised",
authCode: "506847",
additionalData: {
cardSchemeEnhancedDataLevel: "L2",
cardPaymentMethod: "visa",
cardIssuingBank: "Bank of America",
cardIssuingCountry: "US",
cardIssuingCurrency: "USD",
cardBin: "411111",
fundingSource: "CREDIT",
},
});

const response = await checkoutService.PaymentsApi.payments(
paymentsRequest,
{idempotencyKey: "YOUR_IDEMPOTENCY_KEY"},
);

expect(response.pspReference).toBe("8915844059375211");
expect(response.resultCode).toBe(Types.checkout.PaymentResponse.ResultCodeEnum.Authorised);
expect(response.additionalData).toEqual({
cardSchemeEnhancedDataLevel: "L2",
cardPaymentMethod: "visa",
cardIssuingBank: "Bank of America",
cardIssuingCountry: "US",
cardIssuingCurrency: "USD",
cardBin: "411111",
fundingSource: "CREDIT",
});
});

test("Should properly handle error responses from API", async (): Promise<void> => {
try {
scope.post("/payments")
Expand Down Expand Up @@ -558,6 +811,23 @@ describe("Checkout", (): void => {
expect(sessionsResponse.expiresAt.getFullYear()).toBeGreaterThan(0);
});

test("should update a session.", async (): Promise<void> => {
const updateSessionRequest: Types.checkout.CheckoutSessionPatchSessionRequest = {
amount: createAmountObject("USD", 1500),
payable: true,
sessionData: "encoded-session-data",
};
scope.patch("/sessions/session%2Fid", (body) => {
expect(body).toEqual(updateSessionRequest);
return true;
})
.reply(200, {sessionData: "updated-session-data"});

const response = await checkoutService.PaymentsApi.updateSession("session/id", updateSessionRequest);

expect(response.sessionData).toBe("updated-session-data");
});

test("should create a session instantiating an object", async (): Promise<void> => {

const expectedPayload = {
Expand Down
24 changes: 24 additions & 0 deletions src/services/checkout/paymentsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import Resource from "../resource";
import { ObjectSerializer } from "../../typings/checkout/objectSerializer";
import { CardDetailsRequest } from "../../typings/checkout/models";
import { CardDetailsResponse } from "../../typings/checkout/models";
import { CheckoutSessionPatchSessionRequest } from "../../typings/checkout/models";
import { CheckoutSessionPatchSessionResponse } from "../../typings/checkout/models";
import { CreateCheckoutSessionRequest } from "../../typings/checkout/models";
import { CreateCheckoutSessionResponse } from "../../typings/checkout/models";
import { PaymentDetailsRequest } from "../../typings/checkout/models";
Expand Down Expand Up @@ -167,4 +169,26 @@ export class PaymentsApi extends Service {
return ObjectSerializer.deserialize(response, "CreateCheckoutSessionResponse");
}

/**
* @summary Update a payment session
* @param sessionId {@link string }
* @param checkoutSessionPatchSessionRequest {@link CheckoutSessionPatchSessionRequest }
* @param requestOptions {@link IRequest.Options }
* @return {@link CheckoutSessionPatchSessionResponse }
*/
public async updateSession(sessionId: string, checkoutSessionPatchSessionRequest: CheckoutSessionPatchSessionRequest, requestOptions?: IRequest.Options): Promise<CheckoutSessionPatchSessionResponse> {
const endpoint = `${this.baseUrl}/sessions/{sessionId}`
.replace("{" + "sessionId" + "}", encodeURIComponent(String(sessionId)));
const resource = new Resource(this, endpoint);

const request: CheckoutSessionPatchSessionRequest = ObjectSerializer.serialize(checkoutSessionPatchSessionRequest, "CheckoutSessionPatchSessionRequest");
const response = await getJsonResponse<CheckoutSessionPatchSessionRequest, CheckoutSessionPatchSessionResponse>(
resource,
request,
{ ...requestOptions, method: "PATCH" }
);

return ObjectSerializer.deserialize(response, "CheckoutSessionPatchSessionResponse");
}

}
10 changes: 10 additions & 0 deletions src/typings/checkout/affirmDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export class AffirmDetails {
*/
"checkoutAttemptId"?: string;
/**
* The Affirm financing program to apply to this transaction.
*/
"financingProgram"?: string;
/**
* Base64-encoded JSON object containing SDK related parameters required by the SDK
*/
"sdkData"?: string;
Expand All @@ -33,6 +37,12 @@ export class AffirmDetails {
"type": "string",
"format": ""
},
{
"name": "financingProgram",
"baseName": "financingProgram",
"type": "string",
"format": ""
},
{
"name": "sdkData",
"baseName": "sdkData",
Expand Down
4 changes: 2 additions & 2 deletions src/typings/checkout/agency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

export class Agency {
/**
* The reference number for the invoice, issued by the agency. * Encoding: ASCII * minLength: 1 character * maxLength: 6 characters
* The reference number for the invoice, issued by the agency. * Encoding: ASCII * minLength: 1 character * maxLength: 6 characters * **additionalData key:** `airline.agency_invoice_number`
*/
"invoiceNumber"?: string;
/**
* The two-letter agency plan identifier. * Encoding: ASCII * minLength: 2 characters * maxLength: 2 characters
* The two-letter agency plan identifier. * Encoding: ASCII * minLength: 2 characters * maxLength: 2 characters * **additionalData key:** `airline.agency_plan_name`
*/
"planName"?: string;

Expand Down
Loading
Loading