According to : https://developer.vivawallet.com/apis-for-payments/payment-api/
- .NET 6.0
This library is avalaible from NuGet Package Manager
PM> Install-Package FastDo.VivaWallet.Net
- Restsharp
Register service in Program.cs
:
builder.Services.AddVivaWalletService(config);
Add configurations in appsettings.json
. Example for demo api:
"VivaWalletServiceSettings": {
"AccountsBaseUrl": "https://demo-accounts.vivapayments.com",
"ApiBaseUrl": "https://demo-api.vivapayments.com",
"ClientId": "your client id",
"ClientSecret": "your client secret"
}
It is possible to pass settings directly without using appsettings.json
. Register service in Program.cs
:
var settings = new VivaWalletServiceSettings()
{
AccountsBaseUrl = "https://demo-accounts.vivapayments.com",
ApiBaseUrl = "https://demo-api.vivapayments.com",
ClientId = "k6qtgjg32x4advs1e15834ysnek5z2589w4xi9qg3sse3.apps.vivapayments.com",
ClientSecret = "CQtOvA8BficCU0t80buW5178D6610Q",
};
builder.Services.AddVivaWalletService(settings);
Using DI will register interface IVivaWalletService which will be used.
You can also create instace manualy:
var settings = new VivaWalletServiceSettings()
{
AccountsBaseUrl = "https://demo-accounts.vivapayments.com",
ApiBaseUrl = "https://demo-api.vivapayments.com",
ClientId = "k6qtgjg32x4advs1e15834ysnek5z2589w4xi9qg3sse3.apps.vivapayments.com",
ClientSecret = "CQtOvA8BficCU0t80buW5178D6610Q",
};
var vivaWalletService = new VivaWalletService(settings);
Will get access_token.
var result = await _vivaWalletService.GetAccessTokenAsync();
Will get access_token.
// You must obtain access_token first.
await _vivaWalletService.GetAccessTokenAsync();
// For example, if you want to create a payment for €230.587, you need to pass the value 23058
var request = new CreatePaymentOrderRequest()
{
Amount = 23058,
};
var result = await _vivaWalletService.CreatePaymentOrderAsync(request);
Contributions from others would be very much appreciated! Send pull request/ issue. Thanks!
Copyright (c) 2022 Petr Jílek. MIT Licensed, see LICENSE for details.