/** * Paze Checkout APILib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ import { ApiResponse, RequestOptions } from '../core.js'; import { CheckoutSessionCompleteRequest, checkoutSessionCompleteRequestSchema, } from '../models/checkoutSessionCompleteRequest.js'; import { CheckoutSessionCompleteResponse, checkoutSessionCompleteResponseSchema, } from '../models/checkoutSessionCompleteResponse.js'; import { CheckoutSessionCreateRequest, checkoutSessionCreateRequestSchema, } from '../models/checkoutSessionCreateRequest.js'; import { CheckoutSessionCreateResponse, checkoutSessionCreateResponseSchema, } from '../models/checkoutSessionCreateResponse.js'; import { CheckoutSessionReviewRequest, checkoutSessionReviewRequestSchema, } from '../models/checkoutSessionReviewRequest.js'; import { CheckoutSessionReviewResponse, checkoutSessionReviewResponseSchema, } from '../models/checkoutSessionReviewResponse.js'; import { BaseController } from './baseController.js'; import { ApiErrorResponseError } from '../errors/apiErrorResponseError.js'; import { SimpleError } from '../errors/simpleError.js'; export class CheckoutSessionController extends BaseController { /** * Creates the checkout session required to launch the Paze checkout UX inside a merchant mobile * application. * * * @param body * @return Response from the API call */ async createCheckoutSession( body: CheckoutSessionCreateRequest, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('POST', '/v1/checkout/sessions/create'); const mapped = req.prepareArgs({ body: [body, checkoutSessionCreateRequestSchema], }); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiErrorResponseError, 'Invalid request'); req.throwOn(401, SimpleError, 'Unauthorized'); req.throwOn(422, ApiErrorResponseError, 'Unprocessable entity'); req.throwOn(500, ApiErrorResponseError, 'Server error'); req.authenticate([{ oAuth2: true }]); return req.callAsJson(checkoutSessionCreateResponseSchema, requestOptions); } /** * Retrieves information about the card and consumer selected in the Paze checkout experience. * * * @param body * @return Response from the API call */ async reviewCheckoutSession( body: CheckoutSessionReviewRequest, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('POST', '/v1/checkout/sessions/review'); const mapped = req.prepareArgs({ body: [body, checkoutSessionReviewRequestSchema], }); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiErrorResponseError, 'Invalid request'); req.throwOn(401, SimpleError, 'Unauthorized'); req.throwOn(422, ApiErrorResponseError, 'Processing error'); req.throwOn(500, ApiErrorResponseError, 'Server error'); req.authenticate([{ oAuth2: true }]); return req.callAsJson(checkoutSessionReviewResponseSchema, requestOptions); } /** * Closes the merchant and consumer session and returns a payload identifier and optionally a secure * payload used for payment processing. * * * @param body * @return Response from the API call */ async completeCheckoutSession( body: CheckoutSessionCompleteRequest, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('POST', '/v1/checkout/sessions/complete'); const mapped = req.prepareArgs({ body: [body, checkoutSessionCompleteRequestSchema], }); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, ApiErrorResponseError, 'Invalid request'); req.throwOn(401, SimpleError, 'Unauthorized'); req.throwOn(422, ApiErrorResponseError, 'Unprocessable entity'); req.throwOn(500, ApiErrorResponseError, 'Server error'); req.authenticate([{ oAuth2: true }]); return req.callAsJson( checkoutSessionCompleteResponseSchema, requestOptions ); } }