Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 43 additions & 43 deletions source/includes/_invoices.md → source/includes/_payruns.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Invoices
# Payruns

An Invoice groups Payouts together. It is a managed object, you can not create them directly. When a Payout is created
it is added to the Invoice that is currently open. If there is no open Invoice, a new will be created.
A Payrun groups Payouts together. It is a managed object, you can not create them directly. When a Payout is created
it is added to the Payrun that is currently open. If there is no open Payrun, a new will be created.

You can keep invoices open for a certain time period by enabling batching of payouts. Contact [[email protected]](mailto:[email protected]) if you are interested in this.
You can keep payruns open for a certain time period by enabling batching of payouts. Contact [[email protected]](mailto:[email protected]) if you are interested in this.

### The Invoice object
### The Payrun object

> An example Invoice object:
> An example Payrun object:

```json
{
Expand All @@ -32,22 +32,22 @@ You can keep invoices open for a certain time period by enabling batching of pay
| `id` | A unique identifier for the object. |
| `metadata` | JSON-encoded metadata. |
| `ocr_number` | Bank reference. |
| `open` | Whether the Invoice is the currently open one. |
| `paid_at` | Time at which the Invoice was paid. Displayed as ISO 8601 string. |
| `pdf` | Link to download a pdf version of the Invoice. |
| `open` | Whether the Payrun is the currently open one. |
| `paid_at` | Time at which the Payrun was paid. Displayed as ISO 8601 string. |
| `pdf` | Link to download a pdf version of the Payrun. |
| `price` | Decimal formatted string of the price. |





## List All Invoices
## List All Payruns

```python
import requests

response = requests.get(
'https://api.gigapay.se/v2/invoices/',
'https://api.gigapay.se/v2/payruns/',
headers={
'Authorization': 'Token cd7a4537a231356d404b553f465b6af2fa035821',
'Integration-ID': '79606358-97af-4196-b64c-5f719433d56b'
Expand All @@ -56,11 +56,11 @@ response = requests.get(
```

```shell
curl -X GET -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' https://api.gigapay.se/v2/invoices/
curl -X GET -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' https://api.gigapay.se/v2/payruns/
```

```javascript
fetch("https://api.gigapay.se/v2/invoices/", {
fetch("https://api.gigapay.se/v2/payruns/", {
headers: {
"Authorization": "Token cd7a4537a231356d404b553f465b6af2fa035821",
"Integration-Id": "79606358-97af-4196-b64c-5f719433d56b"
Expand All @@ -74,7 +74,7 @@ fetch("https://api.gigapay.se/v2/invoices/", {
{
"count": 4,
"next": null,
"previous": "https://api.gigapay.se/v2/invoices/?page=1",
"previous": "https://api.gigapay.se/v2/payruns/?page=1",
"results": [
{
"app": "https://app.gigapay.se/i/2859272/?token=Ii9pbnZvaWNpbmcvb3Blbl9pbnZvaWNlcy9jMTMzYzIwMi0xMDUwLTQ5NTktODMwNi05NWQ3Y2IzZjNiMjgvIg",
Expand Down Expand Up @@ -102,11 +102,11 @@ fetch("https://api.gigapay.se/v2/invoices/", {
}
```

This endpoint retrieves all Invoices.
This endpoint retrieves all Payruns.

### HTTP Request

`GET https://api.gigapay.se/v2/invoices/`
`GET https://api.gigapay.se/v2/payruns/`

### Headers

Expand All @@ -120,21 +120,21 @@ Parameter | Required | Description
Parameter | Default | Description
--------- | ------- | -----------
`page` | 1 | Which page to return.
`page_size` | 25 | The number of Invoices per page.
`page_size` | 25 | The number of Payruns per page.
`created_at` | | Timestamp filter.
`paid_at` | | Timestamp filter.





## Retrieve an Invoice
## Retrieve a Payrun

```python
import requests

response = requests.get(
'https://api.gigapay.se/v2/invoices/2859272/',
'https://api.gigapay.se/v2/payruns/2859272/',
headers={
'Authorization': 'Token cd7a4537a231356d404b553f465b6af2fa035821',
'Integration-ID': '79606358-97af-4196-b64c-5f719433d56b'
Expand All @@ -143,11 +143,11 @@ response = requests.get(
```

```shell
curl -X GET -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' https://api.gigapay.se/v2/invoices/2859272/
curl -X GET -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' https://api.gigapay.se/v2/payruns/2859272/
```

```javascript
fetch("https://api.gigapay.se/v2/invoices/2859272/", {
fetch("https://api.gigapay.se/v2/payruns/2859272/", {
headers: {
"Authorization": "Token cd7a4537a231356d404b553f465b6af2fa035821",
"Integration-Id": "79606358-97af-4196-b64c-5f719433d56b"
Expand All @@ -172,11 +172,11 @@ fetch("https://api.gigapay.se/v2/invoices/2859272/", {
}
```

This endpoint retrieves an Invoice.
This endpoint retrieves a Payrun.

### HTTP Request

`GET https://api.gigapay.se/v2/invoices/:id/`
`GET https://api.gigapay.se/v2/payruns/:id/`

### Headers

Expand All @@ -196,13 +196,13 @@ Parameter | Required | Description



## Update an Invoice
## Update a Payrun

```python
import requests

response = requests.patch(
'https://api.gigapay.se/v2/invoices/2859272/',
'https://api.gigapay.se/v2/payruns/2859272/',
json={
'id': '846271',
'metadata': {'original_id': '2859272'}
Expand All @@ -215,11 +215,11 @@ response = requests.patch(
```

```shell
curl -X PATCH -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Content-Type: application/json' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' -d '{"id": "846271", "metadata": {"original_id": "2859272"}}' https://api.gigapay.se/v2/invoices/2859272/
curl -X PATCH -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Content-Type: application/json' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' -d '{"id": "846271", "metadata": {"original_id": "2859272"}}' https://api.gigapay.se/v2/payruns/2859272/
```

```javascript
fetch("https://api.gigapay.se/v2/invoices/2859272/", {
fetch("https://api.gigapay.se/v2/payruns/2859272/", {
method: "PATCH",
body: JSON.stringify({'id': '846271', 'metadata': {'original_id': '2859272'}}),
headers: {
Expand Down Expand Up @@ -249,11 +249,11 @@ fetch("https://api.gigapay.se/v2/invoices/2859272/", {
}
```

This endpoint updates an Invoice.
This endpoint updates a Payrun.

### HTTP Request

`PATCH https://api.gigapay.se/v2/invoices/:id/`
`PATCH https://api.gigapay.se/v2/payruns/:id/`

### Headers

Expand All @@ -276,13 +276,13 @@ Parameter | Type | Required | Default | Notes
`metadata` | Object | False | Previous value |


## Finalize an Invoice
## Finalize a Payrun

```python
import requests

response = requests.post(
'https://api.gigapay.se/v2/invoices/846271/close/',
'https://api.gigapay.se/v2/payruns/846271/close/',
headers={
'Authorization': 'Token cd7a4537a231356d404b553f465b6af2fa035821',
'Integration-ID': '79606358-97af-4196-b64c-5f719433d56b'
Expand All @@ -291,11 +291,11 @@ response = requests.post(
```

```shell
curl -X POST -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' https://api.gigapay.se/v2/invoices/846271/close/
curl -X POST -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' https://api.gigapay.se/v2/payruns/846271/close/
```

```javascript
fetch("https://api.gigapay.se/v2/invoices/846271/close/", {
fetch("https://api.gigapay.se/v2/payruns/846271/close/", {
method: "POST",
headers: {
"Authorization": "Token cd7a4537a231356d404b553f465b6af2fa035821",
Expand All @@ -307,15 +307,15 @@ fetch("https://api.gigapay.se/v2/invoices/846271/close/", {
> The above command returns an empty response.


Invoices are initially created in an open state (pro-forma) and are not immediately finalized. This allows users to review and edit their invoices before submission.
Payruns are initially created in an open state (pro-forma) and are not immediately finalized. This allows users to review and edit their payruns before submission.

Once the invoice is ready, it can be finalized using this endpoint. Finalization has two important effects:
Once the payrun is ready, it can be finalized using this endpoint. Finalization has two important effects:
1. The payouts become visible to the employees
2. The invoice is sent to the email address configured in the integration settings
2. The payrun is sent to the email address configured in the integration settings

### HTTP Request

`POST https://api.gigapay.se/v2/invoices/:id/close/`
`POST https://api.gigapay.se/v2/payruns/:id/close/`

### Headers

Expand All @@ -333,13 +333,13 @@ Parameter | Required | Description



## Delete an Invoice
## Delete a Payrun

```python
import requests

response = requests.delete(
'https://api.gigapay.se/v2/invoices/846271/',
'https://api.gigapay.se/v2/payruns/846271/',
headers={
'Authorization': 'Token cd7a4537a231356d404b553f465b6af2fa035821',
'Integration-ID': '79606358-97af-4196-b64c-5f719433d56b'
Expand All @@ -348,11 +348,11 @@ response = requests.delete(
```

```shell
curl -X DELETE -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' https://api.gigapay.se/v2/invoices/846271/
curl -X DELETE -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' https://api.gigapay.se/v2/payruns/846271/
```

```javascript
fetch("https://api.gigapay.se/v2/invoices/846271/", {
fetch("https://api.gigapay.se/v2/payruns/846271/", {
method: "DELETE",
headers: {
"Authorization": "Token cd7a4537a231356d404b553f465b6af2fa035821",
Expand All @@ -364,11 +364,11 @@ fetch("https://api.gigapay.se/v2/invoices/846271/", {
> The above command returns an empty response.


This endpoint deletes an Invoice. Note that you can not delete a paid Invoice or an Invoice on credit.
This endpoint deletes a Payrun. Note that you can not delete a paid Payrun or a Payrun on credit.

### HTTP Request

`DELETE https://api.gigapay.se/v2/invoices/:id/`
`DELETE https://api.gigapay.se/v2/payruns/:id/`

### Headers

Expand Down
16 changes: 8 additions & 8 deletions source/includes/_webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ import requests
response = requests.put(
'https://api.gigapay.se/v2/webhooks/481272/',
json={
'url': 'https://jobmatchr.se/webhooks/invoiced/',
'events': ['Invoice.created']
'url': 'https://jobmatchr.se/webhooks/payruns/',
'events': ['Payrun.created']
},
headers={
'Authorization': 'Token cd7a4537a231356d404b553f465b6af2fa035821',
Expand All @@ -339,13 +339,13 @@ response = requests.put(
```

```shell
curl -X PUT -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Content-Type: application/json' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' -d '{"url": "https://jobmatchr.se/webhooks/invoiced/", "events": ["Invoice.created"]}' https://api.gigapay.se/v2/webhooks/481272/
curl -X PUT -H 'Authorization: Token cd7a4537a231356d404b553f465b6af2fa035821' -H 'Content-Type: application/json' -H 'Integration-ID: 79606358-97af-4196-b64c-5f719433d56b' -d '{"url": "https://jobmatchr.se/webhooks/payruns/", "events": ["Payrun.created"]}' https://api.gigapay.se/v2/webhooks/481272/
```

```javascript
fetch("https://api.gigapay.se/v2/webhooks/481272/", {
method: "PUT",
body: JSON.stringify({url: "https://jobmatchr.se/webhooks/invoiced/", events: ["Invoice.created"]}),
body: JSON.stringify({url: "https://jobmatchr.se/webhooks/payruns/", events: ["Payrun.created"]}),
headers: {
"Authorization": "Token cd7a4537a231356d404b553f465b6af2fa035821",
"Content-Type": "application/json",
Expand All @@ -359,8 +359,8 @@ fetch("https://api.gigapay.se/v2/webhooks/481272/", {
```json
{
"id": "481272",
"url": "https://jobmatchr.se/webhooks/invoices/",
"events": ["Invoice.created"],
"url": "https://jobmatchr.se/webhooks/payruns/",
"events": ["Payrun.created"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Do we have Payrun.created event?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

"secret_key": "vksnrsc6tamq73tc26rzrnzf33a4pgdv",
"metadata": {}
}
Expand All @@ -369,8 +369,8 @@ fetch("https://api.gigapay.se/v2/webhooks/481272/", {
```json
{
"id": "481272",
"url": "https://jobmatchr.se/webhooks/invoices/",
"events": ["Invoice.created"],
"url": "https://jobmatchr.se/webhooks/payruns/",
"events": ["Payrun.created"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have Payrun.created event?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

"secret_key": "vksnrsc6tamq73tc26rzrnzf33a4pgdv",
"metadata": {}
}
Expand Down
6 changes: 3 additions & 3 deletions source/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ includes:
- messages
- payouts
- pricing
- invoices
- payruns
- webhooks

search: true
Expand Down Expand Up @@ -239,8 +239,8 @@ on the following events:
- `Payout.created`
- `Payout.notified`
- `Payout.accepted`
- `Invoice.created`
- `Invoice.paid`
- `Payrun.created`
- `Payrun.paid`
Comment on lines +242 to +243
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have these webhook events?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will check. This is good. As we should have it indeed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed now


The notifications simply contain the object that triggered the event, as represented in the API.

Expand Down