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