Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update types feb 24 #46

Merged
merged 7 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.214.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.1.0/mod.ts";
import "https://deno.land/std@0.217.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.2.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.214.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.1.0/mod.ts";
import "https://deno.land/std@0.217.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.2.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.214.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.1.0/mod.ts";
import "https://deno.land/std@0.217.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.2.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.214.0/dotenv/load.ts";
import "https://deno.land/std@0.217.0/dotenv/load.ts";
import {
Client,
LoginAuthQueryParams,
} from "https://deno.land/x/vipps_mobilepay_sdk@1.1.0/mod.ts";
} from "https://deno.land/x/vipps_mobilepay_sdk@1.2.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
4 changes: 2 additions & 2 deletions sample_code/order_management_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.214.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.1.0/mod.ts";
import "https://deno.land/std@0.217.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.2.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/recurring_agreement_sample.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "https://deno.land/std@0.214.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.1.0/mod.ts";
import "https://deno.land/std@0.217.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.2.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
5 changes: 3 additions & 2 deletions sample_code/recurring_charge_sample.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "https://deno.land/std@0.214.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.1.0/mod.ts";
import "https://deno.land/std@0.217.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.2.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 @@ -80,6 +80,7 @@ const charge = await client.recurring.charge.create(token, agreementId, {
due: tenDaysFromToday,
retryDays: 5,
transactionType: "DIRECT_CAPTURE",
type: "RECURRING",
});

// Check if the charge was created successfully
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.214.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.1.0/mod.ts";
import "https://deno.land/std@0.217.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.2.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/user_sample.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "https://deno.land/std@0.214.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.1.0/mod.ts";
import "https://deno.land/std@0.217.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.2.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.214.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.1.0/mod.ts";
import "https://deno.land/std@0.217.0/dotenv/load.ts";
import { Client } from "https://deno.land/x/vipps_mobilepay_sdk@1.2.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
10 changes: 5 additions & 5 deletions scripts/script_deps.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export {
greaterThan,
parse,
} from "https://deno.land/std@0.214.0/semver/mod.ts";
export { Spinner } from "https://deno.land/std@0.214.0/cli/mod.ts";
export * as colors from "https://deno.land/std@0.214.0/fmt/colors.ts";
export { delay } from "https://deno.land/std@0.214.0/async/delay.ts";
} from "https://deno.land/std@0.217.0/semver/mod.ts";
export { Spinner } from "https://deno.land/std@0.217.0/cli/mod.ts";
export * as colors from "https://deno.land/std@0.217.0/fmt/colors.ts";
export { delay } from "https://deno.land/std@0.217.0/async/delay.ts";

export { build, emptyDir } from "https://deno.land/x/dnt@0.39.0/mod.ts";
export { build, emptyDir } from "https://deno.land/x/dnt@0.40.0/mod.ts";
12 changes: 1 addition & 11 deletions src/apis/checkout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { uuid } from "../deps.ts";
import { RequestData } from "../types.ts";
import {
CheckoutErrorResponse,
Expand Down Expand Up @@ -29,19 +28,10 @@ export const checkoutRequestFactory = {
client_secret: string,
body: CheckoutInitiateSessionRequest,
): RequestData<CheckoutInitiateSessionOKResponse, CheckoutErrorResponse> => {
const newBody = { ...body };
// Fill in missing props
if (!body.transaction.reference) {
newBody.transaction.reference = uuid.generate();
}
if (!body.merchantInfo.callbackAuthorizationToken) {
newBody.merchantInfo.callbackAuthorizationToken = uuid.generate();
}

return {
url: "/checkout/v3/session",
method: "POST",
body: newBody,
body,
additionalHeaders: {
client_id,
client_secret,
Expand Down
3 changes: 0 additions & 3 deletions src/apis/qr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ export const callbackQRRequestFactory = {
};
},
/**
* NOTE: This endpoint is only intended for MobilePay PoS customers.
* It will be removed in the future.
*
* This endpoint is for migrating existing MobilePay PoS QR codes from the
* current solution that will end its lifetime. It is meant for merchants
* that have printed QR codes and want them to stay functional for the new
Expand Down
75 changes: 49 additions & 26 deletions src/apis/recurring.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { RequestData } from "../types.ts";
import {
AgreementForceAcceptV3Request,
AgreementPatchV3Request,
AgreementResponseV3,
AgreementStatus,
ChargeModificationRequest,
ChargeReference,
ChargeResponseV3,
ChargeStatus,
CreateChargeV3Request,
DraftAgreementResponseV3,
DraftAgreementV3Request,
RecurringAgreementResponseV3,
RecurringAsyncChargeResponse,
RecurringChargeReference,
RecurringChargeResponseV3,
RecurringChargeStatus,
RecurringCreateChargeAsyncV3,
RecurringCreateChargeV3,
RecurringDraftAgreementResponseV3,
RecurringDraftAgreementV3,
RecurringErrorResponse,
RecurringForceAcceptAgreementV3,
RecurringPatchAgreementV3,
RecurringRefundRequest,
RecurringStatus,
} from "./types/recurring_types.ts";

/**
Expand Down Expand Up @@ -40,8 +42,8 @@ export const agreementRequestFactory = {
*/
create: (
token: string,
body: DraftAgreementV3Request,
): RequestData<DraftAgreementResponseV3, RecurringErrorResponse> => {
body: RecurringDraftAgreementV3,
): RequestData<RecurringDraftAgreementResponseV3, RecurringErrorResponse> => {
return {
url: "/recurring/v3/agreements",
method: "POST",
Expand All @@ -62,9 +64,9 @@ export const agreementRequestFactory = {
*/
list: (
token: string,
status: AgreementStatus,
status: RecurringStatus,
createdAfter: number,
): RequestData<AgreementResponseV3, RecurringErrorResponse> => {
): RequestData<RecurringAgreementResponseV3, RecurringErrorResponse> => {
return {
url:
`/recurring/v3/agreements?status=${status}&createdAfter=${createdAfter}`,
Expand All @@ -83,7 +85,7 @@ export const agreementRequestFactory = {
info: (
token: string,
agreementId: string,
): RequestData<AgreementResponseV3, RecurringErrorResponse> => {
): RequestData<RecurringAgreementResponseV3, RecurringErrorResponse> => {
return {
url: `/recurring/v3/agreements/${agreementId}`,
method: "GET",
Expand All @@ -103,7 +105,7 @@ export const agreementRequestFactory = {
update: (
token: string,
agreementId: string,
body: AgreementPatchV3Request,
body: RecurringPatchAgreementV3,
): RequestData<void, RecurringErrorResponse> => {
return {
url: `/recurring/v3/agreements/${agreementId}`,
Expand All @@ -124,7 +126,7 @@ export const agreementRequestFactory = {
forceAccept: (
token: string,
agreementId: string,
body: AgreementForceAcceptV3Request,
body: RecurringForceAcceptAgreementV3,
): RequestData<void, RecurringErrorResponse> => {
return {
url: `/recurring/v3/agreements/${agreementId}/accept`,
Expand Down Expand Up @@ -152,15 +154,36 @@ export const chargeRequestFactory = {
create: (
token: string,
agreementId: string,
body: CreateChargeV3Request,
): RequestData<ChargeReference, RecurringErrorResponse> => {
body: RecurringCreateChargeV3,
): RequestData<RecurringChargeReference, RecurringErrorResponse> => {
return {
url: `/recurring/v3/agreements/${agreementId}/charges`,
method: "POST",
body,
token,
};
},
/**
* Asynchronously creates multiple new recurring charges (payments) that
* will be automatically processed on the due date. If the payment fails,
* the charge will be retried based on retryDays
*
* @param token - The authentication token.
* @param body - The request body containing the charge details.
* @returns An array of `RecurringAsyncChargeResponse` objects,
* or a `RecurringErrorResponse` object.
*/
createMultiple: (
token: string,
body: RecurringCreateChargeAsyncV3[],
): RequestData<RecurringAsyncChargeResponse[], RecurringErrorResponse> => {
return {
url: `/recurring/v3/agreements/charges`,
method: "POST",
body,
token,
};
},
/**
* Fetches a single charge for a user.
*
Expand All @@ -173,7 +196,7 @@ export const chargeRequestFactory = {
token: string,
agreementId: string,
chargeId: string,
): RequestData<ChargeResponseV3, RecurringErrorResponse> => {
): RequestData<RecurringChargeResponseV3, RecurringErrorResponse> => {
return {
url: `/recurring/v3/agreements/${agreementId}/charges/${chargeId}`,
method: "GET",
Expand All @@ -196,7 +219,7 @@ export const chargeRequestFactory = {
infoById: (
token: string,
chargeId: string,
): RequestData<ChargeResponseV3, RecurringErrorResponse> => {
): RequestData<RecurringChargeResponseV3, RecurringErrorResponse> => {
return {
url: `/recurring/v3/agreements/charges/${chargeId}`,
method: "GET",
Expand All @@ -215,8 +238,8 @@ export const chargeRequestFactory = {
list: (
token: string,
agreementId: string,
status?: ChargeStatus,
): RequestData<ChargeResponseV3[], RecurringErrorResponse> => {
status?: RecurringChargeStatus,
): RequestData<RecurringChargeResponseV3[], RecurringErrorResponse> => {
const url = status
? `/recurring/v3/agreements/${agreementId}/charges?status=${status}`
: `/recurring/v3/agreements/${agreementId}/charges`;
Expand Down Expand Up @@ -262,7 +285,7 @@ export const chargeRequestFactory = {
token: string,
agreementId: string,
chargeId: string,
body: ChargeModificationRequest,
body: RecurringRefundRequest,
): RequestData<void, RecurringErrorResponse> => {
return {
url:
Expand All @@ -286,7 +309,7 @@ export const chargeRequestFactory = {
token: string,
agreementId: string,
chargeId: string,
body: ChargeModificationRequest,
body: RecurringRefundRequest,
): RequestData<void, RecurringErrorResponse> => {
return {
url: `/recurring/v3/agreements/${agreementId}/charges/${chargeId}/refund`,
Expand Down
13 changes: 13 additions & 0 deletions src/apis/types/all_external_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Export all API types, for convenience. All exported types are
* prefixed with the API name, to avoid potential naming conflicts.
*/
export type * from "./auth_types.ts";
export type * from "./checkout_types.ts";
export type * from "./epayment_types.ts";
export type * from "./login_types.ts";
export type * from "./ordermanagement_types.ts";
export type * from "./qr_types.ts";
export type * from "./recurring_types.ts";
export type * from "./user_types.ts";
export type * from "./webhooks_types.ts";
4 changes: 2 additions & 2 deletions src/apis/types/checkout_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export type CheckoutPaymentMerchantInfo = {
*/
returnUrl: string;
/** The token will be supplied by the callback to the merchant as a header. Example: "iOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImllX3FXQ1hoWHh0MXpJ". */
callbackAuthorizationToken?: string;
callbackAuthorizationToken: string;
/** Complete URL to the merchant's terms and conditions. Example: "https://example.com/vipps/termsAndConditions". */
termsAndConditionsUrl?: string | null;
};
Expand Down Expand Up @@ -360,7 +360,7 @@ export type CheckoutPaymentTransaction = {
* @maxLength 50
* @pattern ^[-a-zA-Z0-9]*$
*/
reference?: string;
reference: string;
/**
* Description visible to the customer during payment. Example: "One pair of socks".
* @minLength 3
Expand Down
2 changes: 2 additions & 0 deletions src/apis/types/qr_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export type CallbackQrRequest = {
* A description of where the QR code will be located.
* It will be shown in the app when a user scans the QR code.
* Examples could be ‘Kasse 1’ , ‘Kiosk’ or ‘Platform 3’.
*
* @maxLength 36
*/
locationDescription: string;
};
Expand Down
Loading