Skip to content

Instantly share code, notes, and snippets.

@john-zaprite
Created May 13, 2022 14:31
Show Gist options
  • Save john-zaprite/cebab9d3af3c03e17edffbec047133ff to your computer and use it in GitHub Desktop.
Save john-zaprite/cebab9d3af3c03e17edffbec047133ff to your computer and use it in GitHub Desktop.
Zaprite integration with the Ibex Pay API.

The following is the ideal flow Zaprite would like to have when using the Ibex Pay API.

API key

Zaprite should have it's own 'partner' API key that we store as an environment variable in our Next JS app.

Permissions

1. Create public invoices on a user's behalf
2. Watch for settlement of those invoices

User account connection

Zaprite users can sign-in to their Ibex accounts and we will save their accountId in Zaprite's database.

Invoice generation

We will generate a Ibex Pay public invoice on the user's behalf, using our partner API key and the user's Ibex accountId.

We need to also attach custom metadata to the POST request, as follows:

"metadata": {
  "userId": "QNmM7hHzi6vjbi15BSu9",
  "docId": "M7hNmHzi15Bidi6vjbSQ",
  "ref": "l4c9wAxjt8A7QUqZr7Dh"
}

This metadata should be stored on your side, and sent back with the webhook payload.

Webhook payload

We need to have the ability to create a subscription that watches all invoices that have been generated using our partner API key.

The webhook should deliver a payload to our endpoint whenever an invoice is settled. This payload should include the custom metadata that we sent with the original POST request to create the invoice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment