From 30dab684685138b198bbf43f2473e40866149c01 Mon Sep 17 00:00:00 2001 From: Peter Bastiani Date: Mon, 11 Jan 2021 19:32:08 +0100 Subject: [PATCH] AW-1805 Add mollie service --- .../common/src/fm/common-service.module.ts | 4 ++- .../src/fm/models/mollie.payment.response.ts | 15 ++++++++ .../common/src/fm/services/mollie.service.ts | 34 +++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 projects/common/src/fm/models/mollie.payment.response.ts create mode 100644 projects/common/src/fm/services/mollie.service.ts diff --git a/projects/common/src/fm/common-service.module.ts b/projects/common/src/fm/common-service.module.ts index 7a340be..78f4827 100644 --- a/projects/common/src/fm/common-service.module.ts +++ b/projects/common/src/fm/common-service.module.ts @@ -31,6 +31,7 @@ import { StateSerializerService } from './services/state-serializer.service'; import { PackageService } from './services/package.service'; import { PackagePreloadStrategy } from './services/package-preload-strategy.service'; import { SenmlService } from './services/senml-service'; +import { MollieService } from './services/mollie.service'; export { FolderService, @@ -53,7 +54,8 @@ export { SchemaService, PackageService, SenmlService, - PackagePreloadStrategy + PackagePreloadStrategy, + MollieService }; @NgModule({ diff --git a/projects/common/src/fm/models/mollie.payment.response.ts b/projects/common/src/fm/models/mollie.payment.response.ts new file mode 100644 index 0000000..e9865e0 --- /dev/null +++ b/projects/common/src/fm/models/mollie.payment.response.ts @@ -0,0 +1,15 @@ + +export interface IMolliePaymentResponse { + createdAt?: Date, + expiresAt?: Date, + checkoutUrl?: string, + } + + export class MolliePaymentResponse implements IMolliePaymentResponse { + public createdAt?: Date; + public expiresAt?: Date; + public checkoutUrl?: string; + + constructor() { + } + } \ No newline at end of file diff --git a/projects/common/src/fm/services/mollie.service.ts b/projects/common/src/fm/services/mollie.service.ts new file mode 100644 index 0000000..457fb68 --- /dev/null +++ b/projects/common/src/fm/services/mollie.service.ts @@ -0,0 +1,34 @@ +import { Injectable } from '@angular/core'; +import { IItem } from '../models/item'; +import { IItemTask } from '../models/itemTask'; +import { HttpClient } from "@angular/common/http"; +import { AppConfig } from "../shared/app.config"; +import { Observable } from 'rxjs'; +import { IMolliePaymentResponse } from '../models/mollie.payment.response'; + +@Injectable({ + providedIn: 'root', +}) + +export class MollieService { + constructor( + public httpClient: HttpClient, + public appConfig: AppConfig) { + } + + ApiEndpoint() { + return this.appConfig.getConfig("apiEndPoint"); + } + + createMolliePayment(templatePackage: IItem, redirectUrl: string): Observable { + let payload = { + "currency": "EUR", + "amount": "100.00", + "redirectUrl": redirectUrl, + "itemCode": templatePackage.code, + "locale": "nl_NL", + "validity": "12m" + }; + return this.httpClient.post(`${this.ApiEndpoint()}/api/v1/items/create`, payload); + } +} \ No newline at end of file