@volo/abp.ng.payment 10.0.2 → 10.1.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/volo-abp.ng.payment-admin-config.mjs +13 -6
- package/fesm2022/volo-abp.ng.payment-admin-config.mjs.map +1 -1
- package/fesm2022/volo-abp.ng.payment-admin.mjs +79 -67
- package/fesm2022/volo-abp.ng.payment-admin.mjs.map +1 -1
- package/fesm2022/volo-abp.ng.payment-proxy.mjs +122 -17
- package/fesm2022/volo-abp.ng.payment-proxy.mjs.map +1 -1
- package/fesm2022/volo-abp.ng.payment.mjs +1061 -0
- package/fesm2022/volo-abp.ng.payment.mjs.map +1 -1
- package/package.json +12 -12
- package/{admin/config/index.d.ts → types/volo-abp.ng.payment-admin-config.d.ts} +6 -1
- package/{admin/index.d.ts → types/volo-abp.ng.payment-admin.d.ts} +10 -6
- package/types/volo-abp.ng.payment-proxy.d.ts +214 -0
- package/types/volo-abp.ng.payment.d.ts +230 -0
- package/index.d.ts +0 -2
- package/proxy/index.d.ts +0 -130
|
@@ -1,4 +1,1065 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, inject, DestroyRef, signal, effect, forwardRef, Component, Directive, ChangeDetectionStrategy, InjectionToken, ViewContainerRef, DOCUMENT, PLATFORM_ID, Injector } from '@angular/core';
|
|
3
|
+
import { ActivatedRoute, Router } from '@angular/router';
|
|
4
|
+
import * as i1 from '@angular/forms';
|
|
5
|
+
import { FormsModule, NG_VALUE_ACCESSOR, Validators, ReactiveFormsModule } from '@angular/forms';
|
|
6
|
+
import { PageComponent } from '@abp/ng.components/page';
|
|
7
|
+
import { CardComponent, CardBodyComponent, CardFooterComponent, CardHeaderComponent, CardHeaderDirective, LoadingDirective } from '@abp/ng.theme.shared';
|
|
8
|
+
import { GatewayService, PaymentType, PaymentRequestService } from '@volo/abp.ng.payment/proxy';
|
|
9
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
10
|
+
import { LocalizationPipe, ReplaceableComponentsService, EnvironmentService, ReplaceableRouteContainerComponent, RouterOutletComponent } from '@abp/ng.core';
|
|
11
|
+
import { finalize } from 'rxjs/operators';
|
|
12
|
+
import { FormProp, FormPropData, generateFormFromProps, ExtensibleFormComponent, EXTENSIONS_IDENTIFIER, ExtensionsService, mergeWithDefaultProps } from '@abp/ng.components/extensible';
|
|
13
|
+
import { isPlatformServer, isPlatformBrowser } from '@angular/common';
|
|
14
|
+
import * as i2 from '@ngx-validate/core';
|
|
15
|
+
import { NgxValidateCoreModule } from '@ngx-validate/core';
|
|
16
|
+
import { of } from 'rxjs';
|
|
17
|
+
|
|
18
|
+
class GatewayOptionsComponent {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.paymentType = input(...(ngDevMode ? [undefined, { debugName: "paymentType" }] : []));
|
|
21
|
+
this.gatewayService = inject(GatewayService);
|
|
22
|
+
this.destroyRef = inject(DestroyRef);
|
|
23
|
+
this.gateways = signal([], ...(ngDevMode ? [{ debugName: "gateways" }] : []));
|
|
24
|
+
this.onChange = () => { };
|
|
25
|
+
this.onTouched = () => { };
|
|
26
|
+
effect(() => {
|
|
27
|
+
const type = this.paymentType();
|
|
28
|
+
if (type !== undefined && type !== null) {
|
|
29
|
+
this.loadGateways(type);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
loadGateways(type) {
|
|
34
|
+
const gateway$ = type === PaymentType.Subscription
|
|
35
|
+
? this.gatewayService.getSubscriptionSupportedGateways()
|
|
36
|
+
: this.gatewayService.getGatewayConfiguration();
|
|
37
|
+
gateway$
|
|
38
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
39
|
+
.subscribe(gateways => {
|
|
40
|
+
if (gateways?.length) {
|
|
41
|
+
this.gateways.set(gateways);
|
|
42
|
+
// Auto-select if only one gateway is available
|
|
43
|
+
if (gateways.length === 1 && !this.selectedGateway) {
|
|
44
|
+
this.onGatewayChange(gateways[0].name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
writeValue(value) {
|
|
50
|
+
this.selectedGateway = value;
|
|
51
|
+
}
|
|
52
|
+
registerOnChange(fn) {
|
|
53
|
+
this.onChange = fn;
|
|
54
|
+
}
|
|
55
|
+
registerOnTouched(fn) {
|
|
56
|
+
this.onTouched = fn;
|
|
57
|
+
}
|
|
58
|
+
onGatewayChange(value) {
|
|
59
|
+
this.selectedGateway = value;
|
|
60
|
+
this.onChange(value);
|
|
61
|
+
this.onTouched();
|
|
62
|
+
}
|
|
63
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: GatewayOptionsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
64
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.9", type: GatewayOptionsComponent, isStandalone: true, selector: "abp-gateway-options", inputs: { paymentType: { classPropertyName: "paymentType", publicName: "paymentType", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
65
|
+
{
|
|
66
|
+
provide: NG_VALUE_ACCESSOR,
|
|
67
|
+
useExisting: forwardRef(() => GatewayOptionsComponent),
|
|
68
|
+
multi: true
|
|
69
|
+
}
|
|
70
|
+
], ngImport: i0, template: `
|
|
71
|
+
<div class="list-container d-flex flex-wrap row-gap-2">
|
|
72
|
+
@if (gateways().length === 0) {
|
|
73
|
+
<p>No available gateway found.</p>
|
|
74
|
+
} @else {
|
|
75
|
+
@if (gateways().length > 1) {
|
|
76
|
+
@for (gateway of gateways(); track gateway.name) {
|
|
77
|
+
<div class="form-check form-check-inline">
|
|
78
|
+
<input
|
|
79
|
+
class="form-check-input"
|
|
80
|
+
type="radio"
|
|
81
|
+
name="gateway"
|
|
82
|
+
[id]="gateway.name"
|
|
83
|
+
[value]="gateway.name"
|
|
84
|
+
[(ngModel)]="selectedGateway"
|
|
85
|
+
(ngModelChange)="onGatewayChange($event)">
|
|
86
|
+
<label class="form-check-label" [attr.for]="gateway.name">
|
|
87
|
+
<strong>{{'Payment::PayWithGateway' | abpLocalization:gateway.displayName}}</strong>
|
|
88
|
+
</label>
|
|
89
|
+
</div>
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
</div>
|
|
94
|
+
`, isInline: true, styles: [".list-container{min-height:6rem}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "pipe", type: LocalizationPipe, name: "abpLocalization" }] }); }
|
|
95
|
+
}
|
|
96
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: GatewayOptionsComponent, decorators: [{
|
|
97
|
+
type: Component,
|
|
98
|
+
args: [{ selector: 'abp-gateway-options', template: `
|
|
99
|
+
<div class="list-container d-flex flex-wrap row-gap-2">
|
|
100
|
+
@if (gateways().length === 0) {
|
|
101
|
+
<p>No available gateway found.</p>
|
|
102
|
+
} @else {
|
|
103
|
+
@if (gateways().length > 1) {
|
|
104
|
+
@for (gateway of gateways(); track gateway.name) {
|
|
105
|
+
<div class="form-check form-check-inline">
|
|
106
|
+
<input
|
|
107
|
+
class="form-check-input"
|
|
108
|
+
type="radio"
|
|
109
|
+
name="gateway"
|
|
110
|
+
[id]="gateway.name"
|
|
111
|
+
[value]="gateway.name"
|
|
112
|
+
[(ngModel)]="selectedGateway"
|
|
113
|
+
(ngModelChange)="onGatewayChange($event)">
|
|
114
|
+
<label class="form-check-label" [attr.for]="gateway.name">
|
|
115
|
+
<strong>{{'Payment::PayWithGateway' | abpLocalization:gateway.displayName}}</strong>
|
|
116
|
+
</label>
|
|
117
|
+
</div>
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
</div>
|
|
122
|
+
`, imports: [FormsModule, LocalizationPipe], providers: [
|
|
123
|
+
{
|
|
124
|
+
provide: NG_VALUE_ACCESSOR,
|
|
125
|
+
useExisting: forwardRef(() => GatewayOptionsComponent),
|
|
126
|
+
multi: true
|
|
127
|
+
}
|
|
128
|
+
], styles: [".list-container{min-height:6rem}\n"] }]
|
|
129
|
+
}], ctorParameters: () => [], propDecorators: { paymentType: [{ type: i0.Input, args: [{ isSignal: true, alias: "paymentType", required: false }] }] } });
|
|
130
|
+
|
|
131
|
+
class GatewaysSelectionComponent {
|
|
132
|
+
constructor() {
|
|
133
|
+
this.route = inject(ActivatedRoute);
|
|
134
|
+
this.router = inject(Router);
|
|
135
|
+
this.paymentRequestService = inject(PaymentRequestService);
|
|
136
|
+
this.paymentRequest = signal(null, ...(ngDevMode ? [{ debugName: "paymentRequest" }] : []));
|
|
137
|
+
this.paymentType = signal(null, ...(ngDevMode ? [{ debugName: "paymentType" }] : []));
|
|
138
|
+
}
|
|
139
|
+
ngOnInit() {
|
|
140
|
+
const paymentRequestId = this.route.snapshot.queryParams['paymentRequestId'];
|
|
141
|
+
this.paymentRequestService.get(paymentRequestId).subscribe(paymentRequest => {
|
|
142
|
+
this.paymentRequest.set(paymentRequest);
|
|
143
|
+
const hasSubscription = paymentRequest?.products?.some(p => p.paymentType === PaymentType.Subscription);
|
|
144
|
+
this.paymentType.set(hasSubscription ? PaymentType.Subscription : PaymentType.OneTime);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
redirectToPrepayment() {
|
|
148
|
+
this.router.navigate([`/payment/${this.selectedGateway}/prepayment`], {
|
|
149
|
+
queryParams: {
|
|
150
|
+
paymentRequestId: this.paymentRequest().id,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: GatewaysSelectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
155
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.9", type: GatewaysSelectionComponent, isStandalone: true, selector: "abp-gateway-selection", ngImport: i0, template: "<abp-page>\r\n <div class=\"row\">\r\n <div class=\"col-12 col-md-8 offset-md-2 col-lg-6 offset-lg-3\">\r\n <abp-card>\r\n <abp-card-header>\r\n <h4 class=\"text-center\">Select a Payment Gateway</h4>\r\n </abp-card-header>\r\n <abp-card-body>\r\n <abp-gateway-options [(ngModel)]=\"selectedGateway\" [paymentType]=\"paymentType()\" />\r\n </abp-card-body>\r\n <abp-card-footer>\r\n <div class=\"d-flex flex-column mt-8\">\r\n <button class=\"btn btn-success btn-lg\" [disabled]=\"!selectedGateway || !paymentRequest\" (click)=\"redirectToPrepayment()\">\r\n Continue to Checkout ->\r\n </button>\r\n <p class=\"mt-2 mb-1 text-muted text-center\">\r\n <small><i class=\"fas fa-circle-info\"></i>Next, you will be redirected to the selected payment gateway's website for the transaction\r\n </small>\r\n </p>\r\n </div>\r\n </abp-card-footer>\r\n </abp-card>\r\n </div>\r\n </div>\r\n</abp-page>\r\n", dependencies: [{ kind: "component", type: PageComponent, selector: "abp-page", inputs: ["title", "toolbar", "breadcrumb"] }, { kind: "component", type: CardComponent, selector: "abp-card", inputs: ["cardClass", "cardStyle"] }, { kind: "component", type: GatewayOptionsComponent, selector: "abp-gateway-options", inputs: ["paymentType"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: CardBodyComponent, selector: "abp-card-body", inputs: ["cardBodyClass", "cardBodyStyle"] }, { kind: "component", type: CardFooterComponent, selector: "abp-card-footer", inputs: ["cardFooterStyle", "cardFooterClass"] }, { kind: "component", type: CardHeaderComponent, selector: "abp-card-header", inputs: ["cardHeaderClass", "cardHeaderStyle"] }] }); }
|
|
156
|
+
}
|
|
157
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: GatewaysSelectionComponent, decorators: [{
|
|
158
|
+
type: Component,
|
|
159
|
+
args: [{ selector: 'abp-gateway-selection', imports: [
|
|
160
|
+
PageComponent,
|
|
161
|
+
CardComponent,
|
|
162
|
+
GatewayOptionsComponent,
|
|
163
|
+
FormsModule,
|
|
164
|
+
CardBodyComponent,
|
|
165
|
+
CardFooterComponent,
|
|
166
|
+
CardHeaderComponent
|
|
167
|
+
], template: "<abp-page>\r\n <div class=\"row\">\r\n <div class=\"col-12 col-md-8 offset-md-2 col-lg-6 offset-lg-3\">\r\n <abp-card>\r\n <abp-card-header>\r\n <h4 class=\"text-center\">Select a Payment Gateway</h4>\r\n </abp-card-header>\r\n <abp-card-body>\r\n <abp-gateway-options [(ngModel)]=\"selectedGateway\" [paymentType]=\"paymentType()\" />\r\n </abp-card-body>\r\n <abp-card-footer>\r\n <div class=\"d-flex flex-column mt-8\">\r\n <button class=\"btn btn-success btn-lg\" [disabled]=\"!selectedGateway || !paymentRequest\" (click)=\"redirectToPrepayment()\">\r\n Continue to Checkout ->\r\n </button>\r\n <p class=\"mt-2 mb-1 text-muted text-center\">\r\n <small><i class=\"fas fa-circle-info\"></i>Next, you will be redirected to the selected payment gateway's website for the transaction\r\n </small>\r\n </p>\r\n </div>\r\n </abp-card-footer>\r\n </abp-card>\r\n </div>\r\n </div>\r\n</abp-page>\r\n" }]
|
|
168
|
+
}] });
|
|
169
|
+
|
|
170
|
+
var eGatewaysType;
|
|
171
|
+
(function (eGatewaysType) {
|
|
172
|
+
eGatewaysType["iyzico"] = "iyzico";
|
|
173
|
+
eGatewaysType["payu"] = "payu";
|
|
174
|
+
eGatewaysType["paypal"] = "PayPal";
|
|
175
|
+
eGatewaysType["stripe"] = "stripe";
|
|
176
|
+
eGatewaysType["twoCheckout"] = "two-checkout";
|
|
177
|
+
eGatewaysType["alipay"] = "Alipay";
|
|
178
|
+
})(eGatewaysType || (eGatewaysType = {}));
|
|
179
|
+
|
|
180
|
+
class PostPaymentBaseComponent {
|
|
181
|
+
constructor() {
|
|
182
|
+
this.paymentRequestService = inject(PaymentRequestService);
|
|
183
|
+
this.route = inject(ActivatedRoute);
|
|
184
|
+
this.router = inject(Router);
|
|
185
|
+
this.destroyRef = inject(DestroyRef);
|
|
186
|
+
this.isCompleting = signal(false, ...(ngDevMode ? [{ debugName: "isCompleting" }] : []));
|
|
187
|
+
this.paymentRequest = signal(null, ...(ngDevMode ? [{ debugName: "paymentRequest" }] : []));
|
|
188
|
+
this.errorMessage = signal('', ...(ngDevMode ? [{ debugName: "errorMessage" }] : []));
|
|
189
|
+
}
|
|
190
|
+
ngOnInit() {
|
|
191
|
+
this.completePayment();
|
|
192
|
+
}
|
|
193
|
+
getGatewayName() {
|
|
194
|
+
return this.route.snapshot.params['gateway'];
|
|
195
|
+
}
|
|
196
|
+
extractParameters() {
|
|
197
|
+
return { ...this.route.snapshot.queryParams };
|
|
198
|
+
}
|
|
199
|
+
// hook for pre-completion
|
|
200
|
+
beforePaymentCompletion(gateway, parameters) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
afterPaymentCompletion(paymentRequest) {
|
|
204
|
+
// Add your custom logic that run after payment completion
|
|
205
|
+
}
|
|
206
|
+
getRedirectUrl(paymentRequest) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
onPaymentError(error) {
|
|
210
|
+
console.error('Payment completion failed:', error);
|
|
211
|
+
this.errorMessage = error?.error?.error?.message || error?.message || 'Payment failed';
|
|
212
|
+
}
|
|
213
|
+
shouldSkipCompletion(gateway) {
|
|
214
|
+
// Default implementation - can be overridden
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Main payment completion flow with extension hooks.
|
|
219
|
+
*/
|
|
220
|
+
completePayment() {
|
|
221
|
+
const gateway = this.getGatewayName();
|
|
222
|
+
// Check if this gateway should skip completion
|
|
223
|
+
if (this.shouldSkipCompletion(gateway)) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const parameters = this.extractParameters();
|
|
227
|
+
if (!this.beforePaymentCompletion(gateway, parameters)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
this.isCompleting.set(true);
|
|
231
|
+
this.paymentRequestService
|
|
232
|
+
.complete(gateway, parameters)
|
|
233
|
+
.pipe(takeUntilDestroyed(this.destroyRef), finalize(() => {
|
|
234
|
+
this.isCompleting.set(false);
|
|
235
|
+
}))
|
|
236
|
+
.subscribe({
|
|
237
|
+
next: paymentRequest => {
|
|
238
|
+
this.paymentRequest.set(paymentRequest);
|
|
239
|
+
// Hook: After completion
|
|
240
|
+
this.afterPaymentCompletion(paymentRequest);
|
|
241
|
+
// Handle redirect
|
|
242
|
+
const redirectUrl = this.getRedirectUrl(paymentRequest);
|
|
243
|
+
if (redirectUrl) {
|
|
244
|
+
this.router.navigateByUrl(redirectUrl);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
error: error => {
|
|
248
|
+
this.onPaymentError(error);
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PostPaymentBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
253
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.9", type: PostPaymentBaseComponent, isStandalone: true, ngImport: i0 }); }
|
|
254
|
+
}
|
|
255
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PostPaymentBaseComponent, decorators: [{
|
|
256
|
+
type: Directive,
|
|
257
|
+
args: [{}]
|
|
258
|
+
}] });
|
|
259
|
+
|
|
260
|
+
class PostPaymentComponent extends PostPaymentBaseComponent {
|
|
261
|
+
/**
|
|
262
|
+
* Iyzico uses a POST callback endpoint, and it is handled on the API side, so there is no need to send an on-completion callback from the UI.
|
|
263
|
+
*/
|
|
264
|
+
shouldSkipCompletion(gateway) {
|
|
265
|
+
return gateway === eGatewaysType.iyzico;
|
|
266
|
+
}
|
|
267
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PostPaymentComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
268
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.9", type: PostPaymentComponent, isStandalone: true, selector: "abp-post-payment", usesInheritance: true, ngImport: i0, template: "<abp-page>\r\n <div class=\"row justify-content-center align-items-center\" style=\"min-height: 60vh\">\r\n <div class=\"col-12 col-md-6 col-lg-4\">\r\n <abp-card>\r\n <abp-card-body class=\"text-center py-5\">\r\n <div class=\"mb-4\">\r\n <i class=\"fa fa-check-circle text-success fa-5x\"></i>\r\n </div>\r\n <h2 class=\"h3 mb-0\">Payment Success</h2>\r\n </abp-card-body>\r\n </abp-card>\r\n </div>\r\n </div>\r\n</abp-page>\r\n", dependencies: [{ kind: "component", type: PageComponent, selector: "abp-page", inputs: ["title", "toolbar", "breadcrumb"] }, { kind: "component", type: CardComponent, selector: "abp-card", inputs: ["cardClass", "cardStyle"] }, { kind: "component", type: CardBodyComponent, selector: "abp-card-body", inputs: ["cardBodyClass", "cardBodyStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
269
|
+
}
|
|
270
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PostPaymentComponent, decorators: [{
|
|
271
|
+
type: Component,
|
|
272
|
+
args: [{ selector: 'abp-post-payment', imports: [PageComponent, CardComponent, CardBodyComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<abp-page>\r\n <div class=\"row justify-content-center align-items-center\" style=\"min-height: 60vh\">\r\n <div class=\"col-12 col-md-6 col-lg-4\">\r\n <abp-card>\r\n <abp-card-body class=\"text-center py-5\">\r\n <div class=\"mb-4\">\r\n <i class=\"fa fa-check-circle text-success fa-5x\"></i>\r\n </div>\r\n <h2 class=\"h3 mb-0\">Payment Success</h2>\r\n </abp-card-body>\r\n </abp-card>\r\n </div>\r\n </div>\r\n</abp-page>\r\n" }]
|
|
273
|
+
}] });
|
|
274
|
+
|
|
275
|
+
const { required, email, maxLength } = Validators;
|
|
276
|
+
const DEFAULT_IYZICO_PREPAYMENT_FORM_PROPS = FormProp.createMany([
|
|
277
|
+
{
|
|
278
|
+
type: "string" /* ePropType.String */,
|
|
279
|
+
name: 'name',
|
|
280
|
+
displayName: 'Payment::Name',
|
|
281
|
+
id: 'name',
|
|
282
|
+
validators: () => [required, maxLength(64)],
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
type: "string" /* ePropType.String */,
|
|
286
|
+
name: 'surname',
|
|
287
|
+
displayName: 'Payment::Surname',
|
|
288
|
+
id: 'surname',
|
|
289
|
+
validators: () => [required, maxLength(64)],
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
type: "string" /* ePropType.String */,
|
|
293
|
+
name: 'email',
|
|
294
|
+
displayName: 'Payment::Email',
|
|
295
|
+
id: 'email',
|
|
296
|
+
validators: () => [required, email, maxLength(64)],
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
type: "string" /* ePropType.String */,
|
|
300
|
+
name: 'country',
|
|
301
|
+
displayName: 'Payment::Country',
|
|
302
|
+
id: 'country',
|
|
303
|
+
validators: () => [required, maxLength(64)],
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
type: "string" /* ePropType.String */,
|
|
307
|
+
name: 'city',
|
|
308
|
+
displayName: 'Payment::City',
|
|
309
|
+
id: 'city',
|
|
310
|
+
validators: () => [required, maxLength(64)],
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
type: "string" /* ePropType.String */,
|
|
314
|
+
name: 'zipCode',
|
|
315
|
+
displayName: 'Payment::ZipCode',
|
|
316
|
+
id: 'zipCode',
|
|
317
|
+
validators: () => [required, maxLength(20)],
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
type: "text" /* ePropType.Text */,
|
|
321
|
+
name: 'description',
|
|
322
|
+
displayName: 'Payment::Address',
|
|
323
|
+
id: 'description',
|
|
324
|
+
validators: () => [required, maxLength(500)],
|
|
325
|
+
},
|
|
326
|
+
]);
|
|
327
|
+
|
|
328
|
+
const DEFAULT_PAYMENT_FORM_PROPS = {
|
|
329
|
+
["Payment.Iyzico.PrepaymentForm" /* ePaymentComponents.IyzicoPrepaymentForm */]: DEFAULT_IYZICO_PREPAYMENT_FORM_PROPS,
|
|
330
|
+
};
|
|
331
|
+
const PAYMENT_IYZICO_FORM_PROP_CONTRIBUTORS = new InjectionToken('PAYMENT_IYZICO_FORM_PROP_CONTRIBUTORS');
|
|
332
|
+
/**
|
|
333
|
+
* Default gateway to post-payment component key mapping.
|
|
334
|
+
*/
|
|
335
|
+
const DEFAULT_POST_PAYMENT_COMPONENT_MAP = {
|
|
336
|
+
[eGatewaysType.stripe]: "Payment.Stripe.PostPayment" /* ePaymentComponents.StripePostPayment */,
|
|
337
|
+
[eGatewaysType.paypal]: "Payment.PayPal.PostPayment" /* ePaymentComponents.PayPalPostPayment */,
|
|
338
|
+
[eGatewaysType.payu]: "Payment.Payu.PostPayment" /* ePaymentComponents.PayuPostPayment */,
|
|
339
|
+
[eGatewaysType.iyzico]: "Payment.Iyzico.PostPayment" /* ePaymentComponents.IyzicoPostPayment */,
|
|
340
|
+
[eGatewaysType.twoCheckout]: "Payment.TwoCheckout.PostPayment" /* ePaymentComponents.TwoCheckoutPostPayment */,
|
|
341
|
+
[eGatewaysType.alipay]: "Payment.Alipay.PostPayment" /* ePaymentComponents.AlipayPostPayment */,
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Default gateway to pre-payment component key mapping.
|
|
345
|
+
*/
|
|
346
|
+
const DEFAULT_PRE_PAYMENT_COMPONENT_MAP = {
|
|
347
|
+
[eGatewaysType.stripe]: "Payment.Stripe.PrePayment" /* ePaymentComponents.StripePrePayment */,
|
|
348
|
+
[eGatewaysType.paypal]: "Payment.PayPal.PrePayment" /* ePaymentComponents.PayPalPrePayment */,
|
|
349
|
+
[eGatewaysType.payu]: "Payment.Payu.PrePayment" /* ePaymentComponents.PayuPrePayment */,
|
|
350
|
+
[eGatewaysType.iyzico]: "Payment.Iyzico.PrePayment" /* ePaymentComponents.IyzicoPrePayment */,
|
|
351
|
+
[eGatewaysType.twoCheckout]: "Payment.TwoCheckout.PrePayment" /* ePaymentComponents.TwoCheckoutPrePayment */,
|
|
352
|
+
[eGatewaysType.alipay]: "Payment.Alipay.PrePayment" /* ePaymentComponents.AlipayPrePayment */,
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Helper function to get the component key for a specific gateway's post-payment page.
|
|
357
|
+
*
|
|
358
|
+
* @param gateway The gateway name (e.g., 'stripe', 'paypal')
|
|
359
|
+
* @returns The component key for that gateway, or the generic PostPayment component key if not found
|
|
360
|
+
*/
|
|
361
|
+
function getPostPaymentComponentKey(gateway) {
|
|
362
|
+
return DEFAULT_POST_PAYMENT_COMPONENT_MAP[gateway] || "Payment.PostPayment" /* ePaymentComponents.PostPayment */;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Helper function to register a custom post-payment component for a specific gateway.
|
|
366
|
+
* This is a convenience function that wraps ReplaceableComponentsService.add().
|
|
367
|
+
*
|
|
368
|
+
* @param replaceableComponents The ReplaceableComponentsService instance
|
|
369
|
+
* @param config The configuration object with gateway name and component
|
|
370
|
+
*/
|
|
371
|
+
function registerPostPaymentComponent(replaceableComponents, config) {
|
|
372
|
+
const componentKey = getPostPaymentComponentKey(config.gateway);
|
|
373
|
+
replaceableComponents.add({
|
|
374
|
+
key: componentKey,
|
|
375
|
+
component: config.component,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Helper function to register multiple custom post-payment components at once.
|
|
380
|
+
*
|
|
381
|
+
* @param replaceableComponents The ReplaceableComponentsService instance
|
|
382
|
+
* @param configs Array of configuration objects
|
|
383
|
+
*/
|
|
384
|
+
function registerPostPaymentComponents(replaceableComponents, configs) {
|
|
385
|
+
configs.forEach(config => registerPostPaymentComponent(replaceableComponents, config));
|
|
386
|
+
}
|
|
387
|
+
// ============================================
|
|
388
|
+
// PRE-PAYMENT HELPERS
|
|
389
|
+
// ============================================
|
|
390
|
+
/**
|
|
391
|
+
* Helper function to get the component key for a specific gateway's pre-payment page.
|
|
392
|
+
*
|
|
393
|
+
* @param gateway The gateway name (e.g., 'stripe', 'paypal')
|
|
394
|
+
* @returns The component key for that gateway, or the generic Prepayment component key if not found
|
|
395
|
+
*/
|
|
396
|
+
function getPrePaymentComponentKey(gateway) {
|
|
397
|
+
return DEFAULT_PRE_PAYMENT_COMPONENT_MAP[gateway] || "Payment.Prepayment" /* ePaymentComponents.Prepayment */;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Helper function to register a custom pre-payment component for a specific gateway.
|
|
401
|
+
* This is a convenience function that wraps ReplaceableComponentsService.add().
|
|
402
|
+
*
|
|
403
|
+
* @param replaceableComponents The ReplaceableComponentsService instance
|
|
404
|
+
* @param config The configuration object with gateway name and component
|
|
405
|
+
*/
|
|
406
|
+
function registerPrePaymentComponent(replaceableComponents, config) {
|
|
407
|
+
const componentKey = getPrePaymentComponentKey(config.gateway);
|
|
408
|
+
replaceableComponents.add({
|
|
409
|
+
key: componentKey,
|
|
410
|
+
component: config.component,
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Helper function to register multiple custom pre-payment components at once.
|
|
415
|
+
*
|
|
416
|
+
* @param replaceableComponents The ReplaceableComponentsService instance
|
|
417
|
+
* @param configs Array of configuration objects
|
|
418
|
+
*/
|
|
419
|
+
function registerPrePaymentComponents(replaceableComponents, configs) {
|
|
420
|
+
configs.forEach(config => registerPrePaymentComponent(replaceableComponents, config));
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
class PostPaymentHostComponent {
|
|
424
|
+
constructor() {
|
|
425
|
+
this.viewContainerRef = inject(ViewContainerRef);
|
|
426
|
+
this.route = inject(ActivatedRoute);
|
|
427
|
+
this.replaceableComponents = inject(ReplaceableComponentsService);
|
|
428
|
+
this.componentRef = signal(undefined, ...(ngDevMode ? [{ debugName: "componentRef" }] : []));
|
|
429
|
+
}
|
|
430
|
+
ngOnInit() {
|
|
431
|
+
this.loadPostPaymentComponent();
|
|
432
|
+
}
|
|
433
|
+
loadPostPaymentComponent() {
|
|
434
|
+
// Get gateway from route params
|
|
435
|
+
const gateway = this.route.snapshot.params['gateway'];
|
|
436
|
+
if (!gateway) {
|
|
437
|
+
console.warn('No gateway parameter found in route');
|
|
438
|
+
this.loadDefaultComponent();
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
// Get the component key for this gateway (gateway-specific or generic)
|
|
442
|
+
const componentKey = getPostPaymentComponentKey(gateway);
|
|
443
|
+
// Check if a custom component is registered for this key
|
|
444
|
+
const customComponent = this.replaceableComponents.get(componentKey);
|
|
445
|
+
// Load the component (custom or default)
|
|
446
|
+
const componentToLoad = customComponent?.component || PostPaymentComponent;
|
|
447
|
+
// Clear any existing component
|
|
448
|
+
this.viewContainerRef.clear();
|
|
449
|
+
this.componentRef.set(this.viewContainerRef.createComponent(componentToLoad));
|
|
450
|
+
}
|
|
451
|
+
loadDefaultComponent() {
|
|
452
|
+
this.viewContainerRef.clear();
|
|
453
|
+
this.componentRef.set(this.viewContainerRef.createComponent(PostPaymentComponent));
|
|
454
|
+
}
|
|
455
|
+
ngOnDestroy() {
|
|
456
|
+
if (this.componentRef()) {
|
|
457
|
+
this.componentRef().destroy();
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PostPaymentHostComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
461
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.9", type: PostPaymentHostComponent, isStandalone: true, selector: "abp-post-payment-router", ngImport: i0, template: '', isInline: true }); }
|
|
462
|
+
}
|
|
463
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PostPaymentHostComponent, decorators: [{
|
|
464
|
+
type: Component,
|
|
465
|
+
args: [{
|
|
466
|
+
selector: 'abp-post-payment-router',
|
|
467
|
+
template: '',
|
|
468
|
+
}]
|
|
469
|
+
}] });
|
|
470
|
+
|
|
471
|
+
class PrepaymentProgressComponent {
|
|
472
|
+
constructor() {
|
|
473
|
+
this.gateway = input(...(ngDevMode ? [undefined, { debugName: "gateway" }] : []));
|
|
474
|
+
}
|
|
475
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PrepaymentProgressComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
476
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.9", type: PrepaymentProgressComponent, isStandalone: true, selector: "abp-prepayment-progress", inputs: { gateway: { classPropertyName: "gateway", publicName: "gateway", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
477
|
+
<div class="row justify-content-center align-items-center" style="min-height: 60vh">
|
|
478
|
+
<div class="col-12">
|
|
479
|
+
<abp-card>
|
|
480
|
+
<abp-card-body class="text-center py-5">
|
|
481
|
+
<div class="mb-4">
|
|
482
|
+
<i class="fas fa-arrows-rotate fa-spin text-primary fa-2x"></i>
|
|
483
|
+
</div>
|
|
484
|
+
<h3 class="h5 mb-0 text-muted">
|
|
485
|
+
You are being redirected to <b class="text-dark">{{gateway()}}</b> for payment
|
|
486
|
+
</h3>
|
|
487
|
+
</abp-card-body>
|
|
488
|
+
</abp-card>
|
|
489
|
+
</div>
|
|
490
|
+
</div>
|
|
491
|
+
`, isInline: true, dependencies: [{ kind: "component", type: CardBodyComponent, selector: "abp-card-body", inputs: ["cardBodyClass", "cardBodyStyle"] }, { kind: "component", type: CardComponent, selector: "abp-card", inputs: ["cardClass", "cardStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
492
|
+
}
|
|
493
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PrepaymentProgressComponent, decorators: [{
|
|
494
|
+
type: Component,
|
|
495
|
+
args: [{
|
|
496
|
+
selector: 'abp-prepayment-progress',
|
|
497
|
+
template: `
|
|
498
|
+
<div class="row justify-content-center align-items-center" style="min-height: 60vh">
|
|
499
|
+
<div class="col-12">
|
|
500
|
+
<abp-card>
|
|
501
|
+
<abp-card-body class="text-center py-5">
|
|
502
|
+
<div class="mb-4">
|
|
503
|
+
<i class="fas fa-arrows-rotate fa-spin text-primary fa-2x"></i>
|
|
504
|
+
</div>
|
|
505
|
+
<h3 class="h5 mb-0 text-muted">
|
|
506
|
+
You are being redirected to <b class="text-dark">{{gateway()}}</b> for payment
|
|
507
|
+
</h3>
|
|
508
|
+
</abp-card-body>
|
|
509
|
+
</abp-card>
|
|
510
|
+
</div>
|
|
511
|
+
</div>
|
|
512
|
+
`,
|
|
513
|
+
imports: [CardBodyComponent, CardComponent],
|
|
514
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
515
|
+
}]
|
|
516
|
+
}], propDecorators: { gateway: [{ type: i0.Input, args: [{ isSignal: true, alias: "gateway", required: false }] }] } });
|
|
517
|
+
|
|
518
|
+
class PrePaymentLayoutComponent {
|
|
519
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PrePaymentLayoutComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
520
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.9", type: PrePaymentLayoutComponent, isStandalone: true, selector: "abp-prepayment-layout", ngImport: i0, template: `
|
|
521
|
+
<abp-page>
|
|
522
|
+
<div class="row">
|
|
523
|
+
<div class="col-12 col-md-8 offset-md-2 col-lg-6 offset-lg-3">
|
|
524
|
+
<ng-content />
|
|
525
|
+
</div>
|
|
526
|
+
</div>
|
|
527
|
+
</abp-page>
|
|
528
|
+
`, isInline: true, dependencies: [{ kind: "component", type: PageComponent, selector: "abp-page", inputs: ["title", "toolbar", "breadcrumb"] }] }); }
|
|
529
|
+
}
|
|
530
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PrePaymentLayoutComponent, decorators: [{
|
|
531
|
+
type: Component,
|
|
532
|
+
args: [{
|
|
533
|
+
selector: 'abp-prepayment-layout',
|
|
534
|
+
template: `
|
|
535
|
+
<abp-page>
|
|
536
|
+
<div class="row">
|
|
537
|
+
<div class="col-12 col-md-8 offset-md-2 col-lg-6 offset-lg-3">
|
|
538
|
+
<ng-content />
|
|
539
|
+
</div>
|
|
540
|
+
</div>
|
|
541
|
+
</abp-page>
|
|
542
|
+
`,
|
|
543
|
+
standalone: true,
|
|
544
|
+
imports: [PageComponent],
|
|
545
|
+
}]
|
|
546
|
+
}] });
|
|
547
|
+
|
|
548
|
+
class StripePrepaymentComponent {
|
|
549
|
+
constructor() {
|
|
550
|
+
this.baseUrl = input('', ...(ngDevMode ? [{ debugName: "baseUrl" }] : []));
|
|
551
|
+
this.paymentRequest = input(null, ...(ngDevMode ? [{ debugName: "paymentRequest" }] : []));
|
|
552
|
+
this.gateway = input('', ...(ngDevMode ? [{ debugName: "gateway" }] : []));
|
|
553
|
+
this.prePaymentInProgress = signal(false, ...(ngDevMode ? [{ debugName: "prePaymentInProgress" }] : []));
|
|
554
|
+
this.document = inject(DOCUMENT);
|
|
555
|
+
this.platformId = inject(PLATFORM_ID);
|
|
556
|
+
this.paymentRequestService = inject(PaymentRequestService);
|
|
557
|
+
effect(() => {
|
|
558
|
+
if (this.paymentRequest() && this.gateway()) {
|
|
559
|
+
this.startPayment();
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
startPayment() {
|
|
564
|
+
const paymentStartData = {
|
|
565
|
+
paymentRequestId: this.paymentRequest()?.id,
|
|
566
|
+
returnUrl: `${this.baseUrl()}/payment/stripe/post-payment?SessionId={CHECKOUT_SESSION_ID}`,
|
|
567
|
+
cancelUrl: this.baseUrl(),
|
|
568
|
+
};
|
|
569
|
+
this.prePaymentInProgress.set(true);
|
|
570
|
+
this.paymentRequestService
|
|
571
|
+
.start(this.gateway(), paymentStartData)
|
|
572
|
+
.pipe(finalize(() => {
|
|
573
|
+
this.prePaymentInProgress.set(false);
|
|
574
|
+
}))
|
|
575
|
+
.subscribe({
|
|
576
|
+
next: res => {
|
|
577
|
+
this.redirectToCheckout(res.checkoutLink, res.extraProperties?.PublishableKey, res.extraProperties?.SessionId);
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
redirectToCheckout(checkoutLink, publishableKey, sessionId) {
|
|
582
|
+
if (isPlatformServer(this.platformId)) {
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
if (!this.document.querySelector(`script[src="${checkoutLink}"]`)) {
|
|
586
|
+
const script = document.createElement('script');
|
|
587
|
+
script.src = checkoutLink;
|
|
588
|
+
script.type = 'text/javascript';
|
|
589
|
+
script.async = true;
|
|
590
|
+
script.onload = () => {
|
|
591
|
+
this.initializeStripe(publishableKey, sessionId);
|
|
592
|
+
};
|
|
593
|
+
this.document.head.appendChild(script);
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
this.initializeStripe(publishableKey, sessionId);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
initializeStripe(key, sessionId) {
|
|
600
|
+
if (isPlatformServer(this.platformId)) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
if (this.document.defaultView.Stripe) {
|
|
604
|
+
const stripe = this.document.defaultView.Stripe(key);
|
|
605
|
+
stripe.redirectToCheckout({ sessionId: sessionId }).then((result) => {
|
|
606
|
+
if (result.error) {
|
|
607
|
+
console.error(result.error.message);
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
console.error('Stripe script loaded successfully but window.Stripe object cannot found');
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: StripePrepaymentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
616
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.9", type: StripePrepaymentComponent, isStandalone: true, selector: "abp-stripe-prepayment", inputs: { baseUrl: { classPropertyName: "baseUrl", publicName: "baseUrl", isSignal: true, isRequired: false, transformFunction: null }, paymentRequest: { classPropertyName: "paymentRequest", publicName: "paymentRequest", isSignal: true, isRequired: false, transformFunction: null }, gateway: { classPropertyName: "gateway", publicName: "gateway", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<abp-prepayment-layout>\r\n <abp-prepayment-progress [gateway]=\"gateway()\" />\r\n</abp-prepayment-layout>\r\n\r\n", dependencies: [{ kind: "component", type: PrepaymentProgressComponent, selector: "abp-prepayment-progress", inputs: ["gateway"] }, { kind: "component", type: PrePaymentLayoutComponent, selector: "abp-prepayment-layout" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
617
|
+
}
|
|
618
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: StripePrepaymentComponent, decorators: [{
|
|
619
|
+
type: Component,
|
|
620
|
+
args: [{ selector: 'abp-stripe-prepayment', imports: [PrepaymentProgressComponent, PrePaymentLayoutComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<abp-prepayment-layout>\r\n <abp-prepayment-progress [gateway]=\"gateway()\" />\r\n</abp-prepayment-layout>\r\n\r\n" }]
|
|
621
|
+
}], ctorParameters: () => [], propDecorators: { baseUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseUrl", required: false }] }], paymentRequest: [{ type: i0.Input, args: [{ isSignal: true, alias: "paymentRequest", required: false }] }], gateway: [{ type: i0.Input, args: [{ isSignal: true, alias: "gateway", required: false }] }] } });
|
|
622
|
+
|
|
623
|
+
class PayPalPrepaymentComponent {
|
|
624
|
+
constructor() {
|
|
625
|
+
this.baseUrl = input('', ...(ngDevMode ? [{ debugName: "baseUrl" }] : []));
|
|
626
|
+
this.paymentRequest = input(null, ...(ngDevMode ? [{ debugName: "paymentRequest" }] : []));
|
|
627
|
+
this.gateway = input('', ...(ngDevMode ? [{ debugName: "gateway" }] : []));
|
|
628
|
+
this.prePaymentInProgress = signal(false, ...(ngDevMode ? [{ debugName: "prePaymentInProgress" }] : []));
|
|
629
|
+
this.document = inject(DOCUMENT);
|
|
630
|
+
this.platformId = inject(PLATFORM_ID);
|
|
631
|
+
this.paymentRequestService = inject(PaymentRequestService);
|
|
632
|
+
effect(() => {
|
|
633
|
+
if (this.paymentRequest()?.id && this.gateway()) {
|
|
634
|
+
this.startPayment();
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
startPayment() {
|
|
639
|
+
const paymentStartData = {
|
|
640
|
+
paymentRequestId: this.paymentRequest().id,
|
|
641
|
+
returnUrl: `${this.baseUrl()}/payment/paypal/post-payment?paymentRequestId=${this.paymentRequest().id}`,
|
|
642
|
+
cancelUrl: this.baseUrl(),
|
|
643
|
+
};
|
|
644
|
+
this.prePaymentInProgress.set(true);
|
|
645
|
+
this.paymentRequestService
|
|
646
|
+
.start(this.gateway(), paymentStartData)
|
|
647
|
+
.pipe(finalize(() => {
|
|
648
|
+
this.prePaymentInProgress.set(false);
|
|
649
|
+
}))
|
|
650
|
+
.subscribe({
|
|
651
|
+
next: res => {
|
|
652
|
+
if (res?.checkoutLink && isPlatformBrowser(this.platformId)) {
|
|
653
|
+
this.document.defaultView?.location.replace(res.checkoutLink);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PayPalPrepaymentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
659
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.9", type: PayPalPrepaymentComponent, isStandalone: true, selector: "abp-paypal-prepayment", inputs: { baseUrl: { classPropertyName: "baseUrl", publicName: "baseUrl", isSignal: true, isRequired: false, transformFunction: null }, paymentRequest: { classPropertyName: "paymentRequest", publicName: "paymentRequest", isSignal: true, isRequired: false, transformFunction: null }, gateway: { classPropertyName: "gateway", publicName: "gateway", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<abp-prepayment-layout>\r\n <abp-prepayment-progress [gateway]=\"gateway()\" />\r\n</abp-prepayment-layout>\r\n", dependencies: [{ kind: "component", type: PrepaymentProgressComponent, selector: "abp-prepayment-progress", inputs: ["gateway"] }, { kind: "component", type: PrePaymentLayoutComponent, selector: "abp-prepayment-layout" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
660
|
+
}
|
|
661
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PayPalPrepaymentComponent, decorators: [{
|
|
662
|
+
type: Component,
|
|
663
|
+
args: [{ selector: 'abp-paypal-prepayment', imports: [PrepaymentProgressComponent, PrePaymentLayoutComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<abp-prepayment-layout>\r\n <abp-prepayment-progress [gateway]=\"gateway()\" />\r\n</abp-prepayment-layout>\r\n" }]
|
|
664
|
+
}], ctorParameters: () => [], propDecorators: { baseUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseUrl", required: false }] }], paymentRequest: [{ type: i0.Input, args: [{ isSignal: true, alias: "paymentRequest", required: false }] }], gateway: [{ type: i0.Input, args: [{ isSignal: true, alias: "gateway", required: false }] }] } });
|
|
665
|
+
|
|
666
|
+
class PayuPrepaymentComponent {
|
|
667
|
+
constructor() {
|
|
668
|
+
this.baseUrl = input('', ...(ngDevMode ? [{ debugName: "baseUrl" }] : []));
|
|
669
|
+
this.paymentRequest = input(null, ...(ngDevMode ? [{ debugName: "paymentRequest" }] : []));
|
|
670
|
+
this.gateway = input('', ...(ngDevMode ? [{ debugName: "gateway" }] : []));
|
|
671
|
+
this.prePaymentInProgress = signal(false, ...(ngDevMode ? [{ debugName: "prePaymentInProgress" }] : []));
|
|
672
|
+
this.paymentRequestService = inject(PaymentRequestService);
|
|
673
|
+
this.document = inject(DOCUMENT);
|
|
674
|
+
this.platformId = inject(PLATFORM_ID);
|
|
675
|
+
effect(() => {
|
|
676
|
+
if (this.paymentRequest()?.id && this.gateway()) {
|
|
677
|
+
this.startPayment();
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
startPayment() {
|
|
682
|
+
const paymentStartData = {
|
|
683
|
+
paymentRequestId: this.paymentRequest().id,
|
|
684
|
+
returnUrl: `${this.baseUrl()}/payment/payu/post-payment?paymentRequestId=${this.paymentRequest().id}`,
|
|
685
|
+
cancelUrl: this.baseUrl(),
|
|
686
|
+
};
|
|
687
|
+
this.prePaymentInProgress.set(true);
|
|
688
|
+
this.paymentRequestService
|
|
689
|
+
.start(this.gateway(), paymentStartData)
|
|
690
|
+
.pipe(finalize(() => {
|
|
691
|
+
this.prePaymentInProgress.set(false);
|
|
692
|
+
}))
|
|
693
|
+
.subscribe({
|
|
694
|
+
next: res => {
|
|
695
|
+
this.redirectToCheckout(res.checkoutLink, res.extraProperties);
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
redirectToCheckout(checkoutUrl, extraProperties) {
|
|
700
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
701
|
+
const form = this.document.createElement('form');
|
|
702
|
+
form.method = 'POST';
|
|
703
|
+
form.action = checkoutUrl;
|
|
704
|
+
form.style.display = 'none';
|
|
705
|
+
Object.keys(extraProperties).forEach(key => {
|
|
706
|
+
const input = this.document.createElement('input');
|
|
707
|
+
input.type = 'hidden';
|
|
708
|
+
input.name = key;
|
|
709
|
+
input.value = extraProperties[key];
|
|
710
|
+
form.appendChild(input);
|
|
711
|
+
});
|
|
712
|
+
this.document.body.appendChild(form);
|
|
713
|
+
form.submit();
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PayuPrepaymentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
717
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.9", type: PayuPrepaymentComponent, isStandalone: true, selector: "abp-payu-prepayment", inputs: { baseUrl: { classPropertyName: "baseUrl", publicName: "baseUrl", isSignal: true, isRequired: false, transformFunction: null }, paymentRequest: { classPropertyName: "paymentRequest", publicName: "paymentRequest", isSignal: true, isRequired: false, transformFunction: null }, gateway: { classPropertyName: "gateway", publicName: "gateway", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<abp-prepayment-layout>\r\n <abp-prepayment-progress [gateway]=\"gateway()\" />\r\n</abp-prepayment-layout>\r\n", dependencies: [{ kind: "component", type: PrepaymentProgressComponent, selector: "abp-prepayment-progress", inputs: ["gateway"] }, { kind: "component", type: PrePaymentLayoutComponent, selector: "abp-prepayment-layout" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
718
|
+
}
|
|
719
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PayuPrepaymentComponent, decorators: [{
|
|
720
|
+
type: Component,
|
|
721
|
+
args: [{ selector: 'abp-payu-prepayment', imports: [PrepaymentProgressComponent, PrePaymentLayoutComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<abp-prepayment-layout>\r\n <abp-prepayment-progress [gateway]=\"gateway()\" />\r\n</abp-prepayment-layout>\r\n" }]
|
|
722
|
+
}], ctorParameters: () => [], propDecorators: { baseUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseUrl", required: false }] }], paymentRequest: [{ type: i0.Input, args: [{ isSignal: true, alias: "paymentRequest", required: false }] }], gateway: [{ type: i0.Input, args: [{ isSignal: true, alias: "gateway", required: false }] }] } });
|
|
723
|
+
|
|
724
|
+
class IyzicoPrepaymentComponent {
|
|
725
|
+
#injector;
|
|
726
|
+
constructor() {
|
|
727
|
+
this.baseUrl = input('', ...(ngDevMode ? [{ debugName: "baseUrl" }] : []));
|
|
728
|
+
this.apiUrl = input('', ...(ngDevMode ? [{ debugName: "apiUrl" }] : []));
|
|
729
|
+
this.paymentRequest = input(null, ...(ngDevMode ? [{ debugName: "paymentRequest" }] : []));
|
|
730
|
+
this.gateway = input('', ...(ngDevMode ? [{ debugName: "gateway" }] : []));
|
|
731
|
+
this.prePaymentInProgress = signal(false, ...(ngDevMode ? [{ debugName: "prePaymentInProgress" }] : []));
|
|
732
|
+
this.prepaymentForm = signal(null, ...(ngDevMode ? [{ debugName: "prepaymentForm" }] : []));
|
|
733
|
+
this.selectedRecord = {};
|
|
734
|
+
this.#injector = inject(Injector);
|
|
735
|
+
this.paymentRequestService = inject(PaymentRequestService);
|
|
736
|
+
this.environmentService = inject(EnvironmentService);
|
|
737
|
+
this.document = inject(DOCUMENT);
|
|
738
|
+
this.buildForm();
|
|
739
|
+
}
|
|
740
|
+
buildForm() {
|
|
741
|
+
const data = new FormPropData(this.#injector, this.selectedRecord);
|
|
742
|
+
const form = generateFormFromProps(data);
|
|
743
|
+
this.prepaymentForm.set(form);
|
|
744
|
+
}
|
|
745
|
+
startPayment() {
|
|
746
|
+
const form = this.prepaymentForm();
|
|
747
|
+
if (!form || form.invalid)
|
|
748
|
+
return;
|
|
749
|
+
const formValue = form.value;
|
|
750
|
+
//TODO: Remove these values from the UI when the service manages them itself
|
|
751
|
+
const staticValues = {
|
|
752
|
+
IdentityNumber: '12376481923',
|
|
753
|
+
IpAddress: '127.0.0.1',
|
|
754
|
+
Description: 'test',
|
|
755
|
+
};
|
|
756
|
+
const paymentStartData = {
|
|
757
|
+
paymentRequestId: this.paymentRequest().id,
|
|
758
|
+
returnUrl: `${this.apiUrl()}/api/payment/iyzico/callback?paymentRequestId=${this.paymentRequest().id}&returnUrl=${this.baseUrl()}/payment/iyzico/post-payment?paymentRequestId=${this.paymentRequest().id}`,
|
|
759
|
+
cancelUrl: this.baseUrl(),
|
|
760
|
+
extraProperties: {
|
|
761
|
+
Name: formValue.name,
|
|
762
|
+
Surname: formValue.surname,
|
|
763
|
+
Email: formValue.email,
|
|
764
|
+
City: formValue.city,
|
|
765
|
+
Country: formValue.country,
|
|
766
|
+
ZipCode: formValue.zipCode,
|
|
767
|
+
RegistrationAddress: formValue.description,
|
|
768
|
+
...staticValues
|
|
769
|
+
},
|
|
770
|
+
};
|
|
771
|
+
this.prePaymentInProgress.set(true);
|
|
772
|
+
this.paymentRequestService
|
|
773
|
+
.start(this.gateway(), paymentStartData)
|
|
774
|
+
.pipe(finalize(() => {
|
|
775
|
+
this.prePaymentInProgress.set(false);
|
|
776
|
+
}))
|
|
777
|
+
.subscribe({
|
|
778
|
+
next: res => {
|
|
779
|
+
this.document.defaultView?.location.replace(res.checkoutLink);
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: IyzicoPrepaymentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
784
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.9", type: IyzicoPrepaymentComponent, isStandalone: true, selector: "abp-iyzico-prepayment", inputs: { baseUrl: { classPropertyName: "baseUrl", publicName: "baseUrl", isSignal: true, isRequired: false, transformFunction: null }, apiUrl: { classPropertyName: "apiUrl", publicName: "apiUrl", isSignal: true, isRequired: false, transformFunction: null }, paymentRequest: { classPropertyName: "paymentRequest", publicName: "paymentRequest", isSignal: true, isRequired: false, transformFunction: null }, gateway: { classPropertyName: "gateway", publicName: "gateway", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
785
|
+
{
|
|
786
|
+
provide: EXTENSIONS_IDENTIFIER,
|
|
787
|
+
useValue: "Payment.Iyzico.PrepaymentForm" /* ePaymentComponents.IyzicoPrepaymentForm */,
|
|
788
|
+
},
|
|
789
|
+
], ngImport: i0, template: "<abp-prepayment-layout>\r\n <abp-card>\r\n <abp-card-header>\r\n <h4 class=\"text-center\">You will pay with Iyzico</h4>\r\n </abp-card-header>\r\n <abp-card-body>\r\n @if (prepaymentForm(); as form) {\r\n <form [formGroup]=\"form\" (ngSubmit)=\"startPayment()\" validateOnSubmit>\r\n <abp-extensible-form [selectedRecord]=\"selectedRecord\" />\r\n <abp-card-footer>\r\n <button type=\"submit\" class=\"btn btn-success w-100\"\r\n [abpLoading]=\"prePaymentInProgress()\"\r\n [disabled]=\"form.invalid || prePaymentInProgress()\">\r\n <span>{{ 'Continue to Checkout' | abpLocalization }}</span>\r\n <i class=\"fas fa-arrow-right ms-1\" aria-hidden=\"true\"></i>\r\n </button>\r\n </abp-card-footer>\r\n </form>\r\n }\r\n </abp-card-body>\r\n </abp-card>\r\n\r\n</abp-prepayment-layout>\r\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: CardComponent, selector: "abp-card", inputs: ["cardClass", "cardStyle"] }, { kind: "component", type: CardBodyComponent, selector: "abp-card-body", inputs: ["cardBodyClass", "cardBodyStyle"] }, { kind: "component", type: CardFooterComponent, selector: "abp-card-footer", inputs: ["cardFooterStyle", "cardFooterClass"] }, { kind: "directive", type: CardHeaderDirective, selector: "abp-card-header, [abp-card-header], [abpCardHeader]" }, { kind: "ngmodule", type: NgxValidateCoreModule }, { kind: "directive", type: i2.ValidationGroupDirective, selector: "[formGroup],[formGroupName]", exportAs: ["validationGroup"] }, { kind: "component", type: ExtensibleFormComponent, selector: "abp-extensible-form", inputs: ["selectedRecord"], exportAs: ["abpExtensibleForm"] }, { kind: "directive", type: LoadingDirective, selector: "[abpLoading]", inputs: ["abpLoading", "abpLoadingTargetElement", "abpLoadingDelay"] }, { kind: "component", type: PrePaymentLayoutComponent, selector: "abp-prepayment-layout" }, { kind: "pipe", type: LocalizationPipe, name: "abpLocalization" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
790
|
+
}
|
|
791
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: IyzicoPrepaymentComponent, decorators: [{
|
|
792
|
+
type: Component,
|
|
793
|
+
args: [{ selector: 'abp-iyzico-prepayment', imports: [
|
|
794
|
+
ReactiveFormsModule,
|
|
795
|
+
LocalizationPipe,
|
|
796
|
+
CardComponent,
|
|
797
|
+
CardBodyComponent,
|
|
798
|
+
CardFooterComponent,
|
|
799
|
+
CardHeaderDirective,
|
|
800
|
+
NgxValidateCoreModule,
|
|
801
|
+
ExtensibleFormComponent,
|
|
802
|
+
LoadingDirective,
|
|
803
|
+
PrePaymentLayoutComponent,
|
|
804
|
+
], providers: [
|
|
805
|
+
{
|
|
806
|
+
provide: EXTENSIONS_IDENTIFIER,
|
|
807
|
+
useValue: "Payment.Iyzico.PrepaymentForm" /* ePaymentComponents.IyzicoPrepaymentForm */,
|
|
808
|
+
},
|
|
809
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<abp-prepayment-layout>\r\n <abp-card>\r\n <abp-card-header>\r\n <h4 class=\"text-center\">You will pay with Iyzico</h4>\r\n </abp-card-header>\r\n <abp-card-body>\r\n @if (prepaymentForm(); as form) {\r\n <form [formGroup]=\"form\" (ngSubmit)=\"startPayment()\" validateOnSubmit>\r\n <abp-extensible-form [selectedRecord]=\"selectedRecord\" />\r\n <abp-card-footer>\r\n <button type=\"submit\" class=\"btn btn-success w-100\"\r\n [abpLoading]=\"prePaymentInProgress()\"\r\n [disabled]=\"form.invalid || prePaymentInProgress()\">\r\n <span>{{ 'Continue to Checkout' | abpLocalization }}</span>\r\n <i class=\"fas fa-arrow-right ms-1\" aria-hidden=\"true\"></i>\r\n </button>\r\n </abp-card-footer>\r\n </form>\r\n }\r\n </abp-card-body>\r\n </abp-card>\r\n\r\n</abp-prepayment-layout>\r\n" }]
|
|
810
|
+
}], ctorParameters: () => [], propDecorators: { baseUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseUrl", required: false }] }], apiUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "apiUrl", required: false }] }], paymentRequest: [{ type: i0.Input, args: [{ isSignal: true, alias: "paymentRequest", required: false }] }], gateway: [{ type: i0.Input, args: [{ isSignal: true, alias: "gateway", required: false }] }] } });
|
|
811
|
+
|
|
812
|
+
class TwocheckoutPrepaymentComponent {
|
|
813
|
+
constructor() {
|
|
814
|
+
this.baseUrl = input('', ...(ngDevMode ? [{ debugName: "baseUrl" }] : []));
|
|
815
|
+
this.paymentRequest = input(null, ...(ngDevMode ? [{ debugName: "paymentRequest" }] : []));
|
|
816
|
+
this.gateway = input('', ...(ngDevMode ? [{ debugName: "gateway" }] : []));
|
|
817
|
+
this.prePaymentInProgress = signal(false, ...(ngDevMode ? [{ debugName: "prePaymentInProgress" }] : []));
|
|
818
|
+
this.document = inject(DOCUMENT);
|
|
819
|
+
this.platformId = inject(PLATFORM_ID);
|
|
820
|
+
this.paymentRequestService = inject(PaymentRequestService);
|
|
821
|
+
effect(() => {
|
|
822
|
+
if (this.paymentRequest()?.id && this.gateway()) {
|
|
823
|
+
this.startPayment();
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
startPayment() {
|
|
828
|
+
const paymentStartData = {
|
|
829
|
+
paymentRequestId: this.paymentRequest().id,
|
|
830
|
+
returnUrl: `${this.baseUrl()}/payment/twocheckout/post-payment?paymentRequestId=${this.paymentRequest().id}`,
|
|
831
|
+
cancelUrl: this.baseUrl(),
|
|
832
|
+
};
|
|
833
|
+
this.prePaymentInProgress.set(true);
|
|
834
|
+
this.paymentRequestService
|
|
835
|
+
.start(this.gateway(), paymentStartData)
|
|
836
|
+
.pipe(finalize(() => {
|
|
837
|
+
this.prePaymentInProgress.set(false);
|
|
838
|
+
}))
|
|
839
|
+
.subscribe({
|
|
840
|
+
next: res => {
|
|
841
|
+
if (res?.checkoutLink && isPlatformBrowser(this.platformId)) {
|
|
842
|
+
this.document.defaultView.location.replace(res.checkoutLink);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: TwocheckoutPrepaymentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
848
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.9", type: TwocheckoutPrepaymentComponent, isStandalone: true, selector: "abp-twocheckout-prepayment", inputs: { baseUrl: { classPropertyName: "baseUrl", publicName: "baseUrl", isSignal: true, isRequired: false, transformFunction: null }, paymentRequest: { classPropertyName: "paymentRequest", publicName: "paymentRequest", isSignal: true, isRequired: false, transformFunction: null }, gateway: { classPropertyName: "gateway", publicName: "gateway", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<abp-prepayment-layout>\r\n <abp-prepayment-progress [gateway]=\"gateway()\" />\r\n</abp-prepayment-layout>\r\n", dependencies: [{ kind: "component", type: PrepaymentProgressComponent, selector: "abp-prepayment-progress", inputs: ["gateway"] }, { kind: "component", type: PrePaymentLayoutComponent, selector: "abp-prepayment-layout" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
849
|
+
}
|
|
850
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: TwocheckoutPrepaymentComponent, decorators: [{
|
|
851
|
+
type: Component,
|
|
852
|
+
args: [{ selector: 'abp-twocheckout-prepayment', imports: [PrepaymentProgressComponent, PrePaymentLayoutComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<abp-prepayment-layout>\r\n <abp-prepayment-progress [gateway]=\"gateway()\" />\r\n</abp-prepayment-layout>\r\n" }]
|
|
853
|
+
}], ctorParameters: () => [], propDecorators: { baseUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseUrl", required: false }] }], paymentRequest: [{ type: i0.Input, args: [{ isSignal: true, alias: "paymentRequest", required: false }] }], gateway: [{ type: i0.Input, args: [{ isSignal: true, alias: "gateway", required: false }] }] } });
|
|
854
|
+
|
|
855
|
+
class AlipayPrepaymentComponent {
|
|
856
|
+
constructor() {
|
|
857
|
+
this.baseUrl = input('', ...(ngDevMode ? [{ debugName: "baseUrl" }] : []));
|
|
858
|
+
this.paymentRequest = input(null, ...(ngDevMode ? [{ debugName: "paymentRequest" }] : []));
|
|
859
|
+
this.gateway = input('', ...(ngDevMode ? [{ debugName: "gateway" }] : []));
|
|
860
|
+
this.prePaymentInProgress = signal(false, ...(ngDevMode ? [{ debugName: "prePaymentInProgress" }] : []));
|
|
861
|
+
this.document = inject(DOCUMENT);
|
|
862
|
+
this.platformId = inject(PLATFORM_ID);
|
|
863
|
+
this.paymentRequestService = inject(PaymentRequestService);
|
|
864
|
+
effect(() => {
|
|
865
|
+
if (this.paymentRequest()?.id && this.gateway()) {
|
|
866
|
+
this.startPayment();
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
startPayment() {
|
|
871
|
+
const paymentStartData = {
|
|
872
|
+
paymentRequestId: this.paymentRequest().id,
|
|
873
|
+
returnUrl: `${this.baseUrl()}/payment/alipay/post-payment?paymentRequestId=${this.paymentRequest().id}`,
|
|
874
|
+
cancelUrl: this.baseUrl(),
|
|
875
|
+
};
|
|
876
|
+
this.prePaymentInProgress.set(true);
|
|
877
|
+
this.paymentRequestService
|
|
878
|
+
.start(this.gateway(), paymentStartData)
|
|
879
|
+
.pipe(finalize(() => {
|
|
880
|
+
this.prePaymentInProgress.set(false);
|
|
881
|
+
}))
|
|
882
|
+
.subscribe({
|
|
883
|
+
next: res => {
|
|
884
|
+
if (res?.checkoutLink && isPlatformBrowser(this.platformId)) {
|
|
885
|
+
this.document.defaultView.location.replace(res.checkoutLink);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: AlipayPrepaymentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
891
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.9", type: AlipayPrepaymentComponent, isStandalone: true, selector: "abp-alipay-prepayment", inputs: { baseUrl: { classPropertyName: "baseUrl", publicName: "baseUrl", isSignal: true, isRequired: false, transformFunction: null }, paymentRequest: { classPropertyName: "paymentRequest", publicName: "paymentRequest", isSignal: true, isRequired: false, transformFunction: null }, gateway: { classPropertyName: "gateway", publicName: "gateway", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<abp-prepayment-layout>\r\n <abp-prepayment-progress [gateway]=\"gateway()\" />\r\n</abp-prepayment-layout>\r\n", dependencies: [{ kind: "component", type: PrepaymentProgressComponent, selector: "abp-prepayment-progress", inputs: ["gateway"] }, { kind: "component", type: PrePaymentLayoutComponent, selector: "abp-prepayment-layout" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
892
|
+
}
|
|
893
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: AlipayPrepaymentComponent, decorators: [{
|
|
894
|
+
type: Component,
|
|
895
|
+
args: [{ selector: 'abp-alipay-prepayment', imports: [PrepaymentProgressComponent, PrePaymentLayoutComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<abp-prepayment-layout>\r\n <abp-prepayment-progress [gateway]=\"gateway()\" />\r\n</abp-prepayment-layout>\r\n" }]
|
|
896
|
+
}], ctorParameters: () => [], propDecorators: { baseUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseUrl", required: false }] }], paymentRequest: [{ type: i0.Input, args: [{ isSignal: true, alias: "paymentRequest", required: false }] }], gateway: [{ type: i0.Input, args: [{ isSignal: true, alias: "gateway", required: false }] }] } });
|
|
897
|
+
|
|
898
|
+
class PrepaymentHostComponent {
|
|
899
|
+
constructor() {
|
|
900
|
+
this.viewContainerRef = inject(ViewContainerRef);
|
|
901
|
+
this.route = inject(ActivatedRoute);
|
|
902
|
+
this.replaceableComponents = inject(ReplaceableComponentsService);
|
|
903
|
+
this.paymentRequestService = inject(PaymentRequestService);
|
|
904
|
+
this.environmentService = inject(EnvironmentService);
|
|
905
|
+
this.componentRef = signal(undefined, ...(ngDevMode ? [{ debugName: "componentRef" }] : []));
|
|
906
|
+
this.gateway = signal(null, ...(ngDevMode ? [{ debugName: "gateway" }] : []));
|
|
907
|
+
this.baseUrl = signal(null, ...(ngDevMode ? [{ debugName: "baseUrl" }] : []));
|
|
908
|
+
this.apiUrl = signal(null, ...(ngDevMode ? [{ debugName: "apiUrl" }] : []));
|
|
909
|
+
this.paymentRequest = signal(null, ...(ngDevMode ? [{ debugName: "paymentRequest" }] : []));
|
|
910
|
+
}
|
|
911
|
+
ngOnInit() {
|
|
912
|
+
const gateway = this.route.snapshot.params['gateway'];
|
|
913
|
+
this.gateway.set(gateway);
|
|
914
|
+
const paymentRequestId = this.route.snapshot.queryParams['paymentRequestId'];
|
|
915
|
+
if (!this.gateway()) {
|
|
916
|
+
console.warn('No gateway parameter found in route');
|
|
917
|
+
this.loadDefaultComponent();
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
// get baseUrl from environment
|
|
921
|
+
this.baseUrl.set(this.environmentService.getEnvironment()?.application?.baseUrl);
|
|
922
|
+
// get apiUrl from environment. It's required for iyzico post-payment
|
|
923
|
+
this.apiUrl.set(this.environmentService.getEnvironment()?.apis?.default?.url);
|
|
924
|
+
// Load payment request first, then load component
|
|
925
|
+
if (paymentRequestId) {
|
|
926
|
+
this.paymentRequestService.get(paymentRequestId).subscribe({
|
|
927
|
+
next: (paymentRequest) => {
|
|
928
|
+
this.paymentRequest.set(paymentRequest);
|
|
929
|
+
this.loadPrepaymentComponent();
|
|
930
|
+
},
|
|
931
|
+
error: (error) => {
|
|
932
|
+
console.error('Failed to load payment request:', error);
|
|
933
|
+
this.loadDefaultComponent();
|
|
934
|
+
},
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
else {
|
|
938
|
+
this.loadPrepaymentComponent();
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
loadPrepaymentComponent() {
|
|
942
|
+
const componentKey = getPrePaymentComponentKey(this.gateway());
|
|
943
|
+
const customComponent = this.replaceableComponents.get(componentKey);
|
|
944
|
+
let componentToLoad;
|
|
945
|
+
if (customComponent?.component) {
|
|
946
|
+
componentToLoad = customComponent.component;
|
|
947
|
+
}
|
|
948
|
+
else {
|
|
949
|
+
componentToLoad = this.getDefaultComponentForGateway(this.gateway());
|
|
950
|
+
}
|
|
951
|
+
this.viewContainerRef.clear();
|
|
952
|
+
// Create the component
|
|
953
|
+
this.componentRef.set(this.viewContainerRef.createComponent(componentToLoad));
|
|
954
|
+
if (this.componentRef()) {
|
|
955
|
+
this.componentRef().setInput('baseUrl', this.baseUrl());
|
|
956
|
+
this.componentRef().setInput('gateway', this.gateway());
|
|
957
|
+
this.componentRef().setInput('paymentRequest', this.paymentRequest());
|
|
958
|
+
if (this.gateway() === eGatewaysType.iyzico) {
|
|
959
|
+
this.componentRef().setInput('apiUrl', this.apiUrl());
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
getDefaultComponentForGateway(gateway) {
|
|
964
|
+
switch (gateway) {
|
|
965
|
+
case eGatewaysType.stripe:
|
|
966
|
+
return StripePrepaymentComponent;
|
|
967
|
+
case eGatewaysType.paypal:
|
|
968
|
+
return PayPalPrepaymentComponent;
|
|
969
|
+
case eGatewaysType.payu:
|
|
970
|
+
return PayuPrepaymentComponent;
|
|
971
|
+
case eGatewaysType.iyzico:
|
|
972
|
+
return IyzicoPrepaymentComponent;
|
|
973
|
+
case eGatewaysType.twoCheckout:
|
|
974
|
+
return TwocheckoutPrepaymentComponent;
|
|
975
|
+
case eGatewaysType.alipay:
|
|
976
|
+
return AlipayPrepaymentComponent;
|
|
977
|
+
default:
|
|
978
|
+
return PrepaymentProgressComponent;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
loadDefaultComponent() {
|
|
982
|
+
this.viewContainerRef.clear();
|
|
983
|
+
this.componentRef.set(this.viewContainerRef.createComponent(PrepaymentProgressComponent));
|
|
984
|
+
}
|
|
985
|
+
ngOnDestroy() {
|
|
986
|
+
if (this.componentRef()) {
|
|
987
|
+
this.componentRef().destroy();
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PrepaymentHostComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
991
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.9", type: PrepaymentHostComponent, isStandalone: true, selector: "abp-prepayment-host", ngImport: i0, template: '', isInline: true }); }
|
|
992
|
+
}
|
|
993
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: PrepaymentHostComponent, decorators: [{
|
|
994
|
+
type: Component,
|
|
995
|
+
args: [{
|
|
996
|
+
selector: 'abp-prepayment-host',
|
|
997
|
+
template: '',
|
|
998
|
+
}]
|
|
999
|
+
}] });
|
|
1000
|
+
|
|
1001
|
+
const paymentExtensionsResolver = () => {
|
|
1002
|
+
const injector = inject(Injector);
|
|
1003
|
+
const extensions = injector.get(ExtensionsService);
|
|
1004
|
+
const iyzicoFormContributors = injector.get(PAYMENT_IYZICO_FORM_PROP_CONTRIBUTORS, null) || {};
|
|
1005
|
+
// Merge payment form props - prepayment is always CREATE, not EDIT
|
|
1006
|
+
mergeWithDefaultProps(extensions.createFormProps, DEFAULT_PAYMENT_FORM_PROPS, {}, iyzicoFormContributors);
|
|
1007
|
+
return of(true);
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
function createRoutes() {
|
|
1011
|
+
return [
|
|
1012
|
+
{ path: '', redirectTo: 'gateway-selection', pathMatch: 'full' },
|
|
1013
|
+
{
|
|
1014
|
+
path: '',
|
|
1015
|
+
component: RouterOutletComponent,
|
|
1016
|
+
canActivate: [],
|
|
1017
|
+
children: [
|
|
1018
|
+
{
|
|
1019
|
+
path: 'gateway-selection',
|
|
1020
|
+
component: ReplaceableRouteContainerComponent,
|
|
1021
|
+
data: {
|
|
1022
|
+
requiredPolicy: '',
|
|
1023
|
+
replaceableComponent: {
|
|
1024
|
+
key: "Payment.GatewaySelection" /* ePaymentComponents.GatewaySelection */,
|
|
1025
|
+
defaultComponent: GatewaysSelectionComponent,
|
|
1026
|
+
},
|
|
1027
|
+
},
|
|
1028
|
+
title: 'Payment::GatewaySelection',
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
path: ':gateway/prepayment',
|
|
1032
|
+
component: ReplaceableRouteContainerComponent,
|
|
1033
|
+
resolve: [paymentExtensionsResolver],
|
|
1034
|
+
data: {
|
|
1035
|
+
requiredPolicy: '',
|
|
1036
|
+
replaceableComponent: {
|
|
1037
|
+
key: "Payment.Prepayment" /* ePaymentComponents.Prepayment */,
|
|
1038
|
+
defaultComponent: PrepaymentHostComponent,
|
|
1039
|
+
},
|
|
1040
|
+
},
|
|
1041
|
+
title: 'Payment::Prepayment',
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
path: ':gateway/post-payment',
|
|
1045
|
+
component: ReplaceableRouteContainerComponent,
|
|
1046
|
+
data: {
|
|
1047
|
+
requiredPolicy: '',
|
|
1048
|
+
replaceableComponent: {
|
|
1049
|
+
key: "Payment.PostPayment" /* ePaymentComponents.PostPayment */,
|
|
1050
|
+
defaultComponent: PostPaymentHostComponent,
|
|
1051
|
+
},
|
|
1052
|
+
},
|
|
1053
|
+
title: 'Payment::PostPayment',
|
|
1054
|
+
}
|
|
1055
|
+
],
|
|
1056
|
+
},
|
|
1057
|
+
];
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1
1060
|
/**
|
|
2
1061
|
* Generated bundle index. Do not edit.
|
|
3
1062
|
*/
|
|
1063
|
+
|
|
1064
|
+
export { DEFAULT_IYZICO_PREPAYMENT_FORM_PROPS, DEFAULT_PAYMENT_FORM_PROPS, DEFAULT_POST_PAYMENT_COMPONENT_MAP, DEFAULT_PRE_PAYMENT_COMPONENT_MAP, GatewaysSelectionComponent, PAYMENT_IYZICO_FORM_PROP_CONTRIBUTORS, PostPaymentBaseComponent, PostPaymentComponent, PostPaymentHostComponent, PrePaymentLayoutComponent, PrepaymentHostComponent, createRoutes, eGatewaysType, getPostPaymentComponentKey, getPrePaymentComponentKey, paymentExtensionsResolver, registerPostPaymentComponent, registerPostPaymentComponents, registerPrePaymentComponent, registerPrePaymentComponents };
|
|
4
1065
|
//# sourceMappingURL=volo-abp.ng.payment.mjs.map
|