diff --git a/README.md b/README.md index 19f93b4..d8875c0 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ The full version with all supported options is located [here](https://github.com ```typescript payNL.Transaction.start({ //the amount in euro - amount: 19.95, + amount: 1995, // in cents //we redirect the user back to this url after the payment returnUrl: "https://my-return-url.com/return", @@ -135,7 +135,7 @@ payNL.Transaction.get('123456789X12345e').subscribe( console.log('The transaction is paid'); // refund a part of the transaction result.refund({ - amount: 0.5, + amount: 50, // in cents description: '50 cents refund' }); } @@ -175,7 +175,7 @@ After the transaction has been started, you can use the terminalStatusUrl to get ```typescript // Start transaction and send to the terminal payNL.Transaction.start({ - amount: 0.01, + amount: 1, // in cents paymentMethodId: 1927, //returnUrl and ipAddres are not used for instore payments, but are mandatory returnUrl: "not_applicable", @@ -222,7 +222,7 @@ Only amount, bankaccountHolder and bankaccountNumber are mandatory, the rest of ```typescript payNL.DirectDebit.add({ - amount: 0.01, + amount: 1, // in cents bankaccountHolder: "N Name", bankaccountNumber: "NL00RABO0000012345678", // optional diff --git a/examples/connect/createOrder.ts b/examples/connect/createOrder.ts index 94913c5..7b96877 100644 --- a/examples/connect/createOrder.ts +++ b/examples/connect/createOrder.ts @@ -10,7 +10,7 @@ try { exchangeUrl: 'https://127.0.0.1/exchange', expire: new Date(Date.now() + 60 * 60 * 1000), // 1 hour from now amount: { - value: 1000, + value: 1000, // in cents currency: 'EUR', }, customer: { @@ -59,7 +59,7 @@ try { description: 'Product 1', quantity: 1, price: { - value: 1000, + value: 1000, // in cents currency: 'EUR', }, }, diff --git a/src/connect/order/Customer.ts b/src/connect/order/Customer.ts index 77ccd8e..2f3cd68 100644 --- a/src/connect/order/Customer.ts +++ b/src/connect/order/Customer.ts @@ -12,7 +12,7 @@ export type Customer = { phone?: string | null; language?: string | null; /** Locale code like "en_US" or "nl_BE" */ - locale?: `${Lowercase}_${Uppercase}` | null; + locale?: string | null; ipAddress?: string | null; trust?: number; reference?: string | null; diff --git a/src/connect/order/Product.ts b/src/connect/order/Product.ts index 1e9d44d..5f991c4 100644 --- a/src/connect/order/Product.ts +++ b/src/connect/order/Product.ts @@ -8,7 +8,7 @@ export type CreateProduct = { export type ResponseProduct = { id?: string; description?: string; - /** https://developer.pay.nl/reference/get_product_types */ + /** https://developer.pay.nl/reference/product_type_product_types_get */ type?: string; price: CreateAmount; quantity?: number; diff --git a/src/connect/service/ServiceConfig.ts b/src/connect/service/ServiceConfig.ts index 9bfc6e3..740f859 100644 --- a/src/connect/service/ServiceConfig.ts +++ b/src/connect/service/ServiceConfig.ts @@ -1,5 +1,5 @@ export type ServiceConfig = { - mcc: number; + mcc: number | null; code: string; name: string; _links: { @@ -7,7 +7,16 @@ export type ServiceConfig = { href: string; type: string; }[]; - layout: null; + layout: { + code: string; + name: string; + cssUrl: string; + icon: string; + supportingColor: string; + headerTextColor: string; + buttonColor: string; + buttonTextColor: string; + } | null; secret: string; status: string; address: { @@ -33,21 +42,20 @@ export type ServiceConfig = { name: string; status: string; }; + publication?: { + domainUrl: string; + } | null; testMode: boolean; createdAt: string; createdBy: string; - deletedAt: null; - deletedBy: null; - tradeName: null; + deletedAt: string | null; + deletedBy: string | null; + tradeName: { code: string; name: string } | null; modifiedAt: string; modifiedBy: string; contactEmail: string; contactPhone: string; - translations: { - name: { - nl_NL: string; - }; - }; + translations: Translations<'name'>; checkoutTexts: never[]; turnoverGroup: { code: string; @@ -64,12 +72,7 @@ export type ServiceConfig = { tag: string; name: string; image: string; - translations: { - name: { - nl_NL?: string; - en_GB?: string; - }; - }; + translations: Translations<'name'>; paymentMethods: { id: number; name: string; @@ -79,21 +82,14 @@ export type ServiceConfig = { name: string; image: string; }[]; - settings: null; + settings: { key: string; value: string }[] | null; maxAmount: number; minAmount: number; description: string; - translations: { - name: { - [key: string]: string; - }; - description: { - [key: string]: string; - }; - }; + translations: Translations<'name' | 'description'>; targetCountries: string[]; }[]; - requiredFields: null; + requiredFields: { fieldName: string; mandatory: 'required' }[] | null; }[]; checkoutSequence: { default: { @@ -102,3 +98,10 @@ export type ServiceConfig = { }; }; }; + +export type Translations = Record> | null; + +/** + * @example nl_NL or en_GB + */ +export type LanguageCode = string; diff --git a/tests/connect/support/fakeConfig.ts b/tests/connect/support/fakeConfig.ts index 5a552b0..7f6ed95 100644 --- a/tests/connect/support/fakeConfig.ts +++ b/tests/connect/support/fakeConfig.ts @@ -1,4 +1,6 @@ -export const fakeConfig = { +import { ServiceConfig } from '../../../src'; + +export const fakeConfig: ServiceConfig = { code: 'SL-1234-5678', secret: ':secret:', testMode: false,