MoMoSdk 3.0.0
dotnet add package MoMoSdk --version 3.0.0
NuGet\Install-Package MoMoSdk -Version 3.0.0
<PackageReference Include="MoMoSdk" Version="3.0.0" />
<PackageVersion Include="MoMoSdk" Version="3.0.0" />
<PackageReference Include="MoMoSdk" />
paket add MoMoSdk --version 3.0.0
#r "nuget: MoMoSdk, 3.0.0"
#:package MoMoSdk@3.0.0
#addin nuget:?package=MoMoSdk&version=3.0.0
#tool nuget:?package=MoMoSdk&version=3.0.0
Welcome to MoMoSdk!
MoMoSdk is a library for interact with MoMo . wallet APIs
Setting
following appsettings.json file:
{
"MoMoPayment": {
"Endpoint": "https://test-payment.momo.vn/v2/gateway/api",
"AccessKey": "mTCKt9W3eU1m39TW",
"SecretKey": "SetA5RDnLHvt51AULf51DyauxUo3kDU6",
"PartnerCode": "MOMOLRJZ20181206",
"PartnerName": "PRUgift",
"StoreId": "",
"RedirectUrl": "https://localhost:7244/Redirect",
"IpnUrl": "https://3525-14-231-221-55.ap.ngrok.io/api/InstantPaymentNotification"
}
}
Endpoint: MoMo's API AccessKey: your AccessKey SecretKey: your SecretKey PartnerCode: your PartnerCode PartnerName: your PartnerName StoreId: your StoreId RedirectUrl: A partner's URL. This URL is used to redirect from MoMo page to partner's page after customer's payment. IpnUrl: Partner API. Used by MoMo to submit payment results by method (server-to-server) method
Config
add Setting into Program.cs
builder.Services.AddMoMoSdk();
Create Order
add MoMo service
private readonly IMoMoService _momoService;
crete model:
public class CreateOrderViewModel
{
public MoMoRequestType RequestType { get; set; }
public string OrderId { get; set; }
public string OrderInfo { get; set; }
public long Amount { get; set; }
public DeliveryInfo DeliveryInfo { get; set; }
public UserInfo UserInfo { get; set; }
}
create order
PaymentResponse paymentResponse = await _momoService.CreatePayment( model.RequestType,model.OrderId,model.Amount,model.OrderInfo,MoMoCodeHelper.Base64Encode("{}"),new List<Item>(),model.DeliveryInfo,model.UserInfo);
Query Order
QueryResponse queryResponse = await _momoService.QueryPayment(orderId);
Handle Redirect
public void Index([FromQuery] RedirectQuery query)
{
if (_momoService.CheckRedirectUrl(query))
{
//do somethings here
}
throw new Exception("Wrong Signature from MoMo Server");
}
Handle Instant Payment Notification
[HttpPost]
public StatusCodeResult Post([FromBody] IPNModel model)
{
if (_momoService.CheckIPN(model))
{
//do somethings here
}
return BadRequest();
}
Create Refund
Refund Model
public class RefundViewModel
{
public string OrderId { get; set; }
public long Amount { get; set; }
public long TransId { get; set; }
public string? Description { get; set; }
}
create request refund
RefundResponse paymentResponse = await _momoService.CreateRefund(model.OrderId,model.Amount,model.TransId,model.Description);
Query Refund
QueryRefundResponse queryRefundResponse = await _momoService.QueryRefund(orderId);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|