Skip to content

Commit

Permalink
update samples (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-zijdemans-vipps authored Jan 15, 2024
1 parent 40e7f90 commit add4b27
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 25 deletions.
4 changes: 2 additions & 2 deletions sample_code/callbackQR_sample.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "https://deno.land/std@0.210.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.5.2/mod.ts";
import "https://deno.land/std@0.212.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.7.0/mod.ts";

// First, get your API keys from https://portal.vipps.no/
// Here we assume they are stored in a .env file, see .env.example
Expand Down
4 changes: 2 additions & 2 deletions sample_code/checkout_sample.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "https://deno.land/std@0.210.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.5.2/mod.ts";
import "https://deno.land/std@0.212.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.7.0/mod.ts";

// First, get your API keys from https://portal.vipps.no/
// Here we assume they are stored in a .env file, see .env.example
Expand Down
4 changes: 2 additions & 2 deletions sample_code/epayment_sample.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { open } from "https://deno.land/x/open@v0.0.6/index.ts";
import "https://deno.land/std@0.210.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.5.2/mod.ts";
import "https://deno.land/std@0.212.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.7.0/mod.ts";

// First, get your API keys from https://portal.vipps.no/
// Here we assume they are stored in a .env file, see .env.example
Expand Down
4 changes: 2 additions & 2 deletions sample_code/login_sample.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import "https://deno.land/std@0.210.0/dotenv/load.ts";
import "https://deno.land/std@0.212.0/dotenv/load.ts";
import {
Client,
LoginAuthQueryParams,
} from "https://deno.land/x/vipps_mobilepay_sdk@0.5.2/mod.ts";
} from "https://deno.land/x/vipps_mobilepay_sdk@0.7.0/mod.ts";
import { open } from "https://deno.land/x/open@v0.0.6/index.ts";

// First, get your API keys from https://portal.vipps.no/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "https://deno.land/std@0.210.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.5.2/mod.ts";
import "https://deno.land/std@0.212.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.7.0/mod.ts";

// First, get your API keys from https://portal.vipps.no/
// Here we assume they are stored in a .env file, see .env.example
Expand Down Expand Up @@ -35,7 +35,7 @@ if (!accessToken.ok) {

const token = accessToken.data.access_token;

const agreement = await client.agreement.create(token, {
const agreement = await client.recurring.agreement.create(token, {
pricing: {
type: "LEGACY",
amount: 2500,
Expand All @@ -58,7 +58,7 @@ if (!agreement.ok) {
Deno.exit(1);
}

const agreementInfo = await client.agreement.info(
const agreementInfo = await client.recurring.agreement.info(
token,
agreement.data.agreementId,
);
Expand All @@ -70,7 +70,7 @@ if (!agreementInfo.ok) {
Deno.exit(1);
}

const activatedAgreement = await client.agreement.forceAccept(
const activatedAgreement = await client.recurring.agreement.forceAccept(
token,
agreement.data.agreementId,
{
Expand All @@ -85,7 +85,7 @@ if (!activatedAgreement.ok) {
Deno.exit(1);
}

const updatedAgreement = await client.agreement.update(
const updatedAgreement = await client.recurring.agreement.update(
token,
agreement.data.agreementId,
{ status: "STOPPED" },
Expand All @@ -98,7 +98,11 @@ if (!updatedAgreement.ok) {
Deno.exit(1);
}

const listAgreements = await client.agreement.list(token, "STOPPED", 1);
const listAgreements = await client.recurring.agreement.list(
token,
"STOPPED",
1,
);

// Check if the agreements was retrieved successfully
if (!listAgreements.ok) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "https://deno.land/std@0.210.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.5.2/mod.ts";
import "https://deno.land/std@0.212.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.7.0/mod.ts";

// First, get your API keys from https://portal.vipps.no/
// Here we assume they are stored in a .env file, see .env.example
Expand Down Expand Up @@ -35,7 +35,7 @@ if (!accessToken.ok) {

const token = accessToken.data.access_token;

const agreement = await client.agreement.create(token, {
const agreement = await client.recurring.agreement.create(token, {
pricing: {
type: "LEGACY",
amount: 2500,
Expand All @@ -60,7 +60,7 @@ if (!agreement.ok) {

const agreementId = agreement.data.agreementId;

const acceptedAgreement = await client.agreement.forceAccept(
const acceptedAgreement = await client.recurring.agreement.forceAccept(
token,
agreementId,
{ phoneNumber: customerPhoneNumber },
Expand All @@ -77,7 +77,7 @@ if (!acceptedAgreement.ok) {
const tenDaysFromToday = new Date(Date.now() + 10 * 24 * 60 * 60 * 1000)
.toISOString().split("T")[0];

const charge = await client.charge.create(token, agreementId, {
const charge = await client.recurring.charge.create(token, agreementId, {
amount: 2500,
description: "MyNews Digital",
orderId: crypto.randomUUID(),
Expand All @@ -95,7 +95,11 @@ if (!charge.ok) {

const chargeId = charge.data.chargeId;

const chargeInfo = await client.charge.info(token, agreementId, chargeId);
const chargeInfo = await client.recurring.charge.info(
token,
agreementId,
chargeId,
);

// Check if the charge info was fetched successfully
if (!chargeInfo.ok) {
Expand Down
4 changes: 2 additions & 2 deletions sample_code/redirectQR_sample.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "https://deno.land/std@0.210.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.5.2/mod.ts";
import "https://deno.land/std@0.212.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.7.0/mod.ts";

// First, get your API keys from https://portal.vipps.no/
// Here we assume they are stored in a .env file, see .env.example
Expand Down
4 changes: 2 additions & 2 deletions sample_code/webhook_sample.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "https://deno.land/std@0.210.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.5.2/mod.ts";
import "https://deno.land/std@0.212.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@0.7.0/mod.ts";

// First, get your API keys from https://portal.vipps.no/
// Here we assume they are stored in a .env file, see .env.example
Expand Down

0 comments on commit add4b27

Please sign in to comment.