Quick start
Before you beginโ
The provided example values in this guide must be changed with the values for your sales unit and user. This applies for API keys, HTTP headers, reference, phone number, etc.
Your first QR codeโ
Step 1 - Setupโ
You must have already signed up as an organization with Vipps MobilePay and have your test credentials from the merchant portal.
You will need the following values, as described in the Getting started guide:
client_id
- Client_id for a test sales unit.client_secret
- Client_id for a test sales unit.Ocp-Apim-Subscription-Key
- Subscription key for a test sales unit.merchantSerialNumber
- The unique ID for a test sales unit.MobileNumber
- The phone number for the test app profile you have received or registered. This is your test mobile number without country code.
- curl
- Postman
In Postman, import the following files:
๐ฅ To reduce risk of exposure, never store production keys in Postman or any similar tools. ๐ฅ
Update the Current Value field in your Postman environment with your Merchant Test keys. Use Current Value field for added security, as these values are not synced to the cloud.
No additional setup needed :)
Step 2 - Authenticationโ
Get an access_token
from the
Access token API:
POST:/accesstoken/get
.
- curl
- Postman
Send request Get Access Token
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: YOUR-MSN" \
-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.
Merchant Redirect QRโ
A merchant redirect QR contains a link to your webshop. When the user scans this with their phone, your website will open.
Generate a merchant redirect QR with:
POST:/qr/v1/merchant-redirect
.
- curl
- Postman
Send request Merchant Redirect QR > Generate QR
The qr-id
variable is now set in the environment for use with subsequent calls.
Ctrl+click the link to see the QR code. Scanning the QR should open the specified URL on your phone.
The result from this request provides a URL with its own JWT token, which will expire.
Get a new token by calling Get QR by id
.
curl https://apitest.vipps.no/qr/v1/merchant-redirect \
-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 '{
"redirectUrl": "https://example.com/mywebshop",
"id": "UNIQUE-QR-ID"
}'
Enter the returned link into a browser. It will show the QR code. Scanning the QR should open the specified URL on your phone.
The result from this request provides a URL with its own JWT token, which will expire.
Get a new token by calling
GET:/qr/v1/merchant-redirect/{qr-id}
.
Relevant examples:
- Static QR directing to the merchant site for payment
- Static QR directing to the merchant site for product selection
One-time payment QRโ
A one-time payment QR (also called dynamic QR) is connected to a payment. When the user scans this QR with their phone, the Vipps app will open and present them with the payment request.
If you are using the ePayment API in your solution, you do not need to use the QR API. See Dynamic QR directing to the app for payment for an example.
Legacy method for eCom API
Create a payment and get the unique payment reference.
- curl
- Postman
Send request Initiate Payment
The orderId
and vippsLandingPageUrl
variables are now in the environment of this Postman example.
curl --location 'https://apitest.vipps.no/ecomm/v2/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" \
-X POST \
-d '{
"customerInfo": {
"mobileNumber": "91234567"
},
"merchantInfo": {
"merchantSerialNumber": "123456",
"callbackPrefix":"https://example.com/vipps/callbacks-for-payment-update-from-vipps",
"fallBack": "https://example.com/vipps/fallback-result-page-for-both-success-and-failure/acme-shop-123-order123abc",
},
"transaction": {
"amount": 49900,
"orderId": "UNIQUE-PAYMENT-REFERENCE",
"transactionText": "One pair of socks.",
}
}'
Note that orderId
must be unique for each payment you create.
Take note of the URL that is returned in the response body and provide it in the POST:/qr/v1 request to generate the one-time payment QR.
- curl
- Postman
Send request Generate OTP QR
This supplies vippsLandingPageUrl
to
POST:/qr/v1
to provide a URL that can be used to show a QR code.
Ctrl+click the link to see the QR code. Scanning the QR should open the test app on your phone and allow you to complete the one-time purchase.
curl --location 'https://apitest.vipps.no/qr/v1' \
-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 POST \
-d '{
"url": "https://apitest.vipps.no/dwo-api-application/v1/deeplink/vippsgateway?v=2&token=eyJraWQiOiJqd3RrZXkiLCJhbGciOiJSUzI1NiJ<truncated>"
}'
Next stepsโ
See the QR API guide to read about the concepts and details.