-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
190 additions
and
29 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
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions
10
...hop-error-after-payment.component.spec.ts → ...op-cancel-after-payment.component.spec.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
10 changes: 10 additions & 0 deletions
10
src/app/pages/shop/shop-cancel-after-payment/shop-cancel-after-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,10 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-shop-cancel-after-payment', | ||
templateUrl: './shop-cancel-after-payment.component.html', | ||
styleUrl: './shop-cancel-after-payment.component.scss' | ||
}) | ||
export class ShopCancelAfterPaymentComponent { | ||
|
||
} |
8 changes: 7 additions & 1 deletion
8
src/app/pages/shop/shop-checkout/shop-payment-paypal/shop-payment-paypal.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 |
---|---|---|
@@ -1 +1,7 @@ | ||
<p>shop-payment-paypal works!</p> | ||
<div class="row justify-content-center m-2"> | ||
<button class="btn btn-outline-warning" [disabled]="loading" (click)="createOrder()"> | ||
<span *ngIf="loading" class="spinner-border spinner-border-sm" aria-hidden="true"></span> | ||
<i class="bi bi-paypal"></i> PayPal<br> | ||
<span>Payez avec votre compte PayPal</span> | ||
</button> | ||
</div> |
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 |
---|---|---|
|
@@ -14,16 +14,24 @@ export class ShopPaymentPaypalComponent { | |
|
||
private readonly paymentService: PacifistaPaymentService; | ||
|
||
loading = false; | ||
|
||
constructor(protected shopService: ShopService, | ||
protected notificationService: NotificationService, | ||
httpClient: HttpClient) { | ||
this.paymentService = new PacifistaPaymentService(httpClient, environment.production); | ||
} | ||
|
||
createOrder(): void { | ||
if (this.shopService.totalArticlesInBasket() === 0) { | ||
this.notificationService.info("Votre panier est vide. Veuillez ajouter des articles avant de procéder au paiement.", "Paiement"); | ||
return; | ||
} | ||
|
||
const request = new PacifistaPaymentRequestDTO(); | ||
request.articles = this.shopService.createArticlesRequestList(); | ||
|
||
this.loading = true; | ||
this.paymentService.createOrder(request).subscribe({ | ||
next: (response) => { | ||
const redirectUrl: string | undefined = response.urlClientRedirection; | ||
|
@@ -33,8 +41,10 @@ export class ShopPaymentPaypalComponent { | |
} else { | ||
this.notificationService.error("Erreur lors de la création de la commande. Veuillez envoyer un mail à [email protected]", "Paiement"); | ||
} | ||
this.loading = false; | ||
}, | ||
error: (error) => { | ||
this.loading = false; | ||
this.notificationService.onErrorRequest(error); | ||
} | ||
}); | ||
|
7 changes: 7 additions & 0 deletions
7
...pages/shop/shop-checkout/shop-payment-paysafecard/shop-payment-paysafecard.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,7 @@ | ||
<div class="row justify-content-center m-2"> | ||
<button class="btn btn-outline-info" disabled (click)="createOrder()"> | ||
<span *ngIf="loading" class="spinner-border spinner-border-sm" aria-hidden="true"></span> | ||
<i class="bi bi-lock-fill"></i> Paysafe Card<br> | ||
<span>Payez avec votre solde Paysafe Card (carte prépyayée en bureau de tabac)</span> | ||
</button> | ||
</div> |
Empty file.
23 changes: 23 additions & 0 deletions
23
...es/shop/shop-checkout/shop-payment-paysafecard/shop-payment-paysafecard.component.spec.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,23 @@ | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import {ShopPaymentPaysafecardComponent} from './shop-payment-paysafecard.component'; | ||
|
||
describe('ShopPaymentPaysafecardComponent', () => { | ||
let component: ShopPaymentPaysafecardComponent; | ||
let fixture: ComponentFixture<ShopPaymentPaysafecardComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ShopPaymentPaysafecardComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ShopPaymentPaysafecardComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
...p/pages/shop/shop-checkout/shop-payment-paysafecard/shop-payment-paysafecard.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,16 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-shop-payment-paysafecard', | ||
templateUrl: './shop-payment-paysafecard.component.html', | ||
styleUrl: './shop-payment-paysafecard.component.scss' | ||
}) | ||
export class ShopPaymentPaysafecardComponent { | ||
|
||
loading: boolean = false; | ||
|
||
createOrder() { | ||
|
||
} | ||
|
||
} |
10 changes: 0 additions & 10 deletions
10
src/app/pages/shop/shop-error-after-payment/shop-error-after-payment.component.ts
This file was deleted.
Oops, something went wrong.
14 changes: 13 additions & 1 deletion
14
src/app/pages/shop/shop-redirect-after-payment/shop-redirect-after-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 |
---|---|---|
@@ -1 +1,13 @@ | ||
<p>shop-success-page works!</p> | ||
<div *ngIf="loading; else doneLoading"> | ||
<h1>Chargement...</h1> | ||
</div> | ||
|
||
<ng-template #doneLoading> | ||
<div *ngIf="errorMessage.length === 0; else errorDiv"> | ||
Cool ! | ||
</div> | ||
<ng-template #errorDiv> | ||
<h1>Erreur </h1> | ||
{{errorMessage}} | ||
</ng-template> | ||
</ng-template> |
79 changes: 77 additions & 2 deletions
79
src/app/pages/shop/shop-redirect-after-payment/shop-redirect-after-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 |
---|---|---|
@@ -1,10 +1,85 @@ | ||
import {Component} from '@angular/core'; | ||
import {AfterViewInit, Component} from '@angular/core'; | ||
import {ActivatedRoute} from "@angular/router"; | ||
import ShopService from "../shop-service"; | ||
import { | ||
ErrorDto, | ||
PacifistaPaymentResponseDTO, | ||
PacifistaPaymentService | ||
} from "@funixproductions/funixproductions-requests"; | ||
import {HttpClient} from "@angular/common/http"; | ||
import {environment} from "../../../../environments/environment"; | ||
import NotificationService from "../../../services/notifications/services/NotificationService"; | ||
|
||
@Component({ | ||
selector: 'app-shop-redirect-after-payment', | ||
templateUrl: './shop-redirect-after-payment.component.html', | ||
styleUrl: './shop-redirect-after-payment.component.scss' | ||
}) | ||
export class ShopRedirectAfterPaymentComponent { | ||
export class ShopRedirectAfterPaymentComponent implements AfterViewInit { | ||
|
||
loading = true; | ||
errorMessage = ''; | ||
|
||
constructor(private route: ActivatedRoute, | ||
private shopService: ShopService, | ||
private notificationService: NotificationService, | ||
private httpClient: HttpClient) { | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
this.route.queryParams.subscribe(params => { | ||
const orderId = params['token']; | ||
|
||
if (!orderId) { | ||
this.loading = false; | ||
this.errorMessage = "Votre achat n'a pas été validé. Veuillez recommencer. Vous n'avez pas été débité."; | ||
return; | ||
} | ||
|
||
const paymentService = new PacifistaPaymentService(this.httpClient, environment.production); | ||
|
||
paymentService.getStatus(orderId).subscribe({ | ||
next: (response) => { | ||
if (response.orderPaid) { | ||
this.onSuccess(response); | ||
} else { | ||
this.capturePayment(orderId, paymentService); | ||
} | ||
}, | ||
error: (error: ErrorDto) => { | ||
this.onError(error); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
private onSuccess(response: PacifistaPaymentResponseDTO) { | ||
this.loading = false; | ||
|
||
if (response.orderPaid) { | ||
this.errorMessage = ''; | ||
this.shopService.clearBasket(); | ||
} else { | ||
this.errorMessage = "Votre achat n'a pas été validé. Veuillez recommencer. Vous n'avez pas été débité."; | ||
} | ||
} | ||
|
||
private onError(error: ErrorDto) { | ||
this.loading = false; | ||
this.errorMessage = "Une erreur est survenue. Veuillez recommencer. Vous n'avez pas été débité." + | ||
" (Erreur: " + error.error + ", code: " + error.status + ")"; | ||
this.notificationService.onErrorRequest(error); | ||
} | ||
|
||
private capturePayment(orderId: string, paymentService: PacifistaPaymentService) { | ||
paymentService.captureOrder(orderId).subscribe({ | ||
next: (response) => { | ||
this.onSuccess(response); | ||
}, | ||
error: (error: ErrorDto) => { | ||
this.onError(error); | ||
} | ||
}); | ||
} | ||
|
||
} |
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