-
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
yawaflua
committed
Mar 10, 2024
1 parent
9258cb8
commit a2b4865
Showing
8 changed files
with
398 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,79 @@ | ||
# Lava.NET | ||
# Lava.NET | ||
Áèáëèîòåêà äëÿ ðàáîòû ñ API ñàéòà lava.ru. | ||
Ïîêà ÷òî âåäåòñÿ ðàáîòà íàä áèçíåñ-÷àñòüþ API | ||
|
||
Ñîâåòóåòñÿ ïåðåä èñïîëüçîâàíèåì ïðî÷èòàòü [API ñàéòà lava.ru](https://dev.lava.ru/) | ||
# Ïðèìåðû | ||
## Óñòàíîâêà áèáèëîòåêè | ||
```bash | ||
dotnet add package Lava.NET | ||
``` | ||
### È èñïîëüçëîâàíèå â ïðîåêòå | ||
```cs | ||
using Lava.NET; | ||
public class Program | ||
{ | ||
public static async Task Main(string[] args) | ||
{ | ||
var publicLavaApi = new PublicLavaAPI("[ Âàø òîêåí ]"); | ||
// ... Âàøà ëîãèêà | ||
} | ||
} | ||
``` | ||
## Ïðèìåð èñïîëüçîâàíèÿ ñ ASP.NET ïðèëîæåíèåì: | ||
```cs | ||
// Startup.cs | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
var publicLavaApi = new PublicLavaAPI("[ Âàø òîêåí ]"); | ||
services.AddControllers(); | ||
services | ||
|
||
.AddSwaggerGen(); | ||
|
||
services | ||
// ...Íàñòðîéêà ïðèëîæåíèÿ | ||
.AddSingleton(publicLavaAPI); | ||
} | ||
``` | ||
|
||
## Ïðèìåð ðàáîòû ñ âåáõóêîì(.NET 8): | ||
```cs | ||
// PaymentController.cs | ||
[ApiController] | ||
[Route("/payment/")] | ||
public class PaymentController(PublicLavaAPI lavaAPI) : ControllerBase | ||
{ | ||
|
||
|
||
[HttpPost("lava")] | ||
public async Task<IActionResult> ValidatePaymentLava([FromBody] WebhookResponse webhookResponse) | ||
{ | ||
// Âàøà ëîãèêà | ||
return Ok(); // Îáÿçàòåëüíî îòâå÷àòü 200, èíà÷å âåáõóêè áóäóò ïðèõîäèòü ñíîâà è ñíîâà, äî 15 ðàç. | ||
} | ||
} | ||
``` | ||
|
||
## Ñîçäàíèå ññûëêè íà îïëàòó: | ||
```cs | ||
var publicLavaApi = new PublicLavaAPI("[Âàø òîêåí]"); | ||
var createdPayment = await publicLavaApi.CreatePaymentAsync( | ||
new (){ | ||
comment = "Îïëàòà ïîêóïêè â Telegram áîòå", // Íåîá. | ||
hook_url = $"https://example.com/api/payment/lava", // Íåîá. | ||
merchant_id = "AskMeAboutBOT", // Íåîá. | ||
merchant_name = "AskMeAboutBOT", // Íåîá. | ||
custom_fields = $"Ëþáûå êàñòîìíûå äàííûå, ïåðåäàâàåìûå â webhook", // Íåîá. | ||
success_url = $"https://example.com/", // Íåîá. | ||
sum = 39.00f, | ||
wallet_to = "R123123123" | ||
} | ||
); | ||
Console.Out.WriteLine(createdPayment.url); | ||
|
||
// >>> 'https://p2p.lava.ru/form?id=1ee31634-e3e0-34ce-1423-b5b4cb524c6a' | ||
``` |
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
Oops, something went wrong.