Comment on page

Payments

Endpoints

post
/payments
Create a Payment
import axios from 'axios'
const HIDIRECT_BASE_URL = "<HIDIRECT_BASE_URL>"
const API_KEY = "<YOUR_API_KEY>"
axios.post(
`${HIDIRECT_BASE_URL}/payments`,
{
"amount": {
"total": 10,
"currency": "EUR"
},
"merchantUrls": {
"callback": "https://api.exampleshop.com/callback",
"successRedirect": "https://exampleshop.com/success",
"failureRedirect": "https://exampleshop.com/failure",
"cancelRedirect": "https://exampleshop.com/cancel"
}
},
{
headers: {
"x-api-key": API_KEY,
"Content-Type": "application/json"
}
})
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
get
/payments/<id>
Fetch a Payment
import axios from 'axios'
const HIDIRECT_BASE_URL = "<HIDIRECT_BASE_URL>"
const API_KEY = "<YOUR_API_KEY>"
const invoice_id = "<INVOICE_ID>"
axios.get(
`${HIDIRECT_BASE_URL}/payments/${invoice_id}`,
{
headers: {
"x-api-key": API_KEY,
}
})
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
post
/payments/<id>/capture
Capture a Payment
post
/payments/<id>/cancel
Cancel a Payment
post
/payments/<id>/document/<type>
Upload Document
import axios from 'axios'
const HIDIRECT_BASE_URL = "<HIDIRECT_BASE_URL>"
const file = fs.readFileSync('/path/to/file');
const API_KEY = "<YOUR_API_KEY>"
axios.post(
`${HIDIRECT_BASE_URL}/payments/<id>/invoice`,
data: file,
{
headers: {
"x-api-key": API_KEY,
"Content-Type": "application/pdf"
}
})
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});

Entity Definitions

A payment represents the user's 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 user's 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.