Giter VIP home page Giter VIP logo

deno-sdk's Introduction

Vipps Mobilepay SDK

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",
});

General documentation and code samples

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/.

Importing types from the SDK

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.

Working on the code base

You need a recent version of deno before getting started.

Running tests

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

Packaging

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

Getting help

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

deno-sdk's People

Contributors

tomas-zijdemans-vipps avatar rebekaburnett avatar flinkgutt avatar matsjohans avatar

Stargazers

Thomas Lekanger avatar Jakob Hoeg MΓΈrk avatar Meet Dave avatar sommeeeR avatar lasse avatar Marko Jovanov avatar Alex Calugari avatar Hans Petter Wilhelmsen avatar  avatar

Watchers

Mikko Pesari avatar Edvard Gjessing Bakken avatar  avatar sommeeeR avatar

deno-sdk's Issues

Can't build in Node-based project in 1.3.4

Describe the bug
When building a project with @vippsmobilepay/sdk as a dependency, it fails with this error:

./node_modules/@vippsmobilepay/sdk/esm/errors.js
Module not found: Can't resolve '@std/async'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/@vippsmobilepay/sdk/esm/base_client.js
./node_modules/@vippsmobilepay/sdk/esm/mod.js

I downgraded from 1.3.4 to 1.3.1 and was able to build without issue.

To Reproduce

  1. Create a NextJS project
  2. Install @vippsmobilepay/sdk
  3. Run yarn build
  4. Observe failing build
  5. Reinstall downgraded version with yarn add @vippsmobilepay/[email protected]
  6. Observe successful build

Expected behavior
The build should not fail

Desktop (please complete the following information):

  • OS: Arch Linux, also fails in Vercel
  • Browser: N/A
  • Version N/A

Additional context
I see recent commits regarding dependency management updates, but not sure if it is relevant.

Checkout API gone from v2?

Removed all unused APIs (based on internal monitoring) for now, they were starting to get outdated. Please open an Issue (or send a PR) if you wish to use an API that is not supported in the future.

We are currently building a store to be launched in october, using the checkout API. As described here: https://developer.vippsmobilepay.com/docs/APIs/checkout-api/checkout-api-guide/

When updating from 1.3.4 to 2.0.0 client.checkout.create() doesn't work. Is there another way to get the checkout session for the frontend JS using the SDK? I could always do a fetch call to the api, but it was nice to have it in the SDK.

EPaymentPaymentEventOKResponse should not be an array

Describe the bug

EPaymentPaymentEventOKResponse is wrongfully typed as an array of events.

If it is only intended for Payment Event History Response as commented in code, SDK should define a PaymentEvent object and EPaymentPaymentEventOKResponse should have an array of this object.

TL:DR; Missing PaymentEvent object

Expected behavior

Based on this documentation: https://developer.vippsmobilepay.com/docs/APIs/epayment-api/features/webhooks/

As a developer I expect to receive an object representing an event on my endpoint.
EPaymentPaymentEventOkResponse is wrongfully typed or SDK is missing an object for webhook events.

Expose /script/types.d.ts

Is your feature request related to a problem? Please describe.
Hey, I'd like to be able to customise errors in ClientResponses, but the "SDKError" type is not resolvable by any other module format than "node".

Describe the solution you'd like
Would you consider exposing /script/types.d.ts

Describe alternatives you've considered
Currently I'm able to reach the type with a path alias.

Thank You!

Not able to retrieve token after upgrading from 0.7.0 to 1.0.0 or newer

Describe the bug

😟 Error retrieving token 😟
{
ok: false,
error: {
error: 'invalid_scope',
error_description: "AADSTS70011: The provided request must include a 'scope' input parameter. The provided value for the input parameter 'scope' is not valid. The scope [object Object]/.default is not valid. Trace ID: cc6bae79-9dae-451a-9dde-a4dedf775100 Correlation ID: d6b89cfd-2658-47b9-a184-10e950bf083f Timestamp: 2024-03-07 09:49:08Z",
error_codes: [ 70011 ],
timestamp: '2024-03-07 09:49:08Z',
trace_id: 'cc6bae79-9dae-451a-9dde-a4dedf775100',
correlation_id: 'd6b89cfd-2658-47b9-a184-10e950bf083f'
}
}

To Reproduce Steps to reproduce the behavior:

Use the sample code in sample_code/recurring_agreement_sample.ts

Expected behavior
Work as before

Type EPaymentGetPaymentOKResponse missing property metadata

According to Vipps ePayment API specs the object GetPaymentResponse should have the property metadata.
During migration from vipps-sdk we discovered that this property is no longer available in this new SDK.

Could this be corrected? As we are using this to add metadata required by our eCommerce solution.

ReferenceError: crypto is not defined

I got ReferenceError: crypto is not defined when using the client on Node 18 in AWS Lambda.

It can be fixed in your code with the line global.crypto = require("node:crypto");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.