Repository navigation
مشکل در ارسال درخواست به سمت درگاه زرین پال #344
Replies: 1 comment 14 replies
|
درود |
14 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
من روی لوکال تمامی کد های مربوط به ارسال درخواست به سمت درگاه رو پیاده سازی کردم برای تست که درصورت اکی بودن ببرم روی محیط اصلی ولی کد ها با ارور مواجه میشه و پیش نمیره
ارور مربوط به ارسال درخواست با _onlinePayment.RequestAsync و متن ارور هم "An unknown error is happened." هست
کد های اصلی
`
var callBackUrl = Url.Action("Callback", "Payment", null, Request.Scheme, Request.Host.Value);
var response = await _onlinePayment.RequestAsync(invoice =>
{
invoice.SetAmount(transaction.Price * 10)
.SetCallbackUrl(callBackUrl)
.SetTrackingNumber(transaction.Id)
.SetZarinPalData("شارژ کیف پول")
.UseZarinPal();
});;
if (response.Status == PaymentRequestResultStatus.Succeed)
{
await response.GatewayTransporter.TransportAsync();
}
`
متد کال بک
`
public async Task Callback()
{
var invoice =await _onlinePayment.FetchAsync();
var transaction = await _transactionService.GetTransaction((int)invoice.TrackingNumber);
if (transaction == null)
{
return NotFound();
}
}
`
کد های program.cs
builder.Services.AddParbad() .ConfigureGateways(gateways => { gateways.AddZarinPal() .WithAccounts(accounts => { accounts.AddInMemory(account => { account.IsSandbox = bool.Parse(builder.Configuration["GateWays:ZarinPal:SandBox"]); account.MerchantId = builder.Configuration["GateWays:ZarinPal:MerchantId"]; account.Name = "DefaultZarinPal"; }); }); }) .ConfigureStorage(storage => { storage.UseMemoryCache(); }) .ConfigureHttpContext(b => { b.UseDefaultAspNetCore(); });All reactions