> ## Documentation Index
> Fetch the complete documentation index at: https://docs.plude.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Altapay

Altapay is a Danish payment provider supported various means of payment methods including VISA, Mastercard and Swiss.

# Introduction

Our integration with Altapay support the following payment methods:

<Tabs>
  <Tab title="Credit card">
    VISA, Mastercard, Maestro, Dankort via Valitor payment acquirer.
  </Tab>

  <Tab title="Klarna">
    Supported
  </Tab>

  <Tab title="Swiss">
    Supported
  </Tab>

  <Tab title="Apple & Google Pay">
    Supported
  </Tab>

  <Tab title="Paypal">
    Supported
  </Tab>

  <Tab title="Vipps MobilePay">
    Supported
  </Tab>
</Tabs>

<Warning>
  AltaPay require that the payment method currency aligns with the invoice currency. A payment method of `EUR` cannot be used to pay an invice of `USD`.
</Warning>

# Getting started

Sign up for an Altapay account, using the following [link](https://www.altapay.com/public-form).

## Enabling Altapay

Before enabling Altapay, you will need to collect your `username`, `password`, `terminal name` and `gateway name`.

To enable Altapay as a payment provider, use the following snippet:

```bash theme={null}
curl -X POST \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer {your_token_here}" \
     -H "X-environment: {your_environment_id_here}" \
     -H "X-version: 2022-03" \
     -d '{ "name": "altapay" }' \
     https://api.plude.io/paymentproviders/
```

You will receive a response as follows:

```json theme={null}
{
    "url" : "https://go.plude.io/t/sQgzPzNDnDeWLiGvVWZQKX",
    "expires" : "2022-11-07T22:30:05+00:00"   
}
```

Follow the `url` parameter and complete the authorization page with your Altapay credentials. You can retrieve the newly configured payment provider by issuing a request using this snippet:

```bash theme={null}
curl -H "X-version: 2022-03" \
     -H "Authorization: Bearer your_token_here" 
     -H "X-environment: {your_environment_id_here}" \
     -H "X-version: 2022-03" \
     https://api.plude.io/paymentproviders/
```

You will receive a response as follows:

```json theme={null}
{
    "results" : [
        {
            "id" : "d64acb1b-4d34-42ee-b888-f59ec0ef9fd0",
            "name" : "altapay",
            "status" : "active"
            ..
        }
    ]
}
```

## Configuring Altapay

You can configure Altapay with the following parameters.

| parameter   | values                 | note                                                                                  |
| ----------- | ---------------------- | ------------------------------------------------------------------------------------- |
| environment | `test` or `production` | Configure the Altapay environment to use test or production. Default to `production`. |

To configure Altapay, use the following snippet:

```bash theme={null}
curl -X PUT \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer {your_token_here}" \
     -H "X-environment: {your_environment_id_here}" \
     -H "X-version: 2022-03" \
     -d '{ "environment": "test" }' \
     https://api.plude.io/paymentproviders/{d64acb1b-4d34-42ee-b888-f59ec0ef9fd0}
```

# Payment methods

## Adding a Credit card

Altapay use terminals to distinguish between different payment methods. You must first configure a credit card terminal in Altapay to proceed.

To add a credit card payment method to a Customer, use the following snippet:

```bash theme={null}
curl -X PUT \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer {your_token_here}" \
     -H "X-environment: {your_environment_id_here}" \
     -H "X-version: 2022-03" \
     -d '{ "provider": "altapay", "terminal" : "(name of your terminal)", "redirect" : "(your redirect url here)" }' \
     https://api.plude.io/customers/{552dabcf-31e5-4998-9d24-0689448ae7cf}/paymentmethods/
```

Your request will return the following response:

```json theme={null}
{
    "url" : "https://pludesample.altapaysecure.com/merchant/API/...",
    "session" : "fc1aa9d4-df96-4088-b1e4-3bb78bc761b0"
}
```

Redirect the user to the provided URL. The user will be redirected to an Altapay hosted page, and must complete the payment method instructions. Once completed, the user is redirected to the redrect url provided in the initial request.

You will get the following response:

```json theme={null}
{
    "message" : "Payment method created"
}
```
