Skip to content

Commit 73674b4

Browse files
committed
chore: Remove unused files and update dependencies
1 parent 9633425 commit 73674b4

File tree

6 files changed

+78
-74
lines changed

6 files changed

+78
-74
lines changed

angular.json

+2-8
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,7 @@
5555
"development": {
5656
"optimization": false,
5757
"extractLicenses": false,
58-
"sourceMap": true,
59-
"fileReplacements": [
60-
{
61-
"replace": "src/environments/environment.ts",
62-
"with": "src/environments/environment.development.ts"
63-
}
64-
]
58+
"sourceMap": true
6559
}
6660
},
6761
"defaultConfiguration": "production"
@@ -111,4 +105,4 @@
111105
"cli": {
112106
"analytics": false
113107
}
114-
}
108+
}

src/app/components/cart/cart.component.html

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<div class="cardSettings">
2+
<p>Configure API KEY</p>
3+
<input class="input" type="text" [(ngModel)]="tokenCulqi" placeholder="tokenCulqi" aria-label="tokenCulqi" />
4+
<input class="input" type="text" [(ngModel)]="apiKeyCulqi" placeholder="apiKeyCulqi" aria-label="apiKeyCulqi" />
5+
<input class="input" type="text" [(ngModel)]="xculqirsaid" placeholder="xculqirsaid" aria-label="xculqirsaid" />
6+
<input class="input" type="text" [(ngModel)]="rsapublickey" placeholder="rsapublickey" aria-label="rsapublickey" />
7+
</div>
18
<div class="cart">
29
<h2 class="title">Shopping Cart</h2>
310
<div class="card">
+46-29
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,51 @@
1-
.cart {
2-
display: block;
3-
border: 1px solid #bdbdbd;
4-
border-radius: 4px;
5-
padding: 20px;
6-
margin-bottom: 20px;
1+
.cardSettings {
2+
margin: 20px 0;
3+
background-color: #f7f5f5;
4+
border-radius: 12px;
5+
padding: 12px;
6+
display: flex;
7+
flex-direction: column;
78

8-
.title {
9-
margin: 0 0 20px 0;
10-
}
9+
.input {
10+
border: 1px solid #e6e3e3;
11+
margin: 4px 0;
12+
padding: 4px 8px;
13+
border-radius: 4px;
14+
outline: none;
15+
}
16+
}
1117

12-
.card {
13-
.list {
14-
&Item {
15-
display: flex;
16-
justify-content: space-between;
18+
.cart {
19+
display: block;
20+
border: 1px solid #bdbdbd;
21+
border-radius: 4px;
22+
padding: 20px;
23+
margin-bottom: 20px;
1724

18-
p {
19-
margin: 0 0 12px 0;
20-
}
21-
}
22-
}
25+
.title {
26+
margin: 0 0 20px 0;
27+
}
2328

24-
.btn {
25-
margin-top: 20px;
26-
background-color: #5C44E4;
27-
padding: 8px 20px;
28-
border-radius: 4px;
29-
color: white;
30-
border: none;
31-
}
32-
}
29+
.card {
30+
.list {
31+
&Item {
32+
display: flex;
33+
justify-content: space-between;
3334

34-
}
35+
p {
36+
margin: 0 0 12px 0;
37+
}
38+
}
39+
}
40+
41+
.btn {
42+
margin-top: 20px;
43+
background-color: #5C44E4;
44+
padding: 8px 20px;
45+
border-radius: 4px;
46+
color: white;
47+
border: none;
48+
}
49+
}
50+
51+
}

src/app/components/cart/cart.component.ts

+23-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { CurrencyPipe } from '@angular/common';
22
import { Component } from '@angular/core';
33
import { ICulqiOptions, IOrderCulqiResponse, NgxCulqiService } from 'ngx-culqi';
4-
import { environment } from '../../../environments/environment';
4+
import { FormsModule } from '@angular/forms';
55

66
@Component({
77
selector: 'app-cart',
88
standalone: true,
9-
imports: [CurrencyPipe],
9+
imports: [CurrencyPipe, FormsModule],
1010
templateUrl: './cart.component.html',
1111
styleUrl: './cart.component.scss'
1212
})
@@ -23,6 +23,11 @@ export class CartComponent {
2323
];
2424
amountTotal = 400;
2525

26+
tokenCulqi: string = '';
27+
apiKeyCulqi: string = '';
28+
xculqirsaid: string = '';
29+
rsapublickey: string = ``;
30+
2631
styleCulqi = {
2732
logo: 'https://developers.google.com/static/homepage-assets/images/angular_gradient.png',
2833
bannerColor: '#5C44E4',
@@ -38,7 +43,6 @@ export class CartComponent {
3843
constructor(private ngxCulqiService: NgxCulqiService) { }
3944

4045
ngOnInit(): void {
41-
this.ngxCulqiService.loadScriptCulqi(environment.tokenCulqi, environment.apiKeyCulqi);
4246
this.ngxCulqiService.tokenCreated$.subscribe(value => {
4347
if (value) {
4448
this.showToken(value);
@@ -54,6 +58,8 @@ export class CartComponent {
5458
}
5559

5660
paymentCulqi(): void {
61+
// This function must be called from ngOnInit. Just for this example, it is inside the payment with a setTimeOut to be set from the form.
62+
this.ngxCulqiService.loadScriptCulqi(this.tokenCulqi, this.apiKeyCulqi);
5763
const order = {
5864
"amount": this.amountTotal * 100,
5965
"currency_code": "PEN",
@@ -68,19 +74,21 @@ export class CartComponent {
6874
"expiration_date": (Math.floor(Date.now() / 1000) + 86400),
6975
"confirm": false
7076
};
71-
this.ngxCulqiService.generateOrder(order).subscribe((response: Partial<IOrderCulqiResponse>) => {
72-
const culqiSettings = {
73-
title: order.description,
74-
currency: 'PEN',
75-
amount: order.amount,
76-
order: response.id,
77-
xculqirsaid: environment.xculqirsaid,
78-
rsapublickey: environment.rsapublickey
79-
};
77+
setTimeout(() => {
78+
this.ngxCulqiService.generateOrder(order).subscribe((response: Partial<IOrderCulqiResponse>) => {
79+
const culqiSettings = {
80+
title: order.description,
81+
currency: 'PEN',
82+
amount: order.amount,
83+
order: response.id,
84+
xculqirsaid: this.xculqirsaid,
85+
rsapublickey: this.rsapublickey
86+
};
8087

81-
const culqiOptions: ICulqiOptions = { style: this.styleCulqi };
82-
this.ngxCulqiService.generateToken(culqiSettings, culqiOptions);
83-
});
88+
const culqiOptions: ICulqiOptions = { style: this.styleCulqi };
89+
this.ngxCulqiService.generateToken(culqiSettings, culqiOptions);
90+
});
91+
}, 3000);
8492
}
8593

8694
showToken(token: string): void {

src/environments/environment.development.ts

-11
This file was deleted.

src/environments/environment.ts

-11
This file was deleted.

0 commit comments

Comments
 (0)