> **Description:** A step-by-step guide to quickly implement the PSP Merchant API for automated merchant onboarding, including authentication setup, API calls, and validation of merchant information.

# PSP Merchant API quick start

## Before you begin

The example values in this guide must be replaced with your own values.
This applies to API keys, HTTP headers, references, and similar values.

**MobilePay Online PSPs**

This page is for PSPs integrating with the ePayment, Recurring, or Vipps PSP APIs.
If you are a MobilePay Online PSP, go to [MobilePay Online API](https://developer.vippsmobilepay.com/docs/APIs/psp-mp-api/README.md).

## Sign up your first merchant

### Step 1 - Setup

You must have already signed up as a Payment Service Provider with Vipps MobilePay and received your test credentials.
If you haven't done this yet, see [Setup](https://developer.vippsmobilepay.com/docs/APIs/psp-merchant-api/psp-merchant-api-getting-started.md).

You will need the following credentials:

* `client_id` - Client ID, required for getting the access token.
* `client_secret` - Client secret, required for getting the access token.
* `Ocp-Apim-Subscription-Key` - PSP subscription key, required for all requests.
* `PSP-ID` - PSP ID provided by Vipps MobilePay, required for all requests.

### Step 2 - Get an access token

All subsequent requests require an `access_token` from
[`POST:/accesstoken/get`](https://developer.vippsmobilepay.com/redocusaurus/access-token-swagger-id.yaml).

```bash
curl -X POST 'https://apitest.vipps.no/accesstoken/get' \
-H "Content-Type: application/json" \
-H 'client_id: YOUR-CLIENT-ID' \
-H 'client_secret: YOUR-CLIENT-SECRET' \
-H 'Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY' \
-H 'Merchant-Serial-Number: YOUR-MSN' \
--data ''
```

In production, include all `Vipps-System` headers to aid debugging.
See [HTTP headers](https://developer.vippsmobilepay.com/docs/knowledge-base/http-headers.md) for details.

Use the `access_token` value as the Bearer token in the `Authorization` header of all subsequent requests.

### Step 3 - Get all merchants under your PSP account

Send
[`GET:/merchant-management/psp/v1/merchants`](https://developer.vippsmobilepay.com/redocusaurus/psp-merchant-swagger-id.yaml)
for a JSON response showing all the merchants and their information.

```bash
curl -X GET https://apitest.vipps.no/merchant-management/psp/v1/merchants \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-ACCESS-TOKEN" \
-H "Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY" \
-H "PSP-ID: YOUR-PSP-ID" \
-H "Vipps-System-Name: acme" \
-H "Vipps-System-Version: 3.1.2" \
-H "Vipps-System-Plugin-Name: acme-webshop" \
-H "Vipps-System-Plugin-Version: 4.5.6" \
```

### Step 4 - Get merchant details by MSN

Use
[`GET:/merchant-management/psp/v1/merchants/{merchantSerialNumber}`](https://developer.vippsmobilepay.com/redocusaurus/psp-merchant-swagger-id.yaml)
for information about a specific merchant. Supply the MSN.

```bash
curl -X GET https://apitest.vipps.no/merchant-management/psp/v1/merchants/{merchantSerialNumber} \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-ACCESS-TOKEN" \
-H "Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY" \
-H "PSP-ID: YOUR-PSP-ID" \
-H "Vipps-System-Name: acme" \
-H "Vipps-System-Version: 3.1.2" \
-H "Vipps-System-Plugin-Name: acme-webshop" \
-H "Vipps-System-Plugin-Version: 4.5.6" \
```

### Step 5 - Create a new merchant

Send
[`POST:/merchant-management/psp/v1/merchants`](https://developer.vippsmobilepay.com/redocusaurus/psp-merchant-swagger-id.yaml).
The response includes the `merchantSerialNumber`.

```bash
curl -X POST https://apitest.vipps.no/merchant-management/psp/v1/merchants \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-ACCESS-TOKEN" \
-H "Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY" \
-H "Idempotency-Key: YOUR-IDEMPOTENCY-KEY" \
-H "PSP-ID: YOUR-PSP-ID" \
-H "Vipps-System-Name: acme" \
-H "Vipps-System-Version: 3.1.2" \
-H "Vipps-System-Plugin-Name: acme-webshop" \
-H "Vipps-System-Plugin-Version: 4.5.6" \
--data '{
    "name": "Fry Merch Shop",
    "address": {
        "addressLine1": "Robert Levins gate 5",
        "city": "Oslo",
        "country": "NO",
        "postCode": "0154",
        "addressLine2": ""
    },
    "logo": "YOUR-BASE64-ENCODED-PNG",
    "organizationNumber": "123456789",
    "companyName": "Fry Teknologi AS",
    "companyEmail": "developer@example.com",
    "mccCode": "5411",
    "email": "developer@example.com",
    "website": "https://example.com"
}'
```

### Step 6 - (Optional) Update a merchant

To update the merchant, send the
[`PATCH:/merchant-management/psp/v1/merchants/{merchantSerialNumber}`](https://developer.vippsmobilepay.com/redocusaurus/psp-merchant-swagger-id.yaml)
request. Provide the Merchant Serial Number and the properties to be updated.

```bash
curl -X PATCH https://apitest.vipps.no/merchant-management/psp/v1/merchants/{merchantSerialNumber} \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-ACCESS-TOKEN" \
-H "Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY" \
-H "PSP-ID: YOUR-PSP-ID" \
-H "Vipps-System-Name: acme" \
-H "Vipps-System-Version: 3.1.2" \
-H "Vipps-System-Plugin-Name: acme-webshop" \
-H "Vipps-System-Plugin-Version: 4.5.6" \
--data '{
    "email": "developer2@example.com",
    "website": "https://example.com/updated"
    }'
```

## Next steps

See the [API guide](https://developer.vippsmobilepay.com/docs/APIs/psp-merchant-api/psp-merchant-api-guide.md) to read about the concepts and details.

> **Full site overview:** For every page in this documentation, read [https://developer.vippsmobilepay.com/llms.txt](https://developer.vippsmobilepay.com/llms.txt).
