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AAiB,EACtB,KAAK,SAAW,CACpB,EAGJ,IAAY,SAXZ,QAAA,0BAWA,SAAY,GACR,IAAA,+CACA,IAAA,yDACA,IAAA,6DACA,IAAA,yDACA,IAAA,2EACA,IAAA,yDACA,IAAA,iEACA,IAAA,iDACA,IAAA,iEACA,IAAA,+DACA,IAAA,6DACA,IAAA,iDACA,IAAA,6CACA,IAAA,6DACA,IAAA,+DACA,IAAA,+DACA,IAAA,2EACA,IAAA,qCACA,IAAA,qDACA,IAAA,iDACA,IAAA,uFACA,IAAA,2DACA,IAAA,uEACA,IAAA,iGACA,IAAA,2EACA,IAAA,2CACA,IAAA,yCACA,IAAA,+EACA,IAAA,iEACA,IAAA,2GACA,IAAA,+CACA,IAAA,mEACA,IAAA,uCACA,IAAA,2DACA,IAAA,+EACA,IAAA,mGACA,IAAA,+EACA,IAAA,mEACA,IAAA,6DACA,IAAA,6DACA,IAAA,iDACA,IAAA,yCACA,IAAA,gEACH,CA5CD,CAAY,WAAQ,QAAA,SAAR,SAAQ","file":"/npm/app-store-server-library@0.1.3/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/app-store-server-library@0.1.3/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// Copyright (c) 2023 Apple Inc. Licensed under MIT License.\n\nimport fetch from 'node-fetch';\nimport { CheckTestNotificationResponse, CheckTestNotificationResponseValidator } from './models/CheckTestNotificationResponse';\nimport { ConsumptionRequest } from './models/ConsumptionRequest';\nimport { Environment } from './models/Environment';\nimport { ExtendRenewalDateRequest } from './models/ExtendRenewalDateRequest';\nimport { ExtendRenewalDateResponse, ExtendRenewalDateResponseValidator } from './models/ExtendRenewalDateResponse';\nimport { HistoryResponse, HistoryResponseValidator } from './models/HistoryResponse';\nimport { MassExtendRenewalDateRequest } from './models/MassExtendRenewalDateRequest';\nimport { MassExtendRenewalDateResponse, MassExtendRenewalDateResponseValidator } from './models/MassExtendRenewalDateResponse';\nimport { MassExtendRenewalDateStatusResponse, MassExtendRenewalDateStatusResponseValidator } from './models/MassExtendRenewalDateStatusResponse';\nimport { OrderLookupResponse, OrderLookupResponseValidator } from './models/OrderLookupResponse';\nimport { RefundHistoryResponse, RefundHistoryResponseValidator } from './models/RefundHistoryResponse';\nimport { SendTestNotificationResponse, SendTestNotificationResponseValidator } from './models/SendTestNotificationResponse';\nimport { StatusResponse, StatusResponseValidator } from './models/StatusResponse';\nimport { TransactionHistoryRequest } from './models/TransactionHistoryRequest';\nimport { TransactionInfoResponse, TransactionInfoResponseValidator } from './models/TransactionInfoResponse';\nimport { Validator } from './models/Validator';\nimport { Status } from './models/Status';\nexport { SignedDataVerifier as SignedJWTVerifier } from './jwt_verification'\nexport { ReceiptUtility } from './receipt_utility'\nexport { AccountTenure } from \"./models/AccountTenure\"\nexport { AutoRenewStatus } from './models/AutoRenewStatus'\nexport { CheckTestNotificationResponse } from './models/CheckTestNotificationResponse'\nexport { ConsumptionRequest } from './models/ConsumptionRequest'\nexport { ConsumptionStatus } from './models/ConsumptionStatus'\nexport { Data } from './models/Data'\nexport { DeliveryStatus } from './models/DeliveryStatus'\nexport { Environment } from './models/Environment'\nexport { ExpirationIntent } from './models/ExpirationIntent'\nexport { ExtendReasonCode } from './models/ExtendReasonCode'\nexport { ExtendRenewalDateRequest } from './models/ExtendRenewalDateRequest'\nexport { ExtendRenewalDateResponse } from './models/ExtendRenewalDateResponse'\nexport { SendAttemptResult } from './models/SendAttemptResult'\nexport { SendAttemptItem } from './models/SendAttemptItem'\nexport { HistoryResponse } from './models/HistoryResponse'\nexport { InAppOwnershipType } from './models/InAppOwnershipType'\nexport { JWSRenewalInfoDecodedPayload } from './models/JWSRenewalInfoDecodedPayload'\nexport { JWSTransactionDecodedPayload } from './models/JWSTransactionDecodedPayload'\nexport { LastTransactionsItem } from './models/LastTransactionsItem'\nexport { LifetimeDollarsPurchased } from './models/LifetimeDollarsPurchased'\nexport { LifetimeDollarsRefunded } from './models/LifetimeDollarsRefunded'\nexport { MassExtendRenewalDateRequest } from './models/MassExtendRenewalDateRequest'\nexport { MassExtendRenewalDateResponse } from './models/MassExtendRenewalDateResponse'\nexport { MassExtendRenewalDateStatusResponse } from './models/MassExtendRenewalDateStatusResponse'\nexport { NotificationHistoryRequest } from './models/NotificationHistoryRequest'\nexport { NotificationHistoryResponse } from './models/NotificationHistoryResponse'\nexport { NotificationHistoryResponseItem } from './models/NotificationHistoryResponseItem'\nexport { NotificationTypeV2 } from './models/NotificationTypeV2'\nexport { OfferType } from './models/OfferType'\nexport { OrderLookupResponse } from './models/OrderLookupResponse'\nexport { OrderLookupStatus } from './models/OrderLookupStatus'\nexport { Platform } from './models/Platform'\nexport { PlayTime } from './models/PlayTime'\nexport { PriceIncreaseStatus } from './models/PriceIncreaseStatus'\nexport { RefundHistoryResponse } from './models/RefundHistoryResponse'\nexport { ResponseBodyV2 } from './models/ResponseBodyV2'\nexport { ResponseBodyV2DecodedPayload } from './models/ResponseBodyV2DecodedPayload'\nexport { RevocationReason } from './models/RevocationReason'\nexport { SendTestNotificationResponse } from './models/SendTestNotificationResponse'\nexport { Status } from './models/Status'\nexport { StatusResponse } from './models/StatusResponse'\nexport { SubscriptionGroupIdentifierItem } from './models/SubscriptionGroupIdentifierItem'\nexport { Subtype } from './models/Subtype'\nexport { Summary } from './models/Summary'\nexport { TransactionHistoryRequest, Order, ProductType } from './models/TransactionHistoryRequest'\nexport { TransactionInfoResponse } from './models/TransactionInfoResponse'\nexport { TransactionReason } from './models/TransactionReason'\nexport { Type } from './models/Type'\nexport { UserStatus } from './models/UserStatus'\nexport { PromotionalOfferSignatureCreator } from './promotional_offer'\nexport { DecodedSignedData } from './models/DecodedSignedData'\nexport { AppTransaction } from './models/AppTransaction'\n\nimport jsonwebtoken = require('jsonwebtoken');\nimport { NotificationHistoryRequest } from './models/NotificationHistoryRequest';\nimport { NotificationHistoryResponse, NotificationHistoryResponseValidator } from './models/NotificationHistoryResponse';\n\nexport class AppStoreServerAPIClient {\n    private static PRODUCTION_URL = \"https://api.storekit.itunes.apple.com\";\n    private static SANDBOX_URL = \"https://api.storekit-sandbox.itunes.apple.com\";\n    private static USER_AGENT = \"app-store-server-library/node/0.1\";\n\n    private issueId: string\n    private keyId: string\n    private signingKey: string\n    private bundleId: string\n    private urlBase: string\n\n    /**\n     * Create an App Store Server API client\n     * @param signingKey Your private key downloaded from App Store Connect\n     * @param keyId Your private key ID from App Store Connect\n     * @param issuerId Your issuer ID from the Keys page in App Store Connect\n     * @param bundleId Your app’s bundle ID\n     * @param environment The environment to target\n     */\n    public constructor(signingKey: string, keyId: string, issuerId: string, bundleId: string, environment: Environment) {\n        this.issueId = issuerId\n        this.keyId = keyId\n        this.bundleId = bundleId\n        this.signingKey = signingKey\n        this.urlBase = environment === \"Sandbox\" ? AppStoreServerAPIClient.SANDBOX_URL : AppStoreServerAPIClient.PRODUCTION_URL\n    }\n\n    protected async makeRequest<T>(path: string, method: string, queryParameters: { [key: string]: [string]}, body: object | null, validator: Validator<T> | null): Promise<T> {\n        const headers: { [key: string]: string } = {\n            'User-Agent': AppStoreServerAPIClient.USER_AGENT,\n            'Authorization': 'Bearer ' + this.createBearerToken(),\n            'Accept': 'application/json',\n        }\n        const parsedQueryParameters = new URLSearchParams(queryParameters)\n        let stringBody = undefined\n        if (body != null) {\n            stringBody = JSON.stringify(body)\n            headers['Content-Type'] = 'application/json'\n        }\n\n        const response = await fetch(this.urlBase + path + '?' + parsedQueryParameters, {\n            method: method,\n            body: stringBody,\n            headers: headers\n        })\n\n        if(response.ok) {\n            // Success\n            if (validator == null) {\n                return null as T\n            }\n\n            const responseBody = await response.json()\n\n            if (!validator.validate(responseBody)) {\n                throw new Error(\"Unexpected response body format\")\n            }\n\n            return responseBody\n        }\n\n        try {\n            const responseBody = await response.json()\n            const errorCode = responseBody['errorCode']\n\n            if (Object.values(APIError).includes(errorCode)) {\n                throw new APIException(response.status, errorCode as APIError)\n            }\n\n            throw new APIException(response.status)\n        } catch (e) {\n            if (e instanceof APIException) {\n                throw e\n            }\n\n            throw new APIException(response.status)\n        }\n    }\n\n    /**\n     * Uses a subscription’s product identifier to extend the renewal date for all of its eligible active subscribers.\n     *\n     * @param massExtendRenewalDateRequest The request body for extending a subscription renewal date for all of its active subscribers.\n     * @return A response that indicates the server successfully received the subscription-renewal-date extension request.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/extend_subscription_renewal_dates_for_all_active_subscribers Extend Subscription Renewal Dates for All Active Subscribers}\n     */\n    public async extendRenewalDateForAllActiveSubscribers(massExtendRenewalDateRequest: MassExtendRenewalDateRequest): Promise<MassExtendRenewalDateResponse> {\n        return await this.makeRequest(\"/inApps/v1/subscriptions/extend/mass/\", \"POST\", {}, massExtendRenewalDateRequest, new MassExtendRenewalDateResponseValidator());\n    }\n\n    /**\n     * Extends the renewal date of a customer’s active subscription using the original transaction identifier.\n     *\n     * @param originalTransactionId    The original transaction identifier of the subscription receiving a renewal date extension.\n     * @param extendRenewalDateRequest The request body containing subscription-renewal-extension data.\n     * @return A response that indicates whether an individual renewal-date extension succeeded, and related details.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/extend_a_subscription_renewal_date Extend a Subscription Renewal Date}\n     */\n    public async extendSubscriptionRenewalDate(originalTransactionId: string, extendRenewalDateRequest: ExtendRenewalDateRequest): Promise<ExtendRenewalDateResponse> {\n        return await this.makeRequest<ExtendRenewalDateResponse>(\"/inApps/v1/subscriptions/extend/\" + originalTransactionId, \"PUT\", {}, extendRenewalDateRequest, new ExtendRenewalDateResponseValidator());\n    }\n\n    /**\n     * Get the statuses for all of a customer’s auto-renewable subscriptions in your app.\n     *\n     * @param transactionId The identifier of a transaction that belongs to the customer, and which may be an original transaction identifier.\n     * @param status An optional filter that indicates the status of subscriptions to include in the response. Your query may specify more than one status query parameter.\n     * @return A response that contains status information for all of a customer’s auto-renewable subscriptions in your app.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses Get All Subscription Statuses}\n     */\n    public async getAllSubscriptionStatuses(transactionId: string, status: [Status] | undefined = undefined): Promise<StatusResponse> {\n        const queryParameters: { [key: string]: [string]} = {}\n        if (status != null) {\n            queryParameters[\"status\"] = status.map(s => s.toString()) as [string];\n        }\n\n        return await this.makeRequest(\"/inApps/v1/subscriptions/\" + transactionId, \"GET\", queryParameters, null, new StatusResponseValidator());\n    }\n\n    /**\n     * Get a paginated list of all of a customer’s refunded in-app purchases for your app.\n     *\n     * @param transactionId The identifier of a transaction that belongs to the customer, and which may be an original transaction identifier.\n     * @param revision              A token you provide to get the next set of up to 20 transactions. All responses include a revision token. Use the revision token from the previous RefundHistoryResponse.\n     * @return A response that contains status information for all of a customer’s auto-renewable subscriptions in your app.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/get_refund_history Get Refund History}\n     */\n    public async getRefundHistory(transactionId: string, revision: string | null): Promise<RefundHistoryResponse> {\n        const queryParameters: { [key: string]: [string]} = {}\n        if (revision !== null) {\n            queryParameters[\"revision\"] = [revision];\n        }\n\n        return await this.makeRequest(\"/inApps/v2/refund/lookup/\" + transactionId, \"GET\", queryParameters, null, new RefundHistoryResponseValidator());\n    }\n\n    /**\n     * Checks whether a renewal date extension request completed, and provides the final count of successful or failed extensions.\n     *\n     * @param requestIdentifier The UUID that represents your request to the Extend Subscription Renewal Dates for All Active Subscribers endpoint.\n     * @param productId         The product identifier of the auto-renewable subscription that you request a renewal-date extension for.\n     * @return A response that indicates the current status of a request to extend the subscription renewal date to all eligible subscribers.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/get_status_of_subscription_renewal_date_extensions Get Status of Subscription Renewal Date Extensions}\n     */\n    public async getStatusOfSubscriptionRenewalDateExtensions(requestIdentifier: string, productId: string): Promise<MassExtendRenewalDateStatusResponse> {\n        return await this.makeRequest(\"/inApps/v1/subscriptions/extend/mass/\" + productId + \"/\" + requestIdentifier, \"GET\", {}, null, new MassExtendRenewalDateStatusResponseValidator());\n    }\n\n    /**\n     * Check the status of the test App Store server notification sent to your server.\n     *\n     * @param testNotificationToken The test notification token received from the Request a Test Notification endpoint\n     * @return A response that contains the contents of the test notification sent by the App Store server and the result from your server.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/get_test_notification_status Get Test Notification Status}\n     */\n    public async getTestNotificationStatus(testNotificationToken: string): Promise<CheckTestNotificationResponse> {\n        return await this.makeRequest(\"/inApps/v1/notifications/test/\" + testNotificationToken, \"GET\", {}, null, new CheckTestNotificationResponseValidator());\n    }\n\n    /**\n     * Get a list of notifications that the App Store server attempted to send to your server.\n     *\n     * @param paginationToken An optional token you use to get the next set of up to 20 notification history records. All responses that have more records available include a paginationToken. Omit this parameter the first time you call this endpoint.\n     * @param notificationHistoryRequest The request body that includes the start and end dates, and optional query constraints.\n     * @return A response that contains the App Store Server Notifications history for your app.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/get_notification_histor Get Notification History}\n     */\n    public async getNotificationHistory(paginationToken: string | null, notificationHistoryRequest: NotificationHistoryRequest): Promise<NotificationHistoryResponse> {\n        const queryParameters: { [key: string]: [string]} = {}\n        if (paginationToken != null) {\n            queryParameters[\"paginationToken\"] = [paginationToken];\n        }\n        return await this.makeRequest(\"/inApps/v1/notifications/history\", \"POST\", queryParameters, notificationHistoryRequest, new NotificationHistoryResponseValidator());\n    }\n\n    /**\n     * Get a customer’s in-app purchase transaction history for your app.\n     *\n     * @param transactionId The identifier of a transaction that belongs to the customer, and which may be an original transaction identifier.\n     * @param revision              A token you provide to get the next set of up to 20 transactions. All responses include a revision token. Note: For requests that use the revision token, include the same query parameters from the initial request. Use the revision token from the previous HistoryResponse.\n     * @return A response that contains the customer’s transaction history for an app.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/get_transaction_history Get Transaction History}\n     */\n    public async getTransactionHistory(transactionId: string, revision: string | null, transactionHistoryRequest: TransactionHistoryRequest): Promise<HistoryResponse> {\n        const queryParameters: { [key: string]: [string]} = {}\n        if (revision != null) {\n            queryParameters[\"revision\"] = [revision];\n        }\n        if (transactionHistoryRequest.startDate) {\n            queryParameters[\"startDate\"] = [transactionHistoryRequest.startDate.toString()];\n        }\n        if (transactionHistoryRequest.endDate) {\n            queryParameters[\"endDate\"] = [transactionHistoryRequest.endDate.toString()];\n        }\n        if (transactionHistoryRequest.productIds) {\n            queryParameters[\"productId\"] = transactionHistoryRequest.productIds;\n        }\n        if (transactionHistoryRequest.productTypes) {\n            queryParameters[\"productType\"] = transactionHistoryRequest.productTypes;\n        }\n        if (transactionHistoryRequest.sort) {\n            queryParameters[\"sort\"] = [transactionHistoryRequest.sort];\n        }\n        if (transactionHistoryRequest.subscriptionGroupIdentifiers) {\n            queryParameters[\"subscriptionGroupIdentifier\"] = transactionHistoryRequest.subscriptionGroupIdentifiers;\n        }\n        if (transactionHistoryRequest.inAppOwnershipType) {\n            queryParameters[\"inAppOwnershipType\"] = [transactionHistoryRequest.inAppOwnershipType];\n        }\n        if (transactionHistoryRequest.revoked) {\n            queryParameters[\"revoked\"] = [transactionHistoryRequest.revoked.toString()];\n        }\n        return await this.makeRequest(\"/inApps/v1/history/\" + transactionId, \"GET\", queryParameters, null, new HistoryResponseValidator());\n    }\n\n    /**\n     * Get information about a single transaction for your app.\n     *\n     * @param transactionId The identifier of a transaction that belongs to the customer, and which may be an original transaction identifier.\n     * @return A response that contains signed transaction information for a single transaction.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/get_transaction_info Get Transaction Info}\n     */\n    public async getTransactionInfo(transactionId: string): Promise<TransactionInfoResponse> {\n        return await this.makeRequest(\"/inApps/v1/transactions/\" + transactionId, \"GET\", {}, null, new TransactionInfoResponseValidator());\n    }\n\n    /**\n     * Get a customer’s in-app purchases from a receipt using the order ID.\n     *\n     * @param orderId The order ID for in-app purchases that belong to the customer.\n     * @return A response that includes the order lookup status and an array of signed transactions for the in-app purchases in the order.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/look_up_order_id Look Up Order ID}\n     */\n    public async lookUpOrderId(orderId: string): Promise<OrderLookupResponse> {\n        return await this.makeRequest(\"/inApps/v1/lookup/\" + orderId, \"GET\", {}, null, new OrderLookupResponseValidator());\n    }\n\n    /**\n     * Ask App Store Server Notifications to send a test notification to your server.\n     *\n     * @return A response that contains the test notification token.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/request_a_test_notification Request a Test Notification}\n     */\n    public async requestTestNotification(): Promise<SendTestNotificationResponse> {\n        return await this.makeRequest(\"/inApps/v1/notifications/test\", \"POST\", {}, null, new SendTestNotificationResponseValidator());\n    }\n\n    /**\n     * Send consumption information about a consumable in-app purchase to the App Store after your server receives a consumption request notification.\n     *\n     * @param transactionId The transaction identifier for which you’re providing consumption information. You receive this identifier in the CONSUMPTION_REQUEST notification the App Store sends to your server.\n     * @param consumptionRequest    The request body containing consumption information.\n     * @throws APIException If a response was returned indicating the request could not be processed\n     * {@link https://developer.apple.com/documentation/appstoreserverapi/send_consumption_information Send Consumption Information}\n     */\n    public async sendConsumptionData(transactionId: string, consumptionRequest: ConsumptionRequest): Promise<void> {\n        await this.makeRequest(\"/inApps/v1/transactions/consumption/\" + transactionId, \"PUT\", {}, consumptionRequest, null);\n    }\n\n    private createBearerToken(): string {\n        const payload = {\n            bid: this.bundleId\n        }\n        return jsonwebtoken.sign(payload, this.signingKey, { algorithm: 'ES256', keyid: this.keyId, issuer: this.issueId, audience: 'appstoreconnect-v1', expiresIn: '5m'});\n    }\n}\n\n\nexport class APIException extends Error {\n    public httpStatusCode: number\n    public apiError: APIError | null\n\n    constructor(httpStatusCode: number, apiError: APIError | null = null) {\n        super()\n        this.httpStatusCode = httpStatusCode\n        this.apiError = apiError\n    }\n}\n\nexport enum APIError {\n    GENERAL_BAD_REQUEST = 4000000,\n    INVALID_APP_IDENTIFIER = 4000002,\n    INVALID_REQUEST_REVISION = 4000005,\n    INVALID_TRANSACTION_ID = 4000006,\n    INVALID_ORIGINAL_TRANSACTION_ID = 4000008,\n    INVALID_EXTEND_BY_DAYS = 4000009,\n    INVALID_EXTEND_REASON_CODE = 4000010,\n    INVALID_IDENTIFIER = 4000011,\n    START_DATE_TOO_FAR_IN_PAST = 4000012,\n    START_DATE_AFTER_END_DATE = 4000013,\n    INVALID_PAGINATION_TOKEN = 4000014,\n    INVALID_START_DATE = 4000015,\n    INVALID_END_DATE = 4000016,\n    PAGINATION_TOKEN_EXPIRED = 4000017,\n    INVALID_NOTIFICATION_TYPE = 4000018,\n    MULTIPLE_FILTERS_SUPPLIED = 4000019,\n    INVALID_TEST_NOTIFICATION_TOKEN = 4000020,\n    INVALID_SORT = 4000021,\n    INVALID_PRODUCT_TYPE = 4000022,\n    INVALID_PRODUCT_ID = 4000023,\n    INVALID_SUBSCRIPTION_GROUP_IDENTIFIER = 4000024,\n    INVALID_EXCLUDE_REVOKED = 4000025,\n    INVALID_IN_APP_OWNERSHIP_TYPE = 4000026,\n    INVALID_EMPTY_STOREFRONT_COUNTRY_CODE_LIST = 4000027,\n    INVALID_STOREFRONT_COUNTRY_CODE = 4000028,\n    INVALID_REVOKED = 4000030,\n    INVALID_STATUS = 4000031,\n    SUBSCRIPTION_EXTENSION_INELIGIBLE = 4030004,\n    SUBSCRIPTION_MAX_EXTENSION = 4030005,\n    FAMILY_SHARED_SUBSCRIPTION_EXTENSION_INELIGIBLE = 4030007,\n    ACCOUNT_NOT_FOUND = 4040001,\n    ACCOUNT_NOT_FOUND_RETRYABLE = 4040002,\n    APP_NOT_FOUND = 4040003,\n    APP_NOT_FOUND_RETRYABLE = 4040004,\n    ORIGINAL_TRANSACTION_ID_NOT_FOUND = 4040005,\n    ORIGINAL_TRANSACTION_ID_NOT_FOUND_RETRYABLE = 4040006,\n    SERVER_NOTIFICATION_URL_NOT_FOUND = 4040007,\n    TEST_NOTIFICATION_NOT_FOUND = 4040008,\n    STATUS_REQUEST_NOT_FOUND = 4040009,\n    TRANSACTION_ID_NOT_FOUND = 4040010,\n    RATE_LIMIT_EXCEEDED = 4290000,\n    GENERAL_INTERNAL = 5000000,\n    GENERAL_INTERNAL_RETRYABLE = 5000001,\n}"]}