Skip to main content

Quick start

Before you begin

This document covers the quick steps for getting started with the Userinfo API. You must have already signed up as an organization with Vipps MobilePay and have your test credentials from the merchant portal, as described in the Getting started guide.

Important: The examples use standard example values that you must change to use your values. This includes API keys, HTTP headers, reference, etc.

This example is for ePayment, but can be applied to the Recurring and eCom APIs.

Step 1 - Setup

No setup needed :)

Step 2 - Authentication

Get an access_token from the Access token API: POST:/accesstoken/get. This provides you with access to the API.

curl https://apitest.vipps.no/accessToken/get \
-H "client_id: YOUR-CLIENT-ID" \
-H "client_secret: YOUR-CLIENT-SECRET" \
-H "Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY" \
-H "Merchant-Serial-Number: 123456" \
-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" \
-X POST \
--data ''

The property access_token should be used for all other API requests in the Authorization header as the Bearer token.

Step 3 - Request a simple payment with profile flow

Provide the scope object in the POST:/payments call. This contains the information types that you want access to, separated by spaces (e.g., "name address email phoneNumber birthDate").

curl https://apitest.vipps.no/epayment/v1/payments \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1Ni <truncated>" \
-H "Ocp-Apim-Subscription-Key: 0f14ebcab0ec4b29ae0cb90d91b4a84a" \
-H "Merchant-Serial-Number: 123456" \
-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" \
-H "Idempotency-Key: 49ca711a-acee-4d01-993b-9487112e1def" \
-X POST \
-d '{
"amount": {
"value": 49900,
"currency": "NOK"
},
"paymentMethod": {
"type": "WALLET"
},
"customer": {
"phoneNumber": 4791234567
},
"reference": UNIQUE-PAYMENT-REFERENCE,
"userFlow": "WEB_REDIRECT",
"returnUrl": "https://example.com/redirect?reference=UNIQUE-PAYMENT-REFERENCE",
"paymentDescription": "Purchase of socks",
"profile": {
"scope": "name phoneNumber address birthDate"
}
}'

Step 4 - Complete the payment

Open the redirectUrl link that is returned, and it will take you to the landing page. The phone number of your test user should already be filled in, so you only have to click Next.

You will be presented with the payment in the app, where you can complete the payment.

Step 5 - Get the sub for the payment

Call the GET:/payments/{reference} endpoint. The unique identifier, sub, can be retrieved in the payment details under profile.

curl https://apitest.vipps.no/epayment/v1/payments/UNIQUE-PAYMENT-REFERENCE \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1Ni <truncated>" \
-H "Ocp-Apim-Subscription-Key: 0f14ebcab0ec4b29ae0cb90d91b4a84a" \
-H "Merchant-Serial-Number: 123456" \
-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" \
-X GET

Step 6 - Get the user info

Send request GET:/vipps-userinfo-api/userinfo/{sub} with the sub variable from the previous call.

curl https://apitest.vipps.no/vipps-userinfo-api/userinfo/{sub} \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1Ni <truncated>" \
-H "Ocp-Apim-Subscription-Key: 0f14ebcab0ec4b29ae0cb90d91b4a84a" \
-H "Merchant-Serial-Number: 123456" \
-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" \
-H "Idempotency-Key: 49ca711a-acee-4d01-993b-9487112e1def" \
-X GET
Example response
{
"address": {
"address_type": "home",
"country": "NO",
"formatted": "Robert Levins gate 5, 0154\nOSLO\nNO",
"postal_code": "0154",
"region": "OSLO",
"street_address": "Robert Levins gate 5"
},
"birthdate": "2000-02-01",
"family_name": "User",
"given_name": "Test",
"name": "Test User",
"other_addresses": [],
"phone_number": "4791234567",
"sid": "687a31ad9ba1de74",
"sub": "9fe5d0e3-4702-4113-a154-90bc68063325"
}

Next steps

To learn more about this API, visit the Userinfo API guide.