You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-35
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,34 @@
1
1
# PostFinance Checkout TypeScript Library
2
2
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.
5
5
6
6
## Documentation
7
7
8
8
[PostFinance Checkout Web Service API](https://checkout.postfinance.ch/doc/api/web-service)
9
9
10
10
## Requirements
11
11
12
-
- npm 6+
12
+
- npm 9+
13
13
14
14
## 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.
17
19
18
20
## NPM install (recommended)
21
+
19
22
```sh
20
23
npm install postfinancecheckout
21
24
```
22
25
23
26
## 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.
26
32
27
33
### Configuring a Service
28
34
@@ -37,7 +43,7 @@ let apiSecret: string = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';
37
43
let config = {
38
44
space_id: spaceId,
39
45
user_id: userId,
40
-
api_secret: apiSecret
46
+
api_secret: apiSecret,
41
47
default_headers: {
42
48
'x-meta-header-name-1': 'header-value-1',
43
49
'x-meta-header-name-2': 'header-value-2'
@@ -73,22 +79,22 @@ let transactionPaymentPageService: PostFinanceCheckout.api.TransactionPaymentPag
73
79
74
80
// LineItem of type PRODUCT
75
81
let lineItem:PostFinanceCheckout.model.LineItemCreate=newPostFinanceCheckout.model.LineItemCreate();
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).
101
106
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).
103
109
110
+
Default connection timeout is 25 seconds.
104
111
105
112
Connection timeout can be set 2 ways:
106
113
107
-
1. Via configuration property 'timeout' providing value in seconds.
108
-
```
114
+
1. Via configuration property `timeout` providing value in seconds.
115
+
116
+
```typescript
109
117
let config = {
110
-
... other properties ...
118
+
//... other properties ...
111
119
timeout: 15
112
120
}
113
121
let transactionService:PostFinanceCheckout.api.TransactionService=newPostFinanceCheckout.api.TransactionService(config);
114
122
```
115
123
116
-
2. Via service property 'timeout' providing value in seconds
117
-
```
124
+
2. Via service property `timeout` providing value in seconds
125
+
126
+
```typescript
118
127
let config = {
119
-
... properties ...
128
+
//... properties ...
120
129
}
121
130
let transactionService:PostFinanceCheckout.api.TransactionService=newPostFinanceCheckout.api.TransactionService(config);
122
131
transactionService.timeout=15;
123
132
```
124
133
125
134
### Integrating Webhook Payload Signing Mechanism into webhook callback handler
126
135
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.
128
139
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.
130
142
131
143
#### ⚠️ Warning: Generic Pseudocode
132
144
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.**
134
147
>
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
0 commit comments