Munewwer.LakalaPay.Core 0.25.4101

dotnet add package Munewwer.LakalaPay.Core --version 0.25.4101
                    
NuGet\Install-Package Munewwer.LakalaPay.Core -Version 0.25.4101
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Munewwer.LakalaPay.Core" Version="0.25.4101" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Munewwer.LakalaPay.Core" Version="0.25.4101" />
                    
Directory.Packages.props
<PackageReference Include="Munewwer.LakalaPay.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Munewwer.LakalaPay.Core --version 0.25.4101
                    
#r "nuget: Munewwer.LakalaPay.Core, 0.25.4101"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Munewwer.LakalaPay.Core@0.25.4101
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Munewwer.LakalaPay.Core&version=0.25.4101
                    
Install as a Cake Addin
#tool nuget:?package=Munewwer.LakalaPay.Core&version=0.25.4101
                    
Install as a Cake Tool

Munewwer.LakalaPay

Logo

简介

Munewwer.LakalaPay 是一个基于 .NET Standard 2.1 的拉卡拉支付 SDK,提供了对拉卡拉支付接口的完整封装,使开发者能够轻松集成拉卡拉支付功能到自己的应用中。

特性

  • 支持多种支付方式:主扫、被扫、合单支付等
  • 提供完整的交易功能:预下单、支付、查询、关单、撤销、退款等
  • 支持全报文加密模式
  • 支持主流支付渠道:微信、支付宝、银联等
  • 使用依赖注入模式,易于集成
  • 完善的类型定义和注释

安装

dotnet add package Munewwer.LakalaPay.Core
dotnet add package Munewwer.LakalaPay.Payments

快速开始

1. 配置服务

在 Startup.cs 或 Program.cs 中配置服务:

services.ConfigureLakalaPay(options =>
{
    options.AppId = "你的AppId";
    options.SerialNo = "证书序列号";
    options.Sm4Key = "国密4密钥";
    options.PlatformId = "平台ID";
    options.BindOrgCode = "绑定的机构编号";
    
    // 导入证书
    options.ImportPublicKey("公钥证书路径");
    options.ImportPrivateKey("私钥证书路径", "证书密码");
});

2. 使用服务

public class PaymentService
{
    private readonly ILakalaPayService _lakalaPayService;

    public PaymentService(ILakalaPayService lakalaPayService)
    {
        _lakalaPayService = lakalaPayService;
    }

    // 创建预订单(主扫模式)
    public async Task<string> CreatePreOrderAsync(string orderId, decimal amount, string subject)
    {
        var request = new LakalaPreOrderRequest
        {
            MerchantOrderId = orderId,
            Amount = (long)(amount * 100), // 转换为分
            Subject = subject,
            PayType = LakalaCardType.WechatPay, // 设置支付方式:微信支付
            NotifyUrl = "https://your-domain.com/notify"
        };
        
        var result = await _lakalaPayService.CreatePreOrderAsync(request);
        
        if (result.IsSuccess)
        {
            return result.Data.QrCodeUrl; // 返回二维码链接
        }
        
        throw new Exception($"创建预订单失败:{result.ReturnMsg}");
    }
    
    // 查询订单
    public async Task<LakalaQueryOrderResult> QueryOrderAsync(string orderId)
    {
        var request = new LakalaQueryOrderRequest
        {
            MerchantOrderId = orderId
        };
        
        var result = await _lakalaPayService.GetTradeQueryAsync(request);
        
        if (result.IsSuccess)
        {
            return result.Data;
        }
        
        throw new Exception($"查询订单失败:{result.ReturnMsg}");
    }
}

支持的支付方式

主扫支付(顾客扫商家)

// 创建预订单
var result = await _lakalaPayService.CreatePreOrderAsync(request);

// 加密模式
var result = await _lakalaPayService.CreateEncryptedPreOrderAsync(request);

被扫支付(商家扫顾客)

// 付款码支付
var result = await _lakalaPayService.CreateMicropayAsync(request);

// 加密模式
var result = await _lakalaPayService.CreateEncryptedMicropayAsync(request);

合单支付

// 主扫合单
var result = await _lakalaPayService.CreateMergePreOrderAsync(request);

// 被扫合单
var result = await _lakalaPayService.CreateMergeMicropayAsync(request);

其他操作

交易查询

var result = await _lakalaPayService.GetTradeQueryAsync(request);

关闭订单

var result = await _lakalaPayService.CloseTradeOrderAsync(request);

撤销交易

var result = await _lakalaPayService.RevokeTradeOrderAsync(request);

退款

// 普通退款
var result = await _lakalaPayService.RefundTradeOrderAsync(request);

// 合单退款
var result = await _lakalaPayService.RefundMergeTradeOrderAsync(request);

高级配置

切换环境

// 测试环境
LakalaPayServiceExtensions.Host = "https://test.wsmsd.cn/sit/api/v3/";

// 生产环境
LakalaPayServiceExtensions.Host = "https://s2.lakala.com/api/v3/";

自定义 HTTP 客户端

services.ConfigureLakalaPay(
    configureOptions: options => { /* 配置选项 */ },
    configureClient: client => 
    {
        client.Timeout = TimeSpan.FromSeconds(30);
        // 其他 HTTP 客户端配置
    }
);

支持与贡献

如果您发现任何问题或有改进建议,请提交 Issue 或 Pull Request。

许可证

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Munewwer.LakalaPay.Core:

Package Downloads
Munewwer.LakalaPay.Payments

拉卡拉支付开放平台SDK.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.25.4101 324 4/10/2025
0.25.4100 270 4/10/2025
0.25.4091 284 4/9/2025