Payments

Endpoints

post
/payments
Create a Payment
1
import axios from 'axios'
2
3
const HIDIRECT_BASE_URL = "<HIDIRECT_BASE_URL>"
4
const API_KEY = "<YOUR_API_KEY>"
5
6
axios.post(
7
`${HIDIRECT_BASE_URL}/payments`,
8
{
9
"amount": {
10
"total": 10,
11
"currency": "EUR"
12
},
13
"merchantUrls": {
14
"callback": "https://api.exampleshop.com/callback",
15
"successRedirect": "https://exampleshop.com/success",
16
"failureRedirect": "https://exampleshop.com/failure",
17
"cancelRedirect": "https://exampleshop.com/cancel"
18
}
19
},
20
{
21
headers: {
22
"x-api-key": API_KEY,
23
"Content-Type": "application/json"
24
}
25
})
26
.then((response) => {
27
console.log(JSON.stringify(response.data));
28
})
29
.catch((error) => {
30
console.log(error);
31
});
32
Copied!
get
/payments/<id>
Fetch a Payment
1
import axios from 'axios'
2
3
const HIDIRECT_BASE_URL = "<HIDIRECT_BASE_URL>"
4
const API_KEY = "<YOUR_API_KEY>"
5
const invoice_id = "<INVOICE_ID>"
6
7
axios.get(
8
`${HIDIRECT_BASE_URL}/payments/${invoice_id}`,
9
{
10
headers: {
11
"x-api-key": API_KEY,
12
}
13
})
14
.then((response) => {
15
console.log(JSON.stringify(response.data));
16
})
17
.catch((error) => {
18
console.log(error);
19
});
20
Copied!
post
/payments/<id>/capture
Capture a Payment
post
/payments/<id>/cancel
Cancel a Payment
post
/payments/<id>/document/<type>
Upload Document
1
import axios from 'axios'
2
3
const HIDIRECT_BASE_URL = "<HIDIRECT_BASE_URL>"
4
const file = fs.readFileSync('/path/to/file');
5
const API_KEY = "<YOUR_API_KEY>"
6
7
axios.post(
8
`${HIDIRECT_BASE_URL}/payments/<id>/invoice`,
9
data: file,
10
{
11
headers: {
12
"x-api-key": API_KEY,
13
"Content-Type": "application/pdf"
14
}
15
})
16
.then((response) => {
17
console.log(JSON.stringify(response.data));
18
})
19
.catch((error) => {
20
console.log(error);
21
});
22
Copied!

Entity Definitions

A payment represents the users intent to pay for a purchase. A payment can be used to initialise the Checkout flow, therefore allowing a hi.health user to confirm a transaction. Once a payment is confirmed, it will require an invoice to be uploaded for fully processing the reimbursement claim with the users insurance.

Payment

Property Name
Property Type
Description
id
string
Primary key, automatically assigned when the payment is created
amount
Amount
Contains total payment amount with a breakdown that provides details.
merchantReference
string
Identifier from another system, e.g. used to reference the order in your database.
merchantUrls
MerchantUrls
Contains URLs to send callbacks and redirect the user.
status
INITIAL | CLAIMED | SETTLED|DENIED | PENDING
Describes the current status of the payment. INITIAL: The payment was created.
CLAIMED: The payment was claimed by a user logging into the checkout flow.
SETTLED: The payment was fulfilled by hi.health
DENIED: The payment was denied by hi.health PENDING : The payment is still being processed

MerchantUrls

Property name
Property type
Description
callback (optional)
string
This webhook will be used to keep your backend up to date with status updates (payment claimed, payment cancelled, ...).
successRedirect
string
The user will be redirected to this URL once the payment was successfully confirmed.
failureRedirect
string
The user will be redirected to this URL in case the payment was failed. (Note: This redirect is currently not used by our frontend)
cancelRedirect
string
The user will be redirected to this URL in case the payment was cancelled.

Amount

Property name
Property type
Description
total
number
The amount the user will be charged.
Must be a positive integer or a positive float with up to 2 decimal places.
currency
string
The 3 character currency code that identifies the currency.
We support only "EUR" or "eur" at the moment.