Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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'
});
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/connect/createOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -59,7 +59,7 @@ try {
description: 'Product 1',
quantity: 1,
price: {
value: 1000,
value: 1000, // in cents
currency: 'EUR',
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/connect/order/Customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type Customer = {
phone?: string | null;
language?: string | null;
/** Locale code like "en_US" or "nl_BE" */
locale?: `${Lowercase<string>}_${Uppercase<string>}` | null;
locale?: string | null;
ipAddress?: string | null;
trust?: number;
reference?: string | null;
Expand Down
2 changes: 1 addition & 1 deletion src/connect/order/Product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
55 changes: 29 additions & 26 deletions src/connect/service/ServiceConfig.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
export type ServiceConfig = {
mcc: number;
mcc: number | null;
code: string;
name: string;
_links: {
rel: string;
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: {
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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: {
Expand All @@ -102,3 +98,10 @@ export type ServiceConfig = {
};
};
};

export type Translations<T extends string> = Record<T, Record<LanguageCode, string>> | null;

/**
* @example nl_NL or en_GB
*/
export type LanguageCode = string;
4 changes: 3 additions & 1 deletion tests/connect/support/fakeConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const fakeConfig = {
import { ServiceConfig } from '../../../src';

export const fakeConfig: ServiceConfig = {
code: 'SL-1234-5678',
secret: ':secret:',
testMode: false,
Expand Down