-
Notifications
You must be signed in to change notification settings - Fork 1
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
4 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import { CurrencyService } from '../currency.service'; | |
}) | ||
export class CurrencyAccountComponent implements OnInit { | ||
accounts: any[] = []; | ||
|
||
isLoading: boolean = false; | ||
constructor(private axiosService: AxiosService, private currencyService: CurrencyService) { } | ||
|
||
getCurrencyAccounts(): void { | ||
|
@@ -52,4 +52,38 @@ export class CurrencyAccountComponent implements OnInit { | |
this.getCurrencyAccounts(); // Refresh the accounts list after creating a new account | ||
}); | ||
} | ||
|
||
onAddMoney(account: any) { | ||
this.isLoading = true; | ||
this.axiosService.request("POST", | ||
"/api/payment/create", | ||
{ | ||
total: account.amount, | ||
currency: account.curencyCode, | ||
method: "paypal", | ||
intent: "sale", | ||
description: "Płatność za pomocą PayPal. Dodanie środków do konta walutowego. Kwota: " + account.amount + " " + account.currencyCode, | ||
cancelUrl: "http://localhost:8082/api/payment/cancel", | ||
successUrl: "http://localhost:8082/api/payment/success" | ||
|
||
}).then((response) => { | ||
console.log(response.data); | ||
window.location.href = response.data.url; | ||
this.getCurrencyAccounts(); | ||
this.isLoading = false;// Refresh the accounts list after creating a new account | ||
}); | ||
} | ||
|
||
createPayout(account: any) { | ||
this.axiosService.request("POST", | ||
"/api/payment/createPayout", | ||
{ | ||
receiverEmail: "[email protected]", // Dodać kiedyś do db pole paypal email i przypisać do usera podczas rejestracji. | ||
total: account.amount, | ||
currency: account.curencyCode | ||
}).then((response) => { | ||
console.log(response.data); | ||
this.getCurrencyAccounts(); // Refresh the accounts list after creating a new account | ||
}); | ||
} | ||
} |