@monei-js/node-sdk
Version:
Node.js SDK for MONEI Digital Payment Gateway
846 lines (837 loc) • 248 kB
JavaScript
'use strict';
var globalAxios = require('axios');
var crypto = require('crypto');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return n;
}
var globalAxios__default = /*#__PURE__*/_interopDefaultLegacy(globalAxios);
var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
var name = "@monei-js/node-sdk";
var description = "Node.js SDK for MONEI Digital Payment Gateway";
var version = "1.9.1";
var homepage = "https://monei.com";
var author = "MONEI <support@monei.com> (https://monei.com)";
var type = "module";
var license = "MIT";
var contributors = [
"Dmitriy Nevzorov <dn@monei.com>"
];
var repository = {
type: "git",
url: "https://github.com/MONEI/monei-node-sdk"
};
var keywords = [
"monei",
"payment gateway",
"payment processing",
"credit cards",
"api"
];
var files = [
"dist",
"LICENSE",
"README.md"
];
var source = "./index.ts";
var main = "./dist/index.cjs";
var module$1 = "./dist/index.module.js";
var types = "./dist/index.d.ts";
var exports$1 = {
".": {
types: "./dist/index.d.ts",
require: "./dist/index.cjs",
"import": "./dist/index.module.js"
}
};
var publishConfig = {
access: "public",
registry: "https://registry.npmjs.org/"
};
var scripts = {
generate: "openapi-generator-cli generate --generator-key typescript-axios",
"generate:local": "openapi-generator-cli generate --generator-key typescript-axios-local",
compile: "microbundle -f modern,cjs --target node --strict --name index --tsconfig tsconfig.build.json",
dev: "microbundle watch -f modern,cjs --target node --strict --name index --tsconfig tsconfig.build.json",
build: "run-s generate replace format compile",
"build:local": "run-s generate:local replace format compile",
replace: "node scripts/replace.js",
release: "release-it",
prepack: "yarn build",
test: "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
commitlint: "commitlint --edit",
typecheck: "tsc --noEmit",
"lint-staged": "lint-staged",
format: "prettier --write \"**/*.ts\"",
lint: "eslint .",
"lint:fix": "eslint . --fix",
prepare: "husky"
};
var devDependencies = {
"@commitlint/cli": "^20.1.0",
"@commitlint/config-conventional": "^20.0.0",
"@eslint/js": "^9.39.1",
"@openapitools/openapi-generator-cli": "^2.25.2",
"@release-it/conventional-changelog": "10.0.1",
"@types/node": "^22.19.1",
"@vitest/coverage-v8": "^4.0.14",
"axios-mock-adapter": "^2.1.0",
eslint: "^9.39.1",
husky: "^9.1.7",
"lint-staged": "^16.2.7",
microbundle: "^0.15.1",
"npm-run-all": "^4.1.5",
prettier: "^3.7.3",
"release-it": "^19.0.6",
"replace-in-file": "^8.3.0",
typescript: "^5.9.3",
"typescript-eslint": "^8.48.0",
vitest: "^4.0.14"
};
var dependencies = {
axios: "^1.13.2"
};
var packageManager = "yarn@4.12.0";
var pkg = {
name: name,
description: description,
version: version,
homepage: homepage,
author: author,
type: type,
license: license,
contributors: contributors,
repository: repository,
keywords: keywords,
files: files,
source: source,
main: main,
module: module$1,
types: types,
exports: exports$1,
publishConfig: publishConfig,
scripts: scripts,
"lint-staged": {
"*.ts": [
"prettier --write",
"eslint --quiet --fix"
]
},
devDependencies: devDependencies,
dependencies: dependencies,
packageManager: packageManager
};
/* tslint:disable */
const BASE_PATH = 'https://api.monei.com/v1'.replace(/\/+$/, '');
/**
*
* @export
* @class BaseAPI
*/
class BaseAPI {
constructor(configuration, basePath = BASE_PATH, axios = globalAxios__default["default"]) {
this.basePath = void 0;
this.axios = void 0;
this.configuration = void 0;
this.basePath = basePath;
this.axios = axios;
if (configuration) {
var _configuration$basePa;
this.configuration = configuration;
this.basePath = (_configuration$basePa = configuration.basePath) != null ? _configuration$basePa : basePath;
}
}
}
/**
*
* @export
* @class RequiredError
* @extends {Error}
*/
class RequiredError extends Error {
constructor(field, msg) {
super(msg);
this.field = void 0;
this.field = field;
this.name = 'RequiredError';
}
}
/**
*
* @export
*/
const operationServerMap = {};
/* tslint:disable */
/**
*
* @export
*/
const DUMMY_BASE_URL = 'https://example.com';
/**
*
* @throws {RequiredError}
* @export
*/
const assertParamExists = function (functionName, paramName, paramValue) {
if (paramValue === null || paramValue === undefined) {
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
}
};
/**
*
* @export
*/
const setApiKeyToObject = async function (object, keyParamName, configuration) {
if (configuration && configuration.apiKey) {
const localVarApiKeyValue = typeof configuration.apiKey === 'function' ? await configuration.apiKey(keyParamName) : await configuration.apiKey;
object[keyParamName] = localVarApiKeyValue;
}
};
function setFlattenedQueryParams(urlSearchParams, parameter, key = '') {
if (parameter == null) return;
if (typeof parameter === 'object') {
if (Array.isArray(parameter)) {
parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
} else {
Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
}
} else {
if (urlSearchParams.has(key)) {
urlSearchParams.append(key, parameter);
} else {
urlSearchParams.set(key, parameter);
}
}
}
/**
*
* @export
*/
const setSearchParams = function (url, ...objects) {
const searchParams = new URLSearchParams(url.search);
setFlattenedQueryParams(searchParams, objects);
url.search = searchParams.toString();
};
/**
*
* @export
*/
const serializeDataIfNeeded = function (value, requestOptions, configuration) {
const nonString = typeof value !== 'string';
const needsSerialization = nonString && configuration && configuration.isJsonMime ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString;
return needsSerialization ? JSON.stringify(value !== undefined ? value : {}) : value || '';
};
/**
*
* @export
*/
const toPathString = function (url) {
return url.pathname + url.search + url.hash;
};
/**
*
* @export
*/
const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
return (axios = globalAxios, basePath = BASE_PATH) => {
var _configuration$basePa;
const axiosRequestArgs = {
...axiosArgs.options,
url: (axios.defaults.baseURL ? '' : (_configuration$basePa = configuration == null ? void 0 : configuration.basePath) != null ? _configuration$basePa : basePath) + axiosArgs.url
};
return axios.request(axiosRequestArgs);
};
};
/* tslint:disable */
/**
* ApplePayCertificateApi - axios parameter creator
* @export
*/
const ApplePayCertificateApiAxiosParamCreator = function (configuration) {
return {
/**
* Activates an Apple Pay certificate by uploading the signed certificate from Apple. After creating a certificate in the Apple Developer Portal using your CSR, download the signed certificate and upload it here to activate payment processing. ## Activation process 1. Ensure you have downloaded the signed certificate (`.cer` file) from Apple Developer Portal. 2. Convert the certificate to base64: ```bash base64 -i apple_pay.cer ``` 3. Call this endpoint with the base64-encoded certificate in the `cert` field. ## Validation The certificate is validated to ensure: - It matches the private key generated when creating the CSR - It has a valid expiration date Once activated, the certificate becomes available for decrypting Apple Pay payment tokens in your iOS app. ## Notes - A certificate can only be activated once. - The CSR is cleared after successful activation. - The expiration date is extracted and stored for monitoring.
* @summary Activate Certificate
* @param {string} id The unique identifier of the certificate.
* @param {ActivateApplePayCertificateRequest} activateApplePayCertificateRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
activate: async (id, activateApplePayCertificateRequest, options = {}) => {
// verify required parameter 'id' is not null or undefined
assertParamExists('activate', 'id', id);
// verify required parameter 'activateApplePayCertificateRequest' is not null or undefined
assertParamExists('activate', 'activateApplePayCertificateRequest', activateApplePayCertificateRequest);
const localVarPath = `/apple-pay/certificates/{id}/activate`.replace(`{${'id'}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = {
method: 'POST',
...baseOptions,
...options
};
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication APIKey required
await setApiKeyToObject(localVarHeaderParameter, 'Authorization', configuration);
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers
};
localVarRequestOptions.data = serializeDataIfNeeded(activateApplePayCertificateRequest, localVarRequestOptions, configuration);
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions
};
},
/**
* Creates a new Apple Pay certificate by generating a Certificate Signing Request (CSR). Use this endpoint to start the certificate creation process for accepting Apple Pay in your iOS app. ## Setup workflow 1. **Call this endpoint** to generate a CSR. The response includes the `csr` field in base64 format. 2. **Decode the CSR** and save it as a `.certSigningRequest` file: ```bash echo \"CSR_VALUE\" | base64 -d > apple_pay.certSigningRequest ``` 3. **Go to [Apple Developer Portal](https://developer.apple.com/account/resources/certificates/list)**: - Navigate to Certificates, Identifiers & Profiles - Select your Merchant ID under Identifiers - In the \"Apple Pay Payment Processing Certificate\" section, click \"Create Certificate\" - Upload the `.certSigningRequest` file from step 2 - Download the signed certificate (`.cer` file) 4. **Convert the certificate to base64**: ```bash base64 -i apple_pay.cer ``` 5. **Activate the certificate** using the [Activate Certificate](https://docs.monei.com/apis/rest/apple-pay-certificates-activate/) endpoint with the base64 value. ## Important notes - **CSRs expire after 24 hours.** Complete the certificate creation in Apple Developer Portal within this window, or generate a new CSR. - Each CSR can only be used once. If you need a new certificate, create a new CSR. - The private key is securely generated and stored by MONEI. You never need to handle private keys directly. - You must be enrolled in the [Apple Developer Program](https://developer.apple.com/programs/) to create certificates. - The CSR is cleared from the response after the certificate is activated.
* @summary Create Certificate
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
create: async (options = {}) => {
const localVarPath = `/apple-pay/certificates`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = {
method: 'POST',
...baseOptions,
...options
};
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication APIKey required
await setApiKeyToObject(localVarHeaderParameter, 'Authorization', configuration);
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers
};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions
};
},
/**
* Retrieves a specific Apple Pay certificate by its ID. Returns the certificate object with its current status, CSR (if not yet activated), and expiration date (if activated).
* @summary Get Certificate
* @param {string} id The unique identifier of the certificate.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
get: async (id, options = {}) => {
// verify required parameter 'id' is not null or undefined
assertParamExists('get', 'id', id);
const localVarPath = `/apple-pay/certificates/{id}`.replace(`{${'id'}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = {
method: 'GET',
...baseOptions,
...options
};
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication APIKey required
await setApiKeyToObject(localVarHeaderParameter, 'Authorization', configuration);
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers
};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions
};
},
/**
* Retrieves all Apple Pay certificates for your account. Returns an array of certificate objects, including both active and inactive certificates. Use this to view all certificates and their status.
* @summary List Certificates
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getAll: async (options = {}) => {
const localVarPath = `/apple-pay/certificates`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = {
method: 'GET',
...baseOptions,
...options
};
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication APIKey required
await setApiKeyToObject(localVarHeaderParameter, 'Authorization', configuration);
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers
};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions
};
},
/**
* Deletes an Apple Pay certificate. This permanently removes the certificate and its associated private key. The certificate will no longer be available for payment processing. **Warning**: This action cannot be undone. If you only want to temporarily disable a certificate, use the [Update Certificate](https://docs.monei.com/apis/rest/apple-pay-certificates-update/) endpoint instead.
* @summary Delete Certificate
* @param {string} id The unique identifier of the certificate.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
remove: async (id, options = {}) => {
// verify required parameter 'id' is not null or undefined
assertParamExists('remove', 'id', id);
const localVarPath = `/apple-pay/certificates/{id}`.replace(`{${'id'}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = {
method: 'DELETE',
...baseOptions,
...options
};
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication APIKey required
await setApiKeyToObject(localVarHeaderParameter, 'Authorization', configuration);
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers
};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions
};
},
/**
* Updates an Apple Pay certificate\'s active status. Use this endpoint to enable or disable a certificate. Disabling a certificate prevents it from being used for payment token decryption while keeping it available for future use.
* @summary Update Certificate
* @param {string} id The unique identifier of the certificate.
* @param {UpdateApplePayCertificateRequest} updateApplePayCertificateRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
update: async (id, updateApplePayCertificateRequest, options = {}) => {
// verify required parameter 'id' is not null or undefined
assertParamExists('update', 'id', id);
// verify required parameter 'updateApplePayCertificateRequest' is not null or undefined
assertParamExists('update', 'updateApplePayCertificateRequest', updateApplePayCertificateRequest);
const localVarPath = `/apple-pay/certificates/{id}`.replace(`{${'id'}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = {
method: 'POST',
...baseOptions,
...options
};
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication APIKey required
await setApiKeyToObject(localVarHeaderParameter, 'Authorization', configuration);
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers
};
localVarRequestOptions.data = serializeDataIfNeeded(updateApplePayCertificateRequest, localVarRequestOptions, configuration);
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions
};
}
};
};
/**
* ApplePayCertificateApi - functional programming interface
* @export
*/
const ApplePayCertificateApiFp = function (configuration) {
const localVarAxiosParamCreator = ApplePayCertificateApiAxiosParamCreator(configuration);
return {
/**
* Activates an Apple Pay certificate by uploading the signed certificate from Apple. After creating a certificate in the Apple Developer Portal using your CSR, download the signed certificate and upload it here to activate payment processing. ## Activation process 1. Ensure you have downloaded the signed certificate (`.cer` file) from Apple Developer Portal. 2. Convert the certificate to base64: ```bash base64 -i apple_pay.cer ``` 3. Call this endpoint with the base64-encoded certificate in the `cert` field. ## Validation The certificate is validated to ensure: - It matches the private key generated when creating the CSR - It has a valid expiration date Once activated, the certificate becomes available for decrypting Apple Pay payment tokens in your iOS app. ## Notes - A certificate can only be activated once. - The CSR is cleared after successful activation. - The expiration date is extracted and stored for monitoring.
* @summary Activate Certificate
* @param {string} id The unique identifier of the certificate.
* @param {ActivateApplePayCertificateRequest} activateApplePayCertificateRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async activate(id, activateApplePayCertificateRequest, options) {
var _configuration$server, _operationServerMap$A;
const localVarAxiosArgs = await localVarAxiosParamCreator.activate(id, activateApplePayCertificateRequest, options);
const localVarOperationServerIndex = (_configuration$server = configuration == null ? void 0 : configuration.serverIndex) != null ? _configuration$server : 0;
const localVarOperationServerBasePath = (_operationServerMap$A = operationServerMap['ApplePayCertificateApi.activate']) == null || (_operationServerMap$A = _operationServerMap$A[localVarOperationServerIndex]) == null ? void 0 : _operationServerMap$A.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios__default["default"], BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Creates a new Apple Pay certificate by generating a Certificate Signing Request (CSR). Use this endpoint to start the certificate creation process for accepting Apple Pay in your iOS app. ## Setup workflow 1. **Call this endpoint** to generate a CSR. The response includes the `csr` field in base64 format. 2. **Decode the CSR** and save it as a `.certSigningRequest` file: ```bash echo \"CSR_VALUE\" | base64 -d > apple_pay.certSigningRequest ``` 3. **Go to [Apple Developer Portal](https://developer.apple.com/account/resources/certificates/list)**: - Navigate to Certificates, Identifiers & Profiles - Select your Merchant ID under Identifiers - In the \"Apple Pay Payment Processing Certificate\" section, click \"Create Certificate\" - Upload the `.certSigningRequest` file from step 2 - Download the signed certificate (`.cer` file) 4. **Convert the certificate to base64**: ```bash base64 -i apple_pay.cer ``` 5. **Activate the certificate** using the [Activate Certificate](https://docs.monei.com/apis/rest/apple-pay-certificates-activate/) endpoint with the base64 value. ## Important notes - **CSRs expire after 24 hours.** Complete the certificate creation in Apple Developer Portal within this window, or generate a new CSR. - Each CSR can only be used once. If you need a new certificate, create a new CSR. - The private key is securely generated and stored by MONEI. You never need to handle private keys directly. - You must be enrolled in the [Apple Developer Program](https://developer.apple.com/programs/) to create certificates. - The CSR is cleared from the response after the certificate is activated.
* @summary Create Certificate
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async create(options) {
var _configuration$server2, _operationServerMap$A2;
const localVarAxiosArgs = await localVarAxiosParamCreator.create(options);
const localVarOperationServerIndex = (_configuration$server2 = configuration == null ? void 0 : configuration.serverIndex) != null ? _configuration$server2 : 0;
const localVarOperationServerBasePath = (_operationServerMap$A2 = operationServerMap['ApplePayCertificateApi.create']) == null || (_operationServerMap$A2 = _operationServerMap$A2[localVarOperationServerIndex]) == null ? void 0 : _operationServerMap$A2.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios__default["default"], BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Retrieves a specific Apple Pay certificate by its ID. Returns the certificate object with its current status, CSR (if not yet activated), and expiration date (if activated).
* @summary Get Certificate
* @param {string} id The unique identifier of the certificate.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async get(id, options) {
var _configuration$server3, _operationServerMap$A3;
const localVarAxiosArgs = await localVarAxiosParamCreator.get(id, options);
const localVarOperationServerIndex = (_configuration$server3 = configuration == null ? void 0 : configuration.serverIndex) != null ? _configuration$server3 : 0;
const localVarOperationServerBasePath = (_operationServerMap$A3 = operationServerMap['ApplePayCertificateApi.get']) == null || (_operationServerMap$A3 = _operationServerMap$A3[localVarOperationServerIndex]) == null ? void 0 : _operationServerMap$A3.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios__default["default"], BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Retrieves all Apple Pay certificates for your account. Returns an array of certificate objects, including both active and inactive certificates. Use this to view all certificates and their status.
* @summary List Certificates
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getAll(options) {
var _configuration$server4, _operationServerMap$A4;
const localVarAxiosArgs = await localVarAxiosParamCreator.getAll(options);
const localVarOperationServerIndex = (_configuration$server4 = configuration == null ? void 0 : configuration.serverIndex) != null ? _configuration$server4 : 0;
const localVarOperationServerBasePath = (_operationServerMap$A4 = operationServerMap['ApplePayCertificateApi.getAll']) == null || (_operationServerMap$A4 = _operationServerMap$A4[localVarOperationServerIndex]) == null ? void 0 : _operationServerMap$A4.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios__default["default"], BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Deletes an Apple Pay certificate. This permanently removes the certificate and its associated private key. The certificate will no longer be available for payment processing. **Warning**: This action cannot be undone. If you only want to temporarily disable a certificate, use the [Update Certificate](https://docs.monei.com/apis/rest/apple-pay-certificates-update/) endpoint instead.
* @summary Delete Certificate
* @param {string} id The unique identifier of the certificate.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async remove(id, options) {
var _configuration$server5, _operationServerMap$A5;
const localVarAxiosArgs = await localVarAxiosParamCreator.remove(id, options);
const localVarOperationServerIndex = (_configuration$server5 = configuration == null ? void 0 : configuration.serverIndex) != null ? _configuration$server5 : 0;
const localVarOperationServerBasePath = (_operationServerMap$A5 = operationServerMap['ApplePayCertificateApi.remove']) == null || (_operationServerMap$A5 = _operationServerMap$A5[localVarOperationServerIndex]) == null ? void 0 : _operationServerMap$A5.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios__default["default"], BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Updates an Apple Pay certificate\'s active status. Use this endpoint to enable or disable a certificate. Disabling a certificate prevents it from being used for payment token decryption while keeping it available for future use.
* @summary Update Certificate
* @param {string} id The unique identifier of the certificate.
* @param {UpdateApplePayCertificateRequest} updateApplePayCertificateRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async update(id, updateApplePayCertificateRequest, options) {
var _configuration$server6, _operationServerMap$A6;
const localVarAxiosArgs = await localVarAxiosParamCreator.update(id, updateApplePayCertificateRequest, options);
const localVarOperationServerIndex = (_configuration$server6 = configuration == null ? void 0 : configuration.serverIndex) != null ? _configuration$server6 : 0;
const localVarOperationServerBasePath = (_operationServerMap$A6 = operationServerMap['ApplePayCertificateApi.update']) == null || (_operationServerMap$A6 = _operationServerMap$A6[localVarOperationServerIndex]) == null ? void 0 : _operationServerMap$A6.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios__default["default"], BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
}
};
};
/**
* ApplePayCertificateApi - factory interface
* @export
*/
const ApplePayCertificateApiFactory = function (configuration, basePath, axios) {
const localVarFp = ApplePayCertificateApiFp(configuration);
return {
/**
* Activates an Apple Pay certificate by uploading the signed certificate from Apple. After creating a certificate in the Apple Developer Portal using your CSR, download the signed certificate and upload it here to activate payment processing. ## Activation process 1. Ensure you have downloaded the signed certificate (`.cer` file) from Apple Developer Portal. 2. Convert the certificate to base64: ```bash base64 -i apple_pay.cer ``` 3. Call this endpoint with the base64-encoded certificate in the `cert` field. ## Validation The certificate is validated to ensure: - It matches the private key generated when creating the CSR - It has a valid expiration date Once activated, the certificate becomes available for decrypting Apple Pay payment tokens in your iOS app. ## Notes - A certificate can only be activated once. - The CSR is cleared after successful activation. - The expiration date is extracted and stored for monitoring.
* @summary Activate Certificate
* @param {string} id The unique identifier of the certificate.
* @param {ActivateApplePayCertificateRequest} activateApplePayCertificateRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
activate(id, activateApplePayCertificateRequest, options) {
return localVarFp.activate(id, activateApplePayCertificateRequest, options).then(request => request(axios, basePath));
},
/**
* Creates a new Apple Pay certificate by generating a Certificate Signing Request (CSR). Use this endpoint to start the certificate creation process for accepting Apple Pay in your iOS app. ## Setup workflow 1. **Call this endpoint** to generate a CSR. The response includes the `csr` field in base64 format. 2. **Decode the CSR** and save it as a `.certSigningRequest` file: ```bash echo \"CSR_VALUE\" | base64 -d > apple_pay.certSigningRequest ``` 3. **Go to [Apple Developer Portal](https://developer.apple.com/account/resources/certificates/list)**: - Navigate to Certificates, Identifiers & Profiles - Select your Merchant ID under Identifiers - In the \"Apple Pay Payment Processing Certificate\" section, click \"Create Certificate\" - Upload the `.certSigningRequest` file from step 2 - Download the signed certificate (`.cer` file) 4. **Convert the certificate to base64**: ```bash base64 -i apple_pay.cer ``` 5. **Activate the certificate** using the [Activate Certificate](https://docs.monei.com/apis/rest/apple-pay-certificates-activate/) endpoint with the base64 value. ## Important notes - **CSRs expire after 24 hours.** Complete the certificate creation in Apple Developer Portal within this window, or generate a new CSR. - Each CSR can only be used once. If you need a new certificate, create a new CSR. - The private key is securely generated and stored by MONEI. You never need to handle private keys directly. - You must be enrolled in the [Apple Developer Program](https://developer.apple.com/programs/) to create certificates. - The CSR is cleared from the response after the certificate is activated.
* @summary Create Certificate
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
create(options) {
return localVarFp.create(options).then(request => request(axios, basePath));
},
/**
* Retrieves a specific Apple Pay certificate by its ID. Returns the certificate object with its current status, CSR (if not yet activated), and expiration date (if activated).
* @summary Get Certificate
* @param {string} id The unique identifier of the certificate.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
get(id, options) {
return localVarFp.get(id, options).then(request => request(axios, basePath));
},
/**
* Retrieves all Apple Pay certificates for your account. Returns an array of certificate objects, including both active and inactive certificates. Use this to view all certificates and their status.
* @summary List Certificates
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getAll(options) {
return localVarFp.getAll(options).then(request => request(axios, basePath));
},
/**
* Deletes an Apple Pay certificate. This permanently removes the certificate and its associated private key. The certificate will no longer be available for payment processing. **Warning**: This action cannot be undone. If you only want to temporarily disable a certificate, use the [Update Certificate](https://docs.monei.com/apis/rest/apple-pay-certificates-update/) endpoint instead.
* @summary Delete Certificate
* @param {string} id The unique identifier of the certificate.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
remove(id, options) {
return localVarFp.remove(id, options).then(request => request(axios, basePath));
},
/**
* Updates an Apple Pay certificate\'s active status. Use this endpoint to enable or disable a certificate. Disabling a certificate prevents it from being used for payment token decryption while keeping it available for future use.
* @summary Update Certificate
* @param {string} id The unique identifier of the certificate.
* @param {UpdateApplePayCertificateRequest} updateApplePayCertificateRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
update(id, updateApplePayCertificateRequest, options) {
return localVarFp.update(id, updateApplePayCertificateRequest, options).then(request => request(axios, basePath));
}
};
};
/**
* ApplePayCertificateApi - object-oriented interface
* @export
* @class ApplePayCertificateApi
* @extends {BaseAPI}
*/
class ApplePayCertificateApi extends BaseAPI {
/**
* Activates an Apple Pay certificate by uploading the signed certificate from Apple. After creating a certificate in the Apple Developer Portal using your CSR, download the signed certificate and upload it here to activate payment processing. ## Activation process 1. Ensure you have downloaded the signed certificate (`.cer` file) from Apple Developer Portal. 2. Convert the certificate to base64: ```bash base64 -i apple_pay.cer ``` 3. Call this endpoint with the base64-encoded certificate in the `cert` field. ## Validation The certificate is validated to ensure: - It matches the private key generated when creating the CSR - It has a valid expiration date Once activated, the certificate becomes available for decrypting Apple Pay payment tokens in your iOS app. ## Notes - A certificate can only be activated once. - The CSR is cleared after successful activation. - The expiration date is extracted and stored for monitoring.
* @summary Activate Certificate
* @param {string} id The unique identifier of the certificate.
* @param {ActivateApplePayCertificateRequest} activateApplePayCertificateRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ApplePayCertificateApi
*/
activate(id, activateApplePayCertificateRequest, options) {
return ApplePayCertificateApiFp(this.configuration).activate(id, activateApplePayCertificateRequest, options).then(request => request(this.axios, this.basePath));
}
/**
* Creates a new Apple Pay certificate by generating a Certificate Signing Request (CSR). Use this endpoint to start the certificate creation process for accepting Apple Pay in your iOS app. ## Setup workflow 1. **Call this endpoint** to generate a CSR. The response includes the `csr` field in base64 format. 2. **Decode the CSR** and save it as a `.certSigningRequest` file: ```bash echo \"CSR_VALUE\" | base64 -d > apple_pay.certSigningRequest ``` 3. **Go to [Apple Developer Portal](https://developer.apple.com/account/resources/certificates/list)**: - Navigate to Certificates, Identifiers & Profiles - Select your Merchant ID under Identifiers - In the \"Apple Pay Payment Processing Certificate\" section, click \"Create Certificate\" - Upload the `.certSigningRequest` file from step 2 - Download the signed certificate (`.cer` file) 4. **Convert the certificate to base64**: ```bash base64 -i apple_pay.cer ``` 5. **Activate the certificate** using the [Activate Certificate](https://docs.monei.com/apis/rest/apple-pay-certificates-activate/) endpoint with the base64 value. ## Important notes - **CSRs expire after 24 hours.** Complete the certificate creation in Apple Developer Portal within this window, or generate a new CSR. - Each CSR can only be used once. If you need a new certificate, create a new CSR. - The private key is securely generated and stored by MONEI. You never need to handle private keys directly. - You must be enrolled in the [Apple Developer Program](https://developer.apple.com/programs/) to create certificates. - The CSR is cleared from the response after the certificate is activated.
* @summary Create Certificate
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ApplePayCertificateApi
*/
create(options) {
return ApplePayCertificateApiFp(this.configuration).create(options).then(request => request(this.axios, this.basePath));
}
/**
* Retrieves a specific Apple Pay certificate by its ID. Returns the certificate object with its current status, CSR (if not yet activated), and expiration date (if activated).
* @summary Get Certificate
* @param {string} id The unique identifier of the certificate.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ApplePayCertificateApi
*/
get(id, options) {
return ApplePayCertificateApiFp(this.configuration).get(id, options).then(request => request(this.axios, this.basePath));
}
/**
* Retrieves all Apple Pay certificates for your account. Returns an array of certificate objects, including both active and inactive certificates. Use this to view all certificates and their status.
* @summary List Certificates
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ApplePayCertificateApi
*/
getAll(options) {
return ApplePayCertificateApiFp(this.configuration).getAll(options).then(request => request(this.axios, this.basePath));
}
/**
* Deletes an Apple Pay certificate. This permanently removes the certificate and its associated private key. The certificate will no longer be available for payment processing. **Warning**: This action cannot be undone. If you only want to temporarily disable a certificate, use the [Update Certificate](https://docs.monei.com/apis/rest/apple-pay-certificates-update/) endpoint instead.
* @summary Delete Certificate
* @param {string} id The unique identifier of the certificate.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ApplePayCertificateApi
*/
remove(id, options) {
return ApplePayCertificateApiFp(this.configuration).remove(id, options).then(request => request(this.axios, this.basePath));
}
/**
* Updates an Apple Pay certificate\'s active status. Use this endpoint to enable or disable a certificate. Disabling a certificate prevents it from being used for payment token decryption while keeping it available for future use.
* @summary Update Certificate
* @param {string} id The unique identifier of the certificate.
* @param {UpdateApplePayCertificateRequest} updateApplePayCertificateRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ApplePayCertificateApi
*/
update(id, updateApplePayCertificateRequest, options) {
return ApplePayCertificateApiFp(this.configuration).update(id, updateApplePayCertificateRequest, options).then(request => request(this.axios, this.basePath));
}
}
/* tslint:disable */
/**
* ApplePayDomainApi - axios parameter creator
* @export
*/
const ApplePayDomainApiAxiosParamCreator = function (configuration) {
return {
/**
* Registers a domain with Apple Pay. This endpoint allows you to register your website domain with Apple Pay, which is required before you can accept Apple Pay payments on your website. The domain must be accessible via HTTPS and have a valid SSL certificate. Before registering, you must download this [domain association file](https://assets.monei.com/apple-pay/apple-developer-merchantid-domain-association/) and host it at `/.well-known/apple-developer-merchantid-domain-association` on your site. For example, if you\'re registering `example.com`, make that file available at `https://example.com/.well-known/apple-developer-merchantid-domain-association`. After registration, Apple will verify your domain. Once verified, you can display Apple Pay buttons and process Apple Pay payments on your website.
* @summary Register Domain
* @param {RegisterApplePayDomainRequest} registerApplePayDomainRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
register: async (registerApplePayDomainRequest, options = {}) => {
// verify required parameter 'registerApplePayDomainRequest' is not null or undefined
assertParamExists('register', 'registerApplePayDomainRequest', registerApplePayDomainRequest);
const localVarPath = `/apple-pay/domains`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = {
method: 'POST',
...baseOptions,
...options
};
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication APIKey required
await setApiKeyToObject(localVarHeaderParameter, 'Authorization', configuration);
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers
};
localVarRequestOptions.data = serializeDataIfNeeded(registerApplePayDomainRequest, localVarRequestOptions, configuration);
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions
};
}
};
};
/**
* ApplePayDomainApi - functional programming interface
* @export
*/
const ApplePayDomainApiFp = function (configuration) {
const localVarAxiosParamCreator = ApplePayDomainApiAxiosParamCreator(configuration);
return {
/**
* Registers a domain with Apple Pay. This endpoint allows you to register your website domain with Apple Pay, which is required before you can accept Apple Pay payments on your website. The domain must be accessible via HTTPS and have a valid SSL certificate. Before registering, you must download this [domain association file](https://assets.monei.com/apple-pay/apple-developer-merchantid-domain-association/) and host it at `/.well-known/apple-developer-merchantid-domain-association` on your site. For example, if you\'re registering `example.com`, make that file available at `https://example.com/.well-known/apple-developer-merchantid-domain-association`. After registration, Apple will verify your domain. Once verified, you can display Apple Pay buttons and process Apple Pay payments on your website.
* @summary Register Domain
* @param {RegisterApplePayDomainRequest} registerApplePayDomainRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async register(registerApplePayDomainRequest, options) {
var _configuration$server, _operationServerMap$A;
const localVarAxiosArgs = await localVarAxiosParamCreator.register(registerApplePayDomainRequest, options);
const localVarOperationServerIndex = (_configuration$server = configuration == null ? void 0 : configuration.serverIndex) != null ? _configuration$server : 0;
const localVarOperationServerBasePath = (_operationServerMap$A = operationServerMap['ApplePayDomainApi.register']) == null || (_operationServerMap$A = _operationServerMap$A[localVarOperationServerIndex]) == null ? void 0 : _operationServerMap$A.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios__default["default"], BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
}
};
};
/**
* ApplePayDomainApi - factory interface
* @export
*/
const ApplePayDomainApiFactory = function (configuration, basePath, axios) {
const localVarFp = ApplePayDomainApiFp(configuration);
return {
/**
* Registers a domain with Apple Pay. This endpoint allows you to register your website domain with Apple Pay, which is required before you can accept Apple Pay payments on your website. The domain must be accessible via HTTPS and have a valid SSL certificate. Before registering, you must download this [domain association file](https://assets.monei.com/apple-pay/apple-developer-merchantid-domain-association/) and host it at `/.well-known/apple-developer-merchantid-domain-association` on your site. For example, if you\'re registering `example.com`, make that file available at `https://example.com/.well-known/apple-developer-merchantid-domain-association`. After registration, Apple will verify your domain. Once verified, you can display Apple Pay buttons and process Apple Pay payments on your website.
* @summary Register Domain
* @param {RegisterApplePayDomainRequest} registerApplePayDomainRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
register(registerApplePayDomainRequest, options) {
return localVarFp.register(registerApplePayDomainRequest, options).then(request => request(axios, basePath));
}
};
};
/**
* ApplePayDomainApi - object-oriented interface
* @export
* @class ApplePayDomainApi
* @extends {BaseAPI}
*/
class ApplePayDomainApi extends BaseAPI {
/**
* Registers a domain with Apple Pay. This endpoint allows you to register your website domain with Apple Pay, which is required before you can accept Apple Pay payments on your website. The domain must be accessible via HTTPS and have a valid SSL certificate. Before registering, you must download this [domain association file](https://assets.monei.com/apple-pay/apple-developer-merchantid-domain-association/) and host it at `/.well-known/apple-developer-merchantid-domain-association` on your site. For example, if you\'re registering `