payment updates
This commit is contained in:
parent
ca979c7488
commit
abfbdb94c0
@ -47,7 +47,7 @@ export class CheckoutComponent {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.currentApplicationDetails = this.storageService.get<{ headerid: number, applicationName: string, applicationType: string }>('currentapplication')
|
this.currentApplicationDetails = this.storageService.get<{ headerid: number, applicationName: string, applicationType: string }>('currentapplication')
|
||||||
this.orderDetails.description = ` 'Carnet Application - ${this.currentApplicationDetails?.applicationName}`
|
this.orderDetails.description = ` 'Carnet Application - ${this.currentApplicationDetails?.headerid} - ${this.currentApplicationDetails?.applicationName}`
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -114,8 +114,6 @@ export class CheckoutComponent {
|
|||||||
// data.orderID is the ID of the transaction from PayPal
|
// data.orderID is the ID of the transaction from PayPal
|
||||||
const captureDetails = await this.paymentService.completePayment(data.orderID);
|
const captureDetails = await this.paymentService.completePayment(data.orderID);
|
||||||
|
|
||||||
// console.log('Capture details:', captureDetails);
|
|
||||||
|
|
||||||
// You can now redirect the user or update the UI
|
// You can now redirect the user or update the UI
|
||||||
this.changeInProgress = true;
|
this.changeInProgress = true;
|
||||||
this.carnetService.submitApplication(this.currentApplicationDetails?.headerid!).pipe(finalize(() => {
|
this.carnetService.submitApplication(this.currentApplicationDetails?.headerid!).pipe(finalize(() => {
|
||||||
@ -146,6 +144,7 @@ export class CheckoutComponent {
|
|||||||
|
|
||||||
// 4. Handle cancellation
|
// 4. Handle cancellation
|
||||||
onCancel: (data: any) => {
|
onCancel: (data: any) => {
|
||||||
|
this.onCancel();
|
||||||
}
|
}
|
||||||
}).render(this.paypalElement.nativeElement)
|
}).render(this.paypalElement.nativeElement)
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
@ -158,5 +157,29 @@ export class CheckoutComponent {
|
|||||||
(fee): fee is number => typeof fee === 'number'
|
(fee): fee is number => typeof fee === 'number'
|
||||||
);
|
);
|
||||||
this.orderTotal = validFees.reduce((total, fee) => total + fee, 0);
|
this.orderTotal = validFees.reduce((total, fee) => total + fee, 0);
|
||||||
|
this.orderDetails.price = this.orderTotal?.toString() ?? '0.00';
|
||||||
|
}
|
||||||
|
|
||||||
|
onCancel(): void {
|
||||||
|
this.storageService.removeItem('currentapplication');
|
||||||
|
|
||||||
|
let route: string = 'edit-carnet';
|
||||||
|
if (this.currentApplicationDetails?.applicationType === 'duplicate') {
|
||||||
|
route = 'duplicate-carnet';
|
||||||
|
}
|
||||||
|
else if (this.currentApplicationDetails?.applicationType === 'extend') {
|
||||||
|
route = 'extend-carnet';
|
||||||
|
} else if (this.currentApplicationDetails?.applicationType === 'additional') {
|
||||||
|
route = 'additional-sets';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.navigationService.navigate([route, this.currentApplicationDetails?.headerid],
|
||||||
|
{
|
||||||
|
state: { isEditMode: true },
|
||||||
|
queryParams: {
|
||||||
|
applicationname: this.currentApplicationDetails?.applicationName,
|
||||||
|
return: 'shipping'
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -13,8 +13,13 @@ export class PaymentService {
|
|||||||
private http = inject(HttpClient);
|
private http = inject(HttpClient);
|
||||||
|
|
||||||
createOrder(orderDetails: any): Promise<string> {
|
createOrder(orderDetails: any): Promise<string> {
|
||||||
|
const data = {
|
||||||
|
P_PRICE: orderDetails.price,
|
||||||
|
P_DESCRIPTION: orderDetails.description
|
||||||
|
}
|
||||||
|
|
||||||
return firstValueFrom(
|
return firstValueFrom(
|
||||||
this.http.post<{ id: string }>(`${this.apiUrl}/${this.apiDb}/InitiatePayment`, {})
|
this.http.post<{ id: string }>(`${this.apiUrl}/${this.apiDb}/InitiatePayment`, data)
|
||||||
).then(order => order.id);
|
).then(order => order.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user