# Afterpay

> Create checkout sessions and read Afterpay orders and payment limits.

App · 11 actions. Web page: https://docs.lodol.com/docs/integrations/afterpay

## Actions

### Authorize and capture payment

Authorize and capture the full amount of a standard checkout in one call.

**Inputs**

- Token (`token`, text, required): Token.
- Merchant reference (`merchant_reference`, text): Merchant reference.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "created": "example",
    "id": "example",
    "merchantReference": "example",
    "originalAmount": {
      "amount": "example",
      "currency": "example"
    },
    "paymentEvents": [
      {}
    ],
    "paymentState": "example",
    "refunds": [
      {}
    ],
    "status": "APPROVED",
    "token": "example"
  }
}
```

### Authorize payment

Authorize a standard checkout token for later capture.

**Inputs**

- Token (`token`, text, required): Token.
- Merchant reference (`merchant_reference`, text): Merchant reference.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "created": "example",
    "id": "example",
    "merchantReference": "example",
    "originalAmount": {
      "amount": "example",
      "currency": "example"
    },
    "paymentEvents": [
      {}
    ],
    "paymentState": "example",
    "refunds": [
      {}
    ],
    "status": "APPROVED",
    "token": "example"
  }
}
```

### Capture authorized payment

Capture part or all of a previously authorized order amount.

**Inputs**

- Order (`order_id`, text, required): Order ID.
- Amount (`amount`, text, required): A decimal amount in the order currency, such as 35.00.
- Currency (`currency`, text, required): Currency. One of: `AUD`, `CAD`, `GBP`, `NZD`, `USD`.
- Request ID (`request_id`, text): A unique request ID to reuse if you repeat this operation.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "created": "example",
    "id": "example",
    "merchantReference": "example",
    "originalAmount": {
      "amount": "example",
      "currency": "example"
    },
    "paymentEvents": [
      {}
    ],
    "paymentState": "example",
    "refunds": [
      {}
    ],
    "status": "APPROVED",
    "token": "example"
  }
}
```

### Create checkout

Create a standard checkout session and return the URL you can send the customer to.

**Inputs**

- Amount (`amount`, text, required): The amount as a decimal, such as 35.00.
- Currency (`currency`, text, required): Currency. One of: `AUD`, `CAD`, `GBP`, `NZD`, `USD`.
- Email (`email`, text, required): Email.
- First name (`first_name`, text, required): First name.
- Last name (`last_name`, text, required): Last name.
- Phone (`phone`, text): Phone.
- Confirmation URL (`confirmation_url`, text, required): Confirmation URL.
- Cancellation URL (`cancellation_url`, text, required): Cancellation URL.
- Merchant reference (`merchant_reference`, text): Merchant reference.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "expires": "example",
    "redirectCheckoutUrl": "example",
    "token": "example"
  }
}
```

### Get checkout

Read the details of a checkout session by token.

**Inputs**

- Token (`token`, text, required): Token.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "amount": {
      "amount": "example",
      "currency": "example"
    },
    "consumer": {},
    "expires": "example",
    "merchantReference": "example",
    "token": "example"
  }
}
```

### Get payment

Read an Afterpay order by its order ID.

**Inputs**

- Order (`order_id`, text, required): Order ID.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "created": "example",
    "id": "example",
    "merchantReference": "example",
    "originalAmount": {
      "amount": "example",
      "currency": "example"
    },
    "paymentEvents": [
      {}
    ],
    "paymentState": "example",
    "refunds": [
      {}
    ],
    "status": "APPROVED",
    "token": "example"
  }
}
```

### Get payment by checkout token

Read an Afterpay order by its checkout token.

**Inputs**

- Token (`token`, text, required): Token.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "created": "example",
    "id": "example",
    "merchantReference": "example",
    "originalAmount": {
      "amount": "example",
      "currency": "example"
    },
    "paymentEvents": [
      {}
    ],
    "paymentState": "example",
    "refunds": [
      {}
    ],
    "status": "APPROVED",
    "token": "example"
  }
}
```

### Get payment limits

Read the minimum and maximum order amount for your merchant account.

**Inputs**: None.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "maximumAmount": {
      "amount": "example",
      "currency": "example"
    },
    "minimumAmount": {
      "amount": "example",
      "currency": "example"
    }
  }
}
```

### List payments

Read a page of Afterpay orders with payment state and an optional date range.

**Inputs**

- Start date (`start_date`, date and time): Start date.
- End date (`end_date`, date and time): End date.
- Statuses (`statuses`, list): Statuses. One or more of: `APPROVED`, `DECLINED`.
- Order IDS (`order_ids`, list): Order IDS.
- Merchant references (`merchant_references`, list): Merchant references.
- Tokens (`tokens`, list): Tokens.
- Order by (`order_by`, text): Order by. One of: `createdAt`, `id`, `amount`, `merchantReference`, `email`.
- Ascending (`ascending`, true/false): Ascending.
- Limit (`limit`, number): Limit. From 1 to 250.
- Offset (`offset`, number): Offset. At least 0.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "limit": 1,
    "nextPageUrl": "example",
    "offset": 1,
    "results": [
      {
        "created": "example",
        "id": "example",
        "merchantReference": "example",
        "originalAmount": {
          "amount": "example",
          "currency": "example"
        },
        "paymentEvents": [
          {}
        ],
        "paymentState": "example",
        "refunds": [
          {}
        ],
        "status": "APPROVED",
        "token": "example"
      }
    ],
    "totalResults": 1
  }
}
```

### Refund payment

Refund a captured amount on an Afterpay payment.

**Inputs**

- Order (`order_id`, text, required): Order ID.
- Amount (`amount`, text, required): A decimal amount in the order currency, such as 35.00.
- Currency (`currency`, text, required): Currency. One of: `AUD`, `CAD`, `GBP`, `NZD`, `USD`.
- Merchant reference (`merchant_reference`, text, required): Merchant reference.
- Request ID (`request_id`, text, required): A unique request ID to reuse if you repeat this operation.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "amount": {
      "amount": "example",
      "currency": "example"
    },
    "merchantReference": "example",
    "refundId": "example",
    "refundedAt": "example",
    "requestId": "example"
  }
}
```

### Void payment

Release the remaining authorization on a payment.

**Inputs**

- Order (`order_id`, text, required): Order ID.
- Request ID (`request_id`, text): Request ID.

**Outputs**

- `data` (object): The response from Afterpay.

**Example output**

```json
{
  "data": {
    "created": "example",
    "id": "example",
    "merchantReference": "example",
    "originalAmount": {
      "amount": "example",
      "currency": "example"
    },
    "paymentEvents": [
      {}
    ],
    "paymentState": "example",
    "refunds": [
      {}
    ],
    "status": "APPROVED",
    "token": "example"
  }
}
```
