easyabp / paymentservice Goto Github PK
View Code? Open in Web Editor NEWAn abp application module that provides payment service.
License: MIT License
An abp application module that provides payment service.
License: MIT License
需评估:
if (dict.GetOrDefault("result_code") != "SUCCESS")
仅能留下一个,是选择抛错,还是选择回滚退款请求?return_code
和return_msg
?Relate to the abandoned issue: #7
Handle the CancelOrRefundPaymentEto
event, try to cancel the payment, refund it if the payment is already done.
一些先使用后付费的场景很容易让余额低于0。比如云服务之类的。
public void ChangeBalance(decimal changedBalance)
{
var newBalance = decimal.Add(Balance, changedBalance);
if (!newBalance.IsBetween(PrepaymentConsts.AccountMinBalance, PrepaymentConsts.AccountMaxBalance))
{
throw new AmountOverflowException(PrepaymentConsts.AccountMinBalance,
PrepaymentConsts.AccountMaxBalance);
}
if (newBalance < LockedBalance)
{
throw new LockedBalanceIsGreaterThenBalanceException(LockedBalance, newBalance);
}
Balance = newBalance;
}
这里限制死了感觉会不太方便
In the previous design, we get ExtraProperties from the user's input during the Payment entity creation and insert it into the entity without validation so users may input bad ExtraProperties.
In the new design, we create Payment entities without ExtraProperties input and get it in IPaymentAppService.PayAsync method.
It is a good way to resolve: #8
在EasyAbp.Eshop.Payments 版本3.5.0中发起退款/api/e-shop/payments/refund,抛出异常:
System.ObjectDisposedException: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it (or one of its parent scopes) has already been disposed.
at Autofac.Core.Lifetime.LifetimeScope.ThrowDisposedException()
at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable
1 parameters)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Volo.Abp.ObjectMapping.DefaultObjectMapper.Map[TSource,TDestination](TSource source)
at Volo.Abp.BackgroundJobs.BackgroundJobStore.InsertAsync(BackgroundJobInfo jobInfo)
at Volo.Abp.BackgroundJobs.DefaultBackgroundJobManager.EnqueueAsync(String jobName, Object args, BackgroundJobPriority priority, Nullable1 delay) at Volo.Abp.BackgroundJobs.DefaultBackgroundJobManager.EnqueueAsync[TArgs](TArgs args, BackgroundJobPriority priority, Nullable
1 delay)
at EasyAbp.PaymentService.WeChatPay.WeChatPayPaymentServiceProvider.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Volo.Abp.Uow.UnitOfWork.OnCompletedAsync()
at Volo.Abp.Uow.UnitOfWork.CompleteAsync(CancellationToken cancellationToken)
at Volo.Abp.AspNetCore.Uow.AbpUnitOfWorkMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
Publish a PaymentCanceledEto
after the IPaymentManager.CompleteCancelAsync()
method executed.
Relate to: EasyAbp/EShop#40
This measure was added to reduce invalid payments.
Recently using this module with a multi-tenant project I found when I split tenant database, no entries were found in tenant database. It should be caused by Missing IMultiTenant interface on Payment and Refund Entity.
public class Payment : FullAuditedAggregateRoot<Guid>, IPayment
PaymentItemId
from Refund aggregate root.Relate to: EasyAbp/EShop#52
AccountId
property.AccountId
column.We should use NodaMoney to validate money values.
Refer to EasyAbp/EShop#175.
In a multi-tenant environment, the payment entity is always inserted into the host database instead of the tenant db. The problem only occurs in paymentservicecontext and not exist in wechat or prepayment context db.
Use WeChat's "closeorder" API to cancel a payment order, see https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_3
It requires to be used 5 minutes after the order is successfully placed, so we can just TRY to close it.
Handle it and use IPaymentManager.CancelAsync()
method to cancel a payment.
It is a dangerous operation, but it must exist.
IPaymentManager.CancelAsync()
method.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.