TrustyPay.Crypto.Banks.ICBC 0.0.6

dotnet add package TrustyPay.Crypto.Banks.ICBC --version 0.0.6                
NuGet\Install-Package TrustyPay.Crypto.Banks.ICBC -Version 0.0.6                
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="TrustyPay.Crypto.Banks.ICBC" Version="0.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TrustyPay.Crypto.Banks.ICBC --version 0.0.6                
#r "nuget: TrustyPay.Crypto.Banks.ICBC, 0.0.6"                
#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.
// Install TrustyPay.Crypto.Banks.ICBC as a Cake Addin
#addin nuget:?package=TrustyPay.Crypto.Banks.ICBC&version=0.0.6

// Install TrustyPay.Crypto.Banks.ICBC as a Cake Tool
#tool nuget:?package=TrustyPay.Crypto.Banks.ICBC&version=0.0.6                

工行接口客户端类

  • e企付客户端类

  1. EPayHttpClient类的使用示例:

    using TrustyPay.Crypto.Http;
    using TrustyPay.Crypto.Banks.ICBC;
    
    var client = new EPayHttpClient(
        "https://工行接口生产地址",
        new EPayConfig()
        {
            AppId = "<用户e企付AppId>",
            PublicKeyFromBank = "<工行公钥>".FromBase64(),
            PrivateKey = "<用户e企付私钥>".FromBase64()
        });
    
    try
    {
        var result = await client.PostAsync<OrderResult>(
            "/api/mybank/pay/cpay/cporderquery/V1",
            new OrderQuery(
                "<用户协议编号>", "<order code>", "<partner seq>"
            )
        );
    }
    catch (InvalidSignatureException se)
    {
        Console.WriteLine("signature is incorrect!!!");
        return;
    }
    catch (IncorrectResultException re)
    {
        Console.WriteLine("some errors occured!!!");
        return;
    }
    
  2. OrderQuery类定义:

    using Newtonsoft.Json;
    using TrustyPay.Crypto.Banks.ICBC;
    
    public class OrderQuery : IMessageIdentity
    {
        public OrderQuery(string argeeCode, string orderCode, string seq)
        {
            ArgeeCode = argeeCode;
            OrderCode = orderCode;
            PartnerSeq = seq;
        }
    
        [JsonProperty("agreeCode")]
        public string ArgeeCode { get; set; }
    
        [JsonProperty("orderCode")]
        public string OrderCode { get; set; }
    
        [JsonProperty("partnerSeq")]
        public string PartnerSeq { get; set; }
    
        public string MessageId { get; set; } = Guid.NewGuid().ToString("N");
    }
    
  3. OrderResult类定义:

    using Newtonsoft.Json;
    using TrustyPay.Crypto.Banks.ICBC;
    
    public class OrderResult : ResultObjectBase
    {
        [JsonProperty("orderCurr")]
        public string Currency { get; set; }
    
        [JsonProperty("goodsList")]
        public JObject[] Goods { get; set; }
    }
    
  • e钱包客户端类

  1. EWalletHttpClient类的使用示例:

    using TrustyPay.Crypto.Http;
    using TrustyPay.Crypto.Banks.ICBC;
    
    var client = new EWalletHttpClient(
        "https://工行接口生产地址",
        new EWalletConfig()
        {
            AppId = "<用户e钱包AppId>",
            PublicKeyFromBank = "<工行公钥>".FromBase64(),
            PrivateKey = "<用户e钱包私钥>".FromBase64(),
            SM2PrivateKey = "<用户sm2私钥>".FromHex(),
            SM2PublicKeyFromBank = "<工行e钱包sm2公钥>".FromHex()
        });
    
    try
    {
        var result = await client.PostAsync<WalletBalanceResult>(
            "/api/settlement/account/balance/V1/query",
            new WalletBalanceQuery
            {
                CorpNumber = "<用户e钱包AppId>",
                TxDate = DateTime.Now.ToString("yyyy-MM-dd"),
                TxTime = DateTime.Now.ToString("HH:mm:ss"),
                CorpDate = DateTime.Now.ToString("yyyy-MM-dd"),
                SerialNumber = Guid.NewGuid().ToString("N"),
                MediumId = "<e钱包卡号>",
            }
        );
    }
    catch (InvalidSignatureException se)
    {
        Console.WriteLine("signature is incorrect!!!");
        return;
    }
    catch (HttpResponseException re)
    {
        Console.WriteLine(re.Message);
        return;
    }
    
  2. WalletBalanceQuery类定义:

    using Newtonsoft.Json;
    using TrustyPay.Crypto.Http;
    using TrustyPay.Crypto.Banks.ICBC;
    
    public class WalletBalanceQuery : ISecretKey
    {
        /// <summary>
        /// 合作方机构编号
        /// </summary>
        [JsonProperty("corp_no")]
        public string CorpNumber { get; set; }
    
        /// <summary>
        /// 合作方交易日期	2017-03-02
        /// </summary>
        [JsonProperty("trx_acc_date")]
        public string TxDate { get; set; }
    
        /// <summary>
        /// 合作方交易时间	10:38:01
        /// </summary>
        [JsonProperty("trx_acc_time")]
        public string TxTime { get; set; }
    
        /// <summary>
        /// 合作方工作日期
        /// </summary>
        [JsonProperty("corp_date")]
        public string CorpDate { get; set; }
    
        /// <summary>
        /// 合作方交易单号
        /// </summary>
        [JsonProperty("corp_serno")]
        public string SerialNumber { get; set; }
    
        /// <summary>
        /// 外部服务代码
        /// </summary>
        [JsonProperty("out_service_code")]
        public string ServiceCode { get; set; } = "querybalance";
    
        /// <summary>
        /// 工行联名卡号(支持加密传输,Base64编码)
        /// </summary>
        [JsonProperty("medium_id")]
        [Encryption]
        public string MediumId { get; set; }
    
        /// <summary>
        /// 币种
        /// </summary>
        [JsonProperty("ccy")]
        public int Currency { get; set; } = 1;
    
        /// <summary>
        /// sm4对称密钥
        /// </summary>
        [JsonProperty("secret_key")]
        public string SecretKey { get; set; }
    
        /// <summary>
        /// 卡号哈希值
        /// </summary>
        [JsonProperty("medium_id_hash")]
        public string MediumIdHash { get; set; }
    }
    
  3. WalletBalanceResult类定义:

    using Newtonsoft.Json;
    using TrustyPay.Crypto.Http;
    using TrustyPay.Crypto.Banks.ICBC;
    
    public class WalletBalanceResult : ResultObjectBase, ISecretKey
    {
        [JsonProperty("account_balance")]
        public string Balance { get; set; }
    
        [JsonProperty("medium_status")]
        public string Status { get; set; }
    
        [JsonProperty("cust_name")]
        [Encryption]
        public string CustomerName { get; set; }
    
        [JsonProperty("secret_key")]
        public string SecretKey { get; set; }
    }
    
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.0.6 508 7/15/2022
0.0.4 420 6/25/2022
0.0.3 414 6/10/2022
0.0.2 396 6/6/2022
0.0.1 401 6/1/2022