namespace HiVakil.Infrastructure.Services; public class ZarinpalService : IPaymentService { private readonly IRestApiWrapper _restApiWrapper; private readonly IMediator _mediator; private readonly SiteSettings _siteSettings; public ZarinpalService(IRestApiWrapper restApiWrapper, IOptionsSnapshot snapshot, IMediator mediator) { _restApiWrapper = restApiWrapper; _mediator = mediator; _siteSettings = snapshot.Value; } public async Task GetPaymentLinkAsync(double amount,string factorNumber, Guid orderId, Guid userId, string phoneNumber , string fullName , CancellationToken cancellationToken = default) { var request = new ZarinaplPaymentLinkRequest { description = $"پرداخت {amount.ToString("N0")} ریال توسط {fullName} با شماره تماس {phoneNumber} برای سفارش با شماره {factorNumber}", amount = (int)amount, callback_url = Path.Combine(_siteSettings.BaseUrl, "api", "accounting", "pay", "verify"), //merchant_id = "4292b845-b510-4d1d-8ee2-097499b198e5", metadata = new ZarinaplPaymentLinkRequestMetadata { mobile = phoneNumber } }; var response = await _restApiWrapper.ZarinpalRestApi.GetPaymentLinkAsync(request); if (response.data.code != 100) throw new AppException($"Exception in get link from zarinpal | {response.data.message}"); string link = $"https://www.zarinpal.com/pg/StartPay/{response.data.authority}"; return link; } public async Task> VerifyPaymentAsync(string authority, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } }