-
-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial 'Custom Offline' Provider/Proxy/Method.
This adds a new 'CUSTOM_OFFLINE' provider & proxy with an 'ETRANSFER' method as an example. The next step will be to allow dynamic methods using this single new provider.
- Loading branch information
1 parent
d7c50ad
commit 4e21a69
Showing
22 changed files
with
377 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...ts/public/src/app/payment/custom-offline-payment-proxy/custom-offline-payment-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {SimplePaymentProvider} from '../payment-provider'; | ||
|
||
export class CustomOfflinePaymentProvider extends SimplePaymentProvider { | ||
override get paymentMethodDeferred(): boolean { | ||
return true; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
.../src/app/payment/custom-offline-payment-proxy/custom-offline-payment-proxy.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div *ngIf="matchProxyAndMethod" class="row mt-2 mb-2"> | ||
<div class="col-12"> | ||
<div class="text-body-secondary" translate="reservation-page.payment.custom-offline.description"></div> | ||
</div> | ||
</div> |
47 changes: 47 additions & 0 deletions
47
...ic/src/app/payment/custom-offline-payment-proxy/custom-offline-payment-proxy.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges} from '@angular/core'; | ||
|
||
import {PaymentProvider} from '../payment-provider'; | ||
import {UntypedFormGroup} from '@angular/forms'; | ||
import { CustomOfflinePaymentProvider } from './custom-offline-payment-provider'; | ||
import {PaymentMethod, PaymentProxy} from '../../model/event'; | ||
|
||
@Component({ | ||
selector: 'app-custom-offline-payment-proxy', | ||
templateUrl: './custom-offline-payment-proxy.component.html' | ||
}) | ||
export class CustomOfflinePaymentProxyComponent implements OnChanges { | ||
|
||
@Input() | ||
method?: PaymentMethod; | ||
|
||
@Input() | ||
proxy?: PaymentProxy; | ||
|
||
@Input() | ||
parameters?: {[key: string]: any}; | ||
|
||
@Input() | ||
overviewForm?: UntypedFormGroup; | ||
|
||
@Output() | ||
paymentProvider: EventEmitter<PaymentProvider> = new EventEmitter<PaymentProvider>(); | ||
|
||
private compatibleMethods: PaymentMethod[] | string[] = ['ETRANSFER']; | ||
|
||
constructor() { } | ||
|
||
ngOnChanges(changes: SimpleChanges): void { | ||
if (this.matchProxyAndMethod && changes['method']) { | ||
this.paymentProvider.emit(new CustomOfflinePaymentProvider()); | ||
} | ||
} | ||
|
||
public get matchProxyAndMethod(): boolean { | ||
if (!this.method) { | ||
return false; | ||
} | ||
|
||
return (this.compatibleMethods.includes(this.method)) && this.proxy === 'CUSTOM_OFFLINE'; | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
...s/public/src/app/reservation/custom-offline-payment/custom-offline-payment.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<app-reservation> | ||
|
||
<div class="mb-2 mt-2 center-block" *ngIf="purchaseContext && reservationInfo"> | ||
|
||
<div class="alert alert-warning mt-2 mb-2 text-center"> | ||
<h2 *ngIf="reservationFinalized"><fa-icon [icon]="['fas', 'exclamation-triangle']" a11yRole="presentation"></fa-icon>{{' '}}<span [innerHTML]="'reservation-page-waiting.title' | translate: {'0': reservationInfo.formattedExpirationDate[translate.currentLang]}"></span></h2> | ||
<h2 *ngIf="!reservationFinalized" translate="reservation-page-complete.reservation.finalization-in-progress"></h2> | ||
</div> | ||
|
||
<div class="page-header"> | ||
<h2 translate="reservation-page.title"></h2> | ||
</div> | ||
<app-summary-table [purchaseContext]="purchaseContext" [reservationInfo]="reservationInfo"></app-summary-table> | ||
|
||
<ng-container *ngIf="reservationFinalized"> | ||
|
||
<h4 [innerHTML]="'reservation-page-waiting.required-steps'|translate" class="mt-5"></h4> | ||
<h4>CUSTOM OFFLINE PAYMENTS PAGE</h4> | ||
|
||
<ng-template #basicInstruction> | ||
<li *ngIf="purchaseContext.bankAccountOwner.length > 0" class="mb-2"> | ||
<p class="no-margin-bottom" [innerHTML]="'reservation-page-waiting.required-steps.1.with-bank-account-owner' | translate: {'0': purchaseContext.currency+' '+reservationInfo.orderSummary.totalPrice, '1': purchaseContext.bankAccount}"></p> | ||
<p class="bank-account-owner-info" *ngFor="let ownerLine of purchaseContext.bankAccountOwner">{{ownerLine}}</p> | ||
<p class="no-margin-bottom" [innerHTML]="'reservation-page-waiting.required-steps.1.with-bank-account-owner.2' | translate: {'0': paymentReason}"></p> | ||
</li> | ||
<li *ngIf="purchaseContext.bankAccountOwner.length === 0" class="mb-2" | ||
[innerHTML]="'reservation-page-waiting.required-steps.1' | translate: {'0': purchaseContext.currency+' '+reservationInfo.orderSummary.totalPrice, '1': purchaseContext.bankAccount, '2': paymentReason}"> | ||
</li> | ||
</ng-template> | ||
<ng-container *ngIf="purchaseContext.offlinePaymentConfiguration?.showOnlyBasicInstructions"> | ||
<ul class="mt-3 list-unstyled"> | ||
<ng-container *ngTemplateOutlet="basicInstruction"></ng-container> | ||
</ul> | ||
</ng-container> | ||
<ng-container *ngIf="!purchaseContext.offlinePaymentConfiguration?.showOnlyBasicInstructions"> | ||
<ol class="mt-3"> | ||
<ng-container *ngTemplateOutlet="basicInstruction"></ng-container> | ||
<li class="mb-2" [innerHTML]="'reservation-page-waiting.required-steps.2' | translate: {'0': purchaseContext.organizationEmail, '1': reservationInfo.id}"></li> | ||
<li class="mb-2" [innerHTML]="'reservation-page-waiting.required-steps.3' | translate"></li> | ||
</ol> | ||
</ng-container> | ||
</ng-container> | ||
|
||
|
||
<div class="text-center mt-5"> | ||
<h4 [innerHTML]="'reservation-page-waiting.questions' | translate: {'0': purchaseContext.organizationEmail, '1': reservationInfo.id}"></h4> | ||
</div> | ||
|
||
<div class="text-center text-body-secondary mt-5">{{'reservation-page-complete.order-information' | translate: {'0': reservationId, '1': reservationInfo.firstName + ' ' + reservationInfo.lastName} }}</div> | ||
<hr> | ||
<div class="row d-flex justify-content-between mobile-add-margin-bottom"> | ||
<div class="col-md-5 col-12 order-md-1" *ngIf="invoiceAvailable"> | ||
<a [href]="'/api/v2/public/' + purchaseContextType + '/' + publicIdentifier + '/reservation/' + reservationInfo.id + '/invoice'" class="btn btn-success block-button" target="_blank" translate="reservation-page-complete.download-your-invoice"></a> | ||
</div> | ||
<div class="col-md-5 col-12 order-md-1 text-center" *ngIf="!purchaseContext.invoicingConfiguration.userCanDownloadReceiptOrInvoice"><p translate="reservation-page-waiting.invoice-will-be-sent"></p></div> | ||
<div class="col-md-5 col-12 order-md-0"><a [href]="purchaseContext.websiteUrl" class="btn btn-light block-button" translate="to-event-site"></a></div> | ||
</div> | ||
</div> | ||
|
||
</app-reservation> |
4 changes: 4 additions & 0 deletions
4
...s/public/src/app/reservation/custom-offline-payment/custom-offline-payment.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.bank-account-owner-info { | ||
padding-left: 1em; | ||
margin-bottom: 0; | ||
} |
79 changes: 79 additions & 0 deletions
79
...cts/public/src/app/reservation/custom-offline-payment/custom-offline-payment.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {ReservationService} from '../../shared/reservation.service'; | ||
import {ReservationInfo} from '../../model/reservation-info'; | ||
import {ActivatedRoute} from '@angular/router'; | ||
import {zip} from 'rxjs'; | ||
import {TranslateService} from '@ngx-translate/core'; | ||
import {I18nService} from '../../shared/i18n.service'; | ||
import {AnalyticsService} from '../../shared/analytics.service'; | ||
import {PurchaseContext} from '../../model/purchase-context'; | ||
import {PurchaseContextService, PurchaseContextType} from '../../shared/purchase-context.service'; | ||
import {pollReservationStatus} from '../../shared/util'; | ||
|
||
@Component({ | ||
selector: 'app-custom-offline-payment', | ||
templateUrl: './custom-offline-payment.component.html', | ||
styleUrls: ['./custom-offline-payment.component.scss'] | ||
}) | ||
export class CustomOfflinePaymentComponent implements OnInit { | ||
|
||
reservationInfo?: ReservationInfo; | ||
purchaseContextType?: PurchaseContextType; | ||
publicIdentifier?: string; | ||
reservationId?: string; | ||
paymentReason?: string; | ||
|
||
purchaseContext?: PurchaseContext; | ||
|
||
reservationFinalized?: boolean; | ||
|
||
constructor( | ||
private route: ActivatedRoute, | ||
private reservationService: ReservationService, | ||
public translate: TranslateService, | ||
private i18nService: I18nService, | ||
private analytics: AnalyticsService, | ||
private purchaseContextService: PurchaseContextService) { } | ||
|
||
public ngOnInit(): void { | ||
zip(this.route.data, this.route.params).subscribe(([data, params]) => { | ||
this.purchaseContextType = data['type']; | ||
this.publicIdentifier = params[data['publicIdentifierParameter']]; | ||
this.reservationId = params['reservationId']; | ||
zip( | ||
this.purchaseContextService.getContext(this.purchaseContextType, this.publicIdentifier), | ||
this.reservationService.getReservationInfo(this.reservationId) | ||
).subscribe(([ev, reservationInfo]) => { | ||
console.log("reservationInfo:", reservationInfo); | ||
console.log("purchaseContext:", ev); | ||
this.purchaseContext = ev; | ||
this.reservationInfo = reservationInfo; | ||
|
||
this.paymentReason = `<mark>${this.reservationInfo.shortId}</mark>`; | ||
|
||
this.i18nService.setPageTitle('reservation-page-waiting.header.title', ev); | ||
this.analytics.pageView(ev.analyticsConfiguration); | ||
if (this.reservationInfo.status === 'OFFLINE_FINALIZING') { | ||
this.reservationFinalized = false; | ||
pollReservationStatus(this.reservationId, this.reservationService, res => { | ||
if (res.status === 'DEFERRED_OFFLINE_PAYMENT') { | ||
// redirect to deferred payment. Reload the page | ||
location.reload(); | ||
} | ||
this.reservationInfo = res; | ||
this.reservationFinalized = true; | ||
}); | ||
} else { | ||
this.reservationFinalized = true; | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
get invoiceAvailable(): boolean { | ||
return this.reservationFinalized | ||
&& this.purchaseContext.invoicingConfiguration.userCanDownloadReceiptOrInvoice | ||
&& this.reservationInfo.invoiceNumber !== null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.