Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

خطا در متد Fetch #394

Open
zamani3270 opened this issue Sep 15, 2024 · 5 comments
Open

خطا در متد Fetch #394

zamani3270 opened this issue Sep 15, 2024 · 5 comments
Assignees
Labels
question Questions about Parbad

Comments

@zamani3270
Copy link

سلام وقتتون بخیر
من موقع استفاده از متد FetchAsync با Token خطا دریافت میکنم:
No invoice found with the token f9e3784541634fd89d854db3743f2e0a
در حالیکه این توکن در جدول payment وجود داره
در ضمن از customStorage استفاده کردم و موقع RequestAsync به درستی در جدول Payment ذخیره رو انجام میده.

ممنون میشم راهنمایی کنید

@zamani3270 zamani3270 added the question Questions about Parbad label Sep 15, 2024
@Sina-Soltani
Copy link
Owner

درود
مشکل از پیاده سازی custom storage شما هست و باید ببینید مشکل کجاست.
در صورت تمایل میتونید کدهای پیاده سازی رو اینجا قرار بدید تا نگاهی بندازم

@zamani3270
Copy link
Author

سلام خیلی ممنونم
var parbadBuilder = ParbadBuilder.CreateDefaultBuilder();

parbadBuilder.ConfigureGateways(gateways =>
{
gateways.AddMellat().WithAccounts(source => source.Add(ServiceLifetime.Transient));
gateways.AddParbadVirtual().WithOptions(options => options.GatewayPath = "/WriteAPathHere"); ;
gateways.AddMelli();
gateways.AddZarinPal().WithAccounts(source => source.Add(ServiceLifetime.Transient));

}).ConfigureHttpContext(builder => builder.UseDefaultAspNetCore())
   .ConfigureStorage(builder => builder.AddStorage<ParbadRepository>(ServiceLifetime.Transient));

_builder.Populate(parbadBuilder.Services);

این هم ایمپلیمنت IStorage :
public class ParbadRepository : IStorage
{
private readonly Models.PaymentDbContext _dbContext;

 public ParbadRepository(Models.PaymentDbContext dbContext)
 {
     _dbContext = dbContext;
 }

 public IQueryable<Parbad.Storage.Abstractions.Models.Payment> Payments => new List<Parbad.Storage.Abstractions.Models.Payment>().AsQueryable();

 public IQueryable<Parbad.Storage.Abstractions.Models.Transaction> Transactions => new List<Parbad.Storage.Abstractions.Models.Transaction>().AsQueryable();

 public async Task CreatePaymentAsync(Parbad.Storage.Abstractions.Models.Payment payment, CancellationToken cancellationToken = default)
 {
     Models.Payment paymentModel = new Models.Payment()
     {
         TrackingNumber = payment.TrackingNumber,
         Amount = payment.Amount,
         IsPaid = payment.IsPaid,
         Token = payment.Token,
         GatewayName = payment.GatewayName,
         IsCompleted = payment.IsCompleted,
     };

     paymentModel.Transactions.Add(new Models.Transaction() { Amount = payment.Amount });
     await _dbContext.Payments.AddAsync(paymentModel);
 }

 public async Task CreateTransactionAsync(Parbad.Storage.Abstractions.Models.Transaction transaction, CancellationToken cancellationToken = default)
 {
    
 }

 public Task DeletePaymentAsync(Parbad.Storage.Abstractions.Models.Payment payment, CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }

 public Task DeleteTransactionAsync(Parbad.Storage.Abstractions.Models.Transaction transaction, CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }

 public async Task UpdatePaymentAsync(Parbad.Storage.Abstractions.Models.Payment payment, CancellationToken cancellationToken = default)
 {
     await _dbContext.SaveChangesAsync();
 }

 public async Task UpdateTransactionAsync(Parbad.Storage.Abstractions.Models.Transaction transaction, CancellationToken cancellationToken = default)
 {
     await _dbContext.SaveChangesAsync();
 }

}

اینجا هم متد Verify:

var invoice = await _onlinePayment.FetchAsync();

if (invoice.Status != PaymentFetchResultStatus.ReadyForVerifying)
{
var isAlreadyVerified = invoice.IsAlreadyVerified;
return false;
}

var verifyResult = await _onlinePayment.VerifyAsync(invoice);

که خط اول خطا میده که با توکن موردی پیدا نشد در حالیکه توکن توی دیتابیس هست

@Sina-Soltani
Copy link
Owner

درود
شما هر ۲ پراپرتی Payments و Transactions رو برابر با یک لیست خالی قرار دادید.
این مقادیر باید از پایگاه داده گرفته بشه

@zamani3270
Copy link
Author

خیلی ممنونم درست شد

فقط یه مورد دیگه اینکه الان دارم درگاه تستی رو چک میکنم و خروجی status مربوط به متد Fetch
Faild
برمیگرده چطور میتونم state درستش رو تست کنم؟

@Sina-Soltani
Copy link
Owner

لطفا نمونه پروژه ها رو مشاهده کنید و ببینید مشکل کار کجاست

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions about Parbad
Projects
None yet
Development

No branches or pull requests

2 participants