Vipps Donations #33

Merged
olaven merged 18 commits from vipps-demo into main 2024-08-24 16:55:08 +00:00
3 changed files with 8 additions and 1 deletions
Showing only changes of commit 127758dc44 - Show all commits

View File

@ -49,6 +49,7 @@ export const DonationSection = function () {
}
}}
>
{/* @ts-ignore */}
<vipps-mobilepay-button
type="submit"
brand="vipps"
@ -60,6 +61,7 @@ export const DonationSection = function () {
branded="true"
loading="false"
>
{/* @ts-ignore */}
</vipps-mobilepay-button>
</a>
valid: {emailValid.toString()}

View File

@ -1,3 +1,4 @@
// deno-lint-ignore-file ban-ts-comment
import "jsr:@std/dotenv/load";
import { getHostUrl } from "../utils.ts";
import { STATUS_CODE } from "$fresh/server.ts";
@ -30,6 +31,7 @@ const getAccessToken = async function () {
console.log(`Fetching ${`${config.baseUrl}/accesstoken/get`}`);
const response = await fetch(`${config.baseUrl}/accesstoken/get`, {
method: "POST",
// @ts-ignore
headers: {
"client_id": config.clientId,
"client_secret": config.clientSecret,
@ -45,6 +47,7 @@ export const createAgreement = async function (email: string) {
const token = await getAccessToken();
const response = await fetch(`${config.baseUrl}/recurring/v3/agreements/`, {
method: "POST",
// @ts-ignore
headers: {
authorization: `Bearer ${token}`,
"Idempotency-Key": `${email}-${Date.now()}`,
@ -83,6 +86,7 @@ export const createAgreement = async function (email: string) {
export const getAgreement = async function (agreementId: string) {
const token = await getAccessToken();
const response = await fetch(`${config.baseUrl}/recurring/v3/agreements/${agreementId}`, {
// @ts-ignore
headers: {
authorization: `Bearer ${token}`,
...standardVippsHeaders,
@ -102,6 +106,7 @@ export const cancelAgreement = async function (agreementId: string) {
const token = await getAccessToken();
const response = await fetch(`${config.baseUrl}/recurring/v3/agreements/${agreementId}`, {
method: "PATCH",
// @ts-ignore
headers: {
authorization: `Bearer ${token}`,
"Idempotency-Key": `${agreementId}-${Date.now()}`,

View File

@ -6,7 +6,7 @@ import * as vipps from "../lib/vipps/vipps.ts";
import { validateEmail } from "../lib/utils.ts";
type Props = {
email: string;
email: string | null;
error: string | null;
cancelled: boolean;
};