diff --git a/package.json b/package.json index ad562f7b..2494451b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@internxt/sdk", "author": "Internxt ", - "version": "1.10.12", + "version": "1.10.13", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git", diff --git a/src/payments/checkout.ts b/src/payments/checkout.ts index deae14af..a4b049a6 100644 --- a/src/payments/checkout.ts +++ b/src/payments/checkout.ts @@ -172,7 +172,7 @@ export class Checkout { { token, }, - this.headers(), + this.authHeaders(), ); } diff --git a/src/payments/types/index.ts b/src/payments/types/index.ts index 5292b08a..b0d28903 100644 --- a/src/payments/types/index.ts +++ b/src/payments/types/index.ts @@ -45,7 +45,7 @@ export type Price = { currency: string; amount: number; bytes: number; - interval: 'lifetime' | 'year'; + interval: 'month' | 'year' | 'lifetime'; decimalAmount: number; type: UserType; product: string; diff --git a/test/payments/checkout.test.ts b/test/payments/checkout.test.ts index d5869de2..3a9cf953 100644 --- a/test/payments/checkout.test.ts +++ b/test/payments/checkout.test.ts @@ -2,7 +2,7 @@ import sinon from 'sinon'; import { HttpClient } from '../../src/shared/http/client'; import { Checkout } from '../../src/payments'; import { ApiSecurity, AppDetails } from '../../src/shared'; -import { basicHeaders } from '../../src/shared/headers'; +import { basicHeaders, headersWithToken } from '../../src/shared/headers'; import { CryptoCurrency } from '../../src/payments/types'; const httpClient = HttpClient.create(''); @@ -52,7 +52,7 @@ describe('Checkout service tests', () => { const mockedInvoiceId = 'encoded-invoice-id'; const callStub = sinon.stub(httpClient, 'post').resolves(true); - const { client, headers } = clientAndHeadersWithToken({}); + const { client, headers } = clientAndHeadersWithAuthToken({}); // Act const body = await client.verifyCryptoPayment(mockedInvoiceId); @@ -98,3 +98,38 @@ function clientAndHeadersWithToken({ const headers = basicHeaders(clientName, clientVersion); return { client, headers }; } + +function clientAndHeadersWithAuthToken({ + apiUrl = '', + clientName = 'c-name', + clientVersion = '0.1', + token = 'token', + desktopHeader, +}: { + apiUrl?: string; + clientName?: string; + clientVersion?: string; + token?: string; + desktopHeader?: string; +}): { + client: Checkout; + headers: object; +} { + const additionalHeaders: Record = {}; + const appDetails: AppDetails = { + clientName: clientName, + clientVersion: clientVersion, + desktopHeader: desktopHeader, + }; + const apiSecurity: ApiSecurity = { + token: token, + }; + + if (desktopHeader) { + additionalHeaders['x-internxt-desktop-header'] = desktopHeader; + } + + const client = Checkout.client(apiUrl, appDetails, apiSecurity); + const headers = headersWithToken(clientName, clientVersion, token, undefined, additionalHeaders); + return { client, headers }; +}