AW-1805 Update mollie service (client)
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Peter Bastiani 2021-01-13 16:40:35 +01:00
parent cc421742df
commit a08eed7c67
3 changed files with 25 additions and 12 deletions

View File

@ -0,0 +1,16 @@
import { IItem } from "./item";
export interface IMolliePaymentRequest {
templatePackageItem?: IItem,
redirectUrl?: string,
locale?: string,
}
export class MolliePaymentRequest implements IMolliePaymentRequest {
public templatePackageItem?: IItem;
public redirectUrl?: string;
public locale?: string;
constructor() {
}
}

View File

@ -2,12 +2,16 @@
export interface IMolliePaymentResponse { export interface IMolliePaymentResponse {
createdAt?: Date, createdAt?: Date,
expiresAt?: Date, expiresAt?: Date,
currency?: string,
amount?: string,
checkoutUrl?: string, checkoutUrl?: string,
} }
export class MolliePaymentResponse implements IMolliePaymentResponse { export class MolliePaymentResponse implements IMolliePaymentResponse {
public createdAt?: Date; public createdAt?: Date;
public expiresAt?: Date; public expiresAt?: Date;
public currency?: string;
public amount?: string;
public checkoutUrl?: string; public checkoutUrl?: string;
constructor() { constructor() {

View File

@ -1,10 +1,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { IItem } from '../models/item';
import { IItemTask } from '../models/itemTask';
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
import { AppConfig } from "../shared/app.config"; import { AppConfig } from "../shared/app.config";
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { IMolliePaymentResponse } from '../models/mollie.payment.response'; import { IMolliePaymentResponse } from '../models/mollie.payment.response';
import { IMolliePaymentRequest } from '../models/mollie.payment.request';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -20,15 +19,9 @@ export class MollieService {
return this.appConfig.getConfig("apiEndPoint"); return this.appConfig.getConfig("apiEndPoint");
} }
createMolliePayment(templatePackage: IItem, redirectUrl: string): Observable<IMolliePaymentResponse> { createMolliePayment(paymentRequest: IMolliePaymentRequest): Observable<IMolliePaymentResponse> {
let payload = { return this.httpClient.post<IMolliePaymentResponse>(
"currency": "EUR", `${this.ApiEndpoint()}/api/v1/payments/create`,
"amount": "100.00", paymentRequest);
"redirectUrl": redirectUrl,
"itemCode": templatePackage.code,
"locale": "nl_NL",
"validity": templatePackage.data?.validity
};
return this.httpClient.post<IMolliePaymentResponse>(`${this.ApiEndpoint()}/api/v1/payments/create`, payload);
} }
} }