SDK client for Vipps Mobilepay public APIs.
A zero dependency, zero configuration ES Module built with Deno. The code is written entirely in TypeScript and has 100% test coverage.
Available on: deno.land and NPM
import { Client } from "https://deno.land/x/[email protected]/mod.ts";
// Create a client
const client = Client({
merchantSerialNumber,
subscriptionKey,
useTestMode: true,
retryRequests: false,
});
// Grab a token
const accessToken = await client.auth.getToken(clientId, clientSecret);
// Check if the token was retrieved successfully
if (!accessToken.ok) {
console.error("😟 Error retrieving token 😟");
console.error(accessToken.error);
Deno.exit(1);
}
const token = accessToken.data.access_token;
// Create a payment
const payment = await client.payment.create(token, {
amount: {
currency: "NOK",
value: 1000, // This value equals 10 NOK
},
paymentMethod: { type: "WALLET" },
customer: { phoneNumber: "4712345678" },
returnUrl: `https://yourwebsite.com/redirect`,
userFlow: "WEB_REDIRECT",
paymentDescription: "One pair of socks",
});
Documentation of the SDK, and about Vipps MobilePay in general, please visit our developer docs.
A wide range of code samples are available in sample_code/
.
All external exports are defined in src/mod.ts
. Any exports not included in
this file are deemed internal and any modifications will not be treated as
breaking changes. As such, internal exports should be treated as unstable and
used at your own risk.
You need a recent version of deno
before getting started.
If you make changes to this repo, or just want to make sure things are working as desired, you can run:
deno test
To get a full test coverage report in a nice HTML format, run:
deno test --coverage && deno coverage ./coverage --html
New tags are immediately available on deno.land (using a webhook in the repo settings).
To package for NPM, run:
deno run -A scripts/publish_latest_tag_to_npm.ts
We welcome contributions from everyone! Please submit your PR, report your issue, or simply raise a question directly here in Github to get in touch, we'd love to hear from you. To get in contact with our support team, or for other inquiries, please visit our Contact page