48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using AyCode.Services.Loggers;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Http.Json;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TIAM.Entities.Transfers;
|
|
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
|
using TIAMWebApp.Shared.Application.Models;
|
|
using TIAMWebApp.Shared.Application.Utility;
|
|
using TIAM.Core.Loggers;
|
|
using TIAMWebApp.Shared.Application.Models.ClientSide.Payment;
|
|
using static System.Net.WebRequestMethods;
|
|
using Newtonsoft.Json;
|
|
using TIAM.Models.Dtos.Users;
|
|
|
|
namespace TIAMWebApp.Shared.Application.Services
|
|
{
|
|
public class SumupService
|
|
{
|
|
private readonly HttpClient _http;
|
|
private readonly ILogger _logger;
|
|
|
|
public SumupService(HttpClient http, IEnumerable<IAcLogWriterClientBase> logWriters)
|
|
{
|
|
_http = http;
|
|
_logger = new LoggerClient<TransferDataService>(logWriters.ToArray());
|
|
}
|
|
|
|
|
|
public async Task<string> CreatePaymentLinkAsync(Transfer transferToPay)
|
|
{
|
|
var url = $"{Setting.ApiBaseUrl}/{APIUrls.CreatePayment}";
|
|
//var url = $"{APIUrls.GetTransferDestinations}";
|
|
_logger.Info(url);
|
|
var response = await _http.PostAsJsonAsync(url, transferToPay);
|
|
|
|
if (response == null)
|
|
return "Not ok";
|
|
|
|
var result = await response.Content.ReadAsStringAsync();
|
|
var paymentLink = result;
|
|
return paymentLink;
|
|
}
|
|
}
|
|
}
|