Payments

Endpoints

Create a Payment

POST /payments

Create a payment

Headers

Request Body

{
    "amount": 20.01,
    "currency": "EUR",
    "createdAt": "2021-06-23T05:50:22.090Z",
    "customerInformation": {},
    "id": "01F8VPPRANKR4418TWW97QQGEH",
    "merchantReference": null,
    "merchantUrls": {
        "callback": "https://api.exampleshop.com/callback",
        "cancelRedirect": "https://exampleshop.com/cancel",
        "failureRedirect": "https://exampleshop.com/failure",
        "successRedirect": "https://exampleshop.com/success"
    },
    "amountDetails": {
        "tax": 2,
        "shipping": 10,
        "subtotal": 30.01
    },
    "prescriptionRequired": false,
    "status": "INITIAL",
    "updatedAt": null,
    "token": "eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJhbW91bnQiOjIwMDEsImN1cnJlbmN5IjoiRVVSIiwiaWQiOiIwMUY4VlBQUkFOS1I0NDE4VFdXOTdRUUdFSCIsIm1lcmNoYW50VXJscyI6eyJmYWlsdXJlUmVkaXJlY3QiOiJodHRwczovL2V4YW1wbGVzaG9wLmNvbS9mYWlsdXJlIiwic3VjY2Vzc1JlZGlyZWN0IjoiaHR0cHM6Ly9leGFtcGxlc2hvcC5jb20vc3VjY2VzcyIsImNhbmNlbFJlZGlyZWN0IjoiaHR0cHM6Ly9leGFtcGxlc2hvcC5jb20vY2FuY2VsIn0sImFtb3VudERldGFpbHMiOnsidGF4IjoyMDAsInNoaXBwaW5nIjoxMDAwLCJzdWJ0b3RhbCI6MzAwMX0sInByZXNjcmlwdGlvblJlcXVpcmVkIjpmYWxzZSwic3RhdHVzIjoiSU5JVElBTCIsImlhdCI6MTYyNDQyNzQyMjA5MCwiZXhwIjoxNjI0NDM0NjIyMDkwLCJpc3MiOiJodHRwczovL2hpLmhlYWx0aCJ9.ABiWxQIJyzwiXXqxiepB0cJig70qXv3WEoBpmpN5HqHrEtRyuPrwaDdjnldXZOQbs1xBBMSZu0TxVsGCQRg4isqYAa6F1rHs2-wMjs3HS6F7CQTa3UTVj1J2_wb3-JuAsgv7QNRU21G53Jw9CYbAkGeIbM2pAscZJTGiQdrRRjqRZVmH"
}
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);
  });

Fetch a Payment

GET /payments/<id>

Fetch a payment

Path Parameters

Headers

{
    "amount": 20.01,
    "currency": "EUR",
    "createdAt": "2021-06-24T08:34:30.874Z",
    "customerInformation": {},
    "id": "01F8YJG175R7JP223G76N7X75N",
    "merchantReference": null,
    "merchantUrls": {
        "callback": "https://api.exampleshop.com/callback",
        "cancelRedirect": "https://exampleshop.com/cancel",
        "failureRedirect": "https://exampleshop.com/failure",
        "successRedirect": "https://exampleshop.com/success"
    },
    "amountDetails": {
        "tax": 0,
        "shipping": 10,
        "subtotal": 10.01
    },
    "prescriptionRequired": false,
    "status": "INITIAL",
    "updatedAt": null
}
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);
  });

Capture a Payment

POST /payments/<id>/capture

Trigger the capture of a payment that was previously pre-authorised.

This action is only possible on Payments that we're created with the option cardCaptureMode = MANUAL and have the Status AUTHORISED

If Payments are not captured within a span of 7 days, they are automatically cancelled.

Path Parameters

Headers

{
    "amount": 20.01,
    "currency": "EUR",
    "createdAt": "2021-06-24T08:34:30.874Z",
    "customerInformation": {},
    "id": "01F8YJG175R7JP223G76N7X75N",
    "merchantReference": null,
    "merchantUrls": {
        "callback": "https://api.exampleshop.com/callback",
        "cancelRedirect": "https://exampleshop.com/cancel",
        "failureRedirect": "https://exampleshop.com/failure",
        "successRedirect": "https://exampleshop.com/success"
    },
    "amountDetails": {
        "tax": 0,
        "shipping": 10,
        "subtotal": 10.01
    },
    "prescriptionRequired": false,
    "status": "INITIAL",
    "updatedAt": null
}

Cancel a Payment

POST /payments/<id>/cancel

Cancel a payment that was previously pre-authorised.

This action is only possible on Payments that we're created with the option cardCaptureMode = MANUAL and have the Status AUTHORISED

Path Parameters

Headers

{
    "amount": 20.01,
    "currency": "EUR",
    "createdAt": "2021-06-24T08:34:30.874Z",
    "customerInformation": {},
    "id": "01F8YJG175R7JP223G76N7X75N",
    "merchantReference": null,
    "merchantUrls": {
        "callback": "https://api.exampleshop.com/callback",
        "cancelRedirect": "https://exampleshop.com/cancel",
        "failureRedirect": "https://exampleshop.com/failure",
        "successRedirect": "https://exampleshop.com/success"
    },
    "amountDetails": {
        "tax": 0,
        "shipping": 10,
        "subtotal": 10.01
    },
    "prescriptionRequired": false,
    "status": "INITIAL",
    "updatedAt": null
}

Upload Document

POST /payments/<id>/document/<type>

Upload a document related to a specific Order Payment.

Path Parameters

Headers

Request Body

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

MerchantUrls

Amount

Last updated