Skip to content

Commit a7a8302

Browse files
Release 4.6.0
1 parent 898205a commit a7a8302

File tree

171 files changed

+1546
-2166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+1546
-2166
lines changed

.github/workflows/publishing.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
node-version: [18.18.x]
12+
node-version: [20.19.x]
1313
steps:
1414
- uses: actions/checkout@v2
1515
- name: Use Node.js ${{ matrix.node-version }}

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2024 wallee AG
189+
Copyright 2025 wallee AG
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

+49-35
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
# PostFinance Checkout TypeScript Library
22

3-
The PostFinance Checkout TypeScript library wraps around the PostFinance Checkout API. This library facilitates your interaction with various services such as transactions, accounts, and subscriptions.
4-
3+
The PostFinance Checkout TypeScript library wraps around the PostFinance Checkout API. This library facilitates your interaction with various
4+
services such as transactions, accounts, and subscriptions.
55

66
## Documentation
77

88
[PostFinance Checkout Web Service API](https://checkout.postfinance.ch/doc/api/web-service)
99

1010
## Requirements
1111

12-
- npm 6+
12+
- npm 9+
1313

1414
## Installation
15-
>**_NOTE:_** Highly recommended to use TypeScript SDK in server-side applications.<br>
16-
Use front-end frameworks such as Angular at your own risk, as the application might be incompatible or cause a potential threat that the application user information (such as secret keys) might be revealed publicly in the browser.
15+
16+
> **_NOTE:_** Highly recommended to use TypeScript SDK in server-side applications.<br>
17+
> Use front-end frameworks such as Angular at your own risk, as the application might be incompatible or cause a potential
18+
> threat that the application user information (such as secret keys) might be revealed publicly in the browser.
1719
1820
## NPM install (recommended)
21+
1922
```sh
2023
npm install postfinancecheckout
2124
```
2225

2326
## Usage
24-
The library needs to be configured with your account's space id, user id, and secret key which are available in your [PostFinance Checkout
25-
account dashboard](https://checkout.postfinance.ch/account/select). Set `space_id`, `user_id`, and `api_secret` to their values. You can also add custom default headers to the configuration.
27+
28+
The library needs to be configured with your account's space id, user id, and secret key which are available in
29+
your [PostFinance Checkout
30+
account dashboard](https://checkout.postfinance.ch/account/select). Set `space_id`, `user_id`, and `api_secret` to their values.
31+
You can also add custom default headers to the configuration.
2632

2733
### Configuring a Service
2834

@@ -37,7 +43,7 @@ let apiSecret: string = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';
3743
let config = {
3844
space_id: spaceId,
3945
user_id: userId,
40-
api_secret: apiSecret
46+
api_secret: apiSecret,
4147
default_headers: {
4248
'x-meta-header-name-1': 'header-value-1',
4349
'x-meta-header-name-2': 'header-value-2'
@@ -73,22 +79,22 @@ let transactionPaymentPageService: PostFinanceCheckout.api.TransactionPaymentPag
7379

7480
// LineItem of type PRODUCT
7581
let lineItem: PostFinanceCheckout.model.LineItemCreate = new PostFinanceCheckout.model.LineItemCreate();
76-
lineItem.name='Red T-Shirt';
77-
lineItem.uniqueId='5412';
78-
lineItem.sku='red-t-shirt-123';
79-
lineItem.quantity=1;
80-
lineItem.amountIncludingTax=3.50;
81-
lineItem.type=PostFinanceCheckout.model.LineItemType.PRODUCT;
82+
lineItem.name = 'Red T-Shirt';
83+
lineItem.uniqueId = '5412';
84+
lineItem.sku = 'red-t-shirt-123';
85+
lineItem.quantity = 1;
86+
lineItem.amountIncludingTax = 3.50;
87+
lineItem.type = PostFinanceCheckout.model.LineItemType.PRODUCT;
8288

8389
// Transaction
8490
let transaction: PostFinanceCheckout.model.TransactionCreate = new PostFinanceCheckout.model.TransactionCreate();
85-
transaction.lineItems=[lineItem];
86-
transaction.autoConfirmationEnabled=true;
87-
transaction.currency='EUR';
91+
transaction.lineItems = [lineItem];
92+
transaction.autoConfirmationEnabled = true;
93+
transaction.currency = 'EUR';
8894

8995
transactionService.create(spaceId, transaction).then((response) => {
9096
let transactionCreate: PostFinanceCheckout.model.Transaction = response.body;
91-
transactionPaymentPageService.paymentPageUrl(spaceId, <number> transactionCreate.id).then(function (response) {
97+
transactionPaymentPageService.paymentPageUrl(spaceId, <number>transactionCreate.id).then(function (response) {
9298
let pageUrl: string = response.body;
9399
// window.location.href = pageUrl;
94100
});
@@ -97,45 +103,54 @@ transactionService.create(spaceId, transaction).then((response) => {
97103
```
98104

99105
### Configure connection timeout
100-
Connection timeout determines how long the request can take, before cutting off the connection. Same value applies both to inner 'Read timeout' and 'Connection timeout' of a [NPM request module](https://www.npmjs.com/package/request).
101106

102-
Default connection timeout is 25s.
107+
Connection timeout determines how long the request can take, before cutting off the connection. Same value applies both
108+
to inner 'Read timeout' and 'Connection timeout' of a [NPM request module](https://www.npmjs.com/package/request).
103109

110+
Default connection timeout is 25 seconds.
104111

105112
Connection timeout can be set 2 ways:
106113

107-
1. Via configuration property 'timeout' providing value in seconds.
108-
```
114+
1. Via configuration property `timeout` providing value in seconds.
115+
116+
```typescript
109117
let config = {
110-
... other properties ...
118+
// ... other properties ...
111119
timeout: 15
112120
}
113121
let transactionService: PostFinanceCheckout.api.TransactionService = new PostFinanceCheckout.api.TransactionService(config);
114122
```
115123

116-
2. Via service property 'timeout' providing value in seconds
117-
```
124+
2. Via service property `timeout` providing value in seconds
125+
126+
```typescript
118127
let config = {
119-
... properties ...
128+
// ... properties ...
120129
}
121130
let transactionService: PostFinanceCheckout.api.TransactionService = new PostFinanceCheckout.api.TransactionService(config);
122131
transactionService.timeout = 15;
123132
```
124133

125134
### Integrating Webhook Payload Signing Mechanism into webhook callback handler
126135

127-
The HTTP request which is sent for a state change of an entity now includes an additional field `state`, which provides information about the update of the monitored entity's state. This enhancement is a result of the implementation of our webhook encryption mechanism.
136+
The HTTP request which is sent for a state change of an entity now includes an additional field `state`, which provides
137+
information about the update of the monitored entity's state. This enhancement is a result of the implementation of our
138+
webhook encryption mechanism.
128139

129-
Payload field `state` provides direct information about the state update of the entity, making additional API calls to retrieve the entity state redundant.
140+
Payload field `state` provides direct information about the state update of the entity, making additional API calls to
141+
retrieve the entity state redundant.
130142

131143
#### ⚠️ Warning: Generic Pseudocode
132144

133-
> **The provided pseudocode is intentionally generic and serves to illustrate the process of enhancing your API to leverage webhook payload signing. It is not a complete implementation.**
145+
> **The provided pseudocode is intentionally generic and serves to illustrate the process of enhancing your API to
146+
leverage webhook payload signing. It is not a complete implementation.**
134147
>
135-
> Please ensure that you adapt and extend this code to meet the specific needs of your application, including appropriate security measures and error handling.
136-
For a detailed webhook payload signing mechanism understanding we highly recommend referring to our comprehensive
148+
> Please ensure that you adapt and extend this code to meet the specific needs of your application, including
149+
> appropriate security measures and error handling.
150+
> For a detailed webhook payload signing mechanism understanding we highly recommend referring to our comprehensive
137151
[Webhook Payload Signing Documentation](https://checkout.postfinance.ch/doc/webhooks#_webhook_payload_signing_mechanism).
138-
```
152+
153+
```typescript
139154
app.post('/webhook/callback', (req: Request, res: Response) => {
140155
const requestPayload: string = req.body;
141156
const signature: string | undefined = req.headers['x-signature'] as string;
@@ -157,8 +172,7 @@ app.post('/webhook/callback', (req: Request, res: Response) => {
157172
});
158173
```
159174

160-
161-
162175
## License
163176

164-
Please see the [license file](https://github.com/pfpayments/typescript-sdk/blob/master/LICENSE) for more information.
177+
Please see the [license file](https://github.com/pfpayments/typescript-sdk/blob/master/LICENSE) for more
178+
information.

0 commit comments

Comments
 (0)