ElectronicInvoice_TW 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package ElectronicInvoice_TW --version 1.0.4
NuGet\Install-Package ElectronicInvoice_TW -Version 1.0.4
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="ElectronicInvoice_TW" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ElectronicInvoice_TW --version 1.0.4
#r "nuget: ElectronicInvoice_TW, 1.0.4"
#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 ElectronicInvoice_TW as a Cake Addin
#addin nuget:?package=ElectronicInvoice_TW&version=1.0.4

// Install ElectronicInvoice_TW as a Cake Tool
#tool nuget:?package=ElectronicInvoice_TW&version=1.0.4
串接文件下載 電子發票查詢API 1.4.4
使用這個API框架很簡單 只須完成以下幾個步驟

目前把所有API相關的程式放在 ElectronicInvoice.Produce 專案中

  1. [預設]抓取WebConfig 財政部申請的appId和appKey
  2. ElectronicInvoice.Produce專案中創建兩個Model
  • 一個是財政部回應參數的Model (放在InvoiceResult資料夾中)
  • 一個是財政部所需參數的Model (放在Mapping資料夾中) 3. 創建一個要實作的Api物件並繼承ApiBase抽象類,並在泛型那邊指定所需 Model的類型 4. 在外部使用 InvoiceApiFactroy.GetProxyInstace 方法將傳入所需Model,經反射回應相對應的Api物件(依靠Model上註冊的apiType) 5. 使用Api物件.ExcuteApi方法 傳入所需Model 6. Webconfig中設置要請求的api連結
下面詳細說明使用方法已 "QryWinningList" 查詢中獎發票號碼清單為例子
  1. 打開webConfig輸入你的appKey和appId

<add key="GovAppId" value="" />

<add key="GovAPIKey" value=""/>

2-1. 一個是財政部所需參數的Model (放在Mapping資料夾中)

[ApiType(ApiType = typeof(QryWinningListApi), MockApiType = typeof(QryWinningListMockApi))]
public class QryWinningListModel
{
    public string invTerm { get; set; }
}

2-2. 一個是財政部回應參數的Model (放在InvoiceResult資料夾中)

public class QryWinningListViewModel
{
    public string code { get; set; }
    public string msg { get; set; }
    public string invoYm { get; set; }
    public string superPrizeNo { get; set; }
    public string spcPrizeNo { get; set; }
    public string spcPrizeNo2 { get; set; }
    public string spcPrizeNo3 { get; set; }
    public string firstPrizeNo1 { get; set; }
    public string firstPrizeNo2 { get; set; }
    public string firstPrizeNo3 { get; set; }
    public string firstPrizeNo4 { get; set; }
    public string firstPrizeNo5 { get; set; }
    public string firstPrizeNo6 { get; set; }
    public string firstPrizeNo7 { get; set; }
    public string firstPrizeNo8 { get; set; }
    public string firstPrizeNo9 { get; set; }
    public string firstPrizeNo10 { get; set; }
    public string sixthPrizeNo1 { get; set; }
    public string sixthPrizeNo2 { get; set; }
    public string sixthPrizeNo3 { get; set; }
    public string superPrizeAmt { get; set; }
    public string spcPrizeAmt { get; set; }
    public string firstPrizeAmt { get; set; }
    public string secondPrizeAmt { get; set; }
    public string thirdPrizeAmt { get; set; }
    public string fourthPrizeAmt { get; set; }
    public string fifthPrizeAmt { get; set; }
    public string sixthPrizeAmt { get; set; }
    public string sixthPrizeNo4 { get; set; }
    public string sixthPrizeNo5 { get; set; }
    public string sixthPrizeNo6 { get; set; }
}
  1. ElectronicInvoice.Produce專案中 qryInvDetailApi 類別 並繼承 ApiBase<qryInvDetailModel>在泛型上提供財政部所需參數Model的型別,在上面實現父類的 SetParamter 方法提供Paramter參數,而可以使用SortedDictionary 因為參數要按升冪排列
public class qryInvDetailApi : ApiBase<qryInvDetailModel>
{
    protected override string SetParamter(qryInvDetailModel model)
    {
        SortedDictionary<string, string> paramter = 
                   new SortedDictionary<string, string>();
        paramter["version"] = "0.3";
        paramter["action"] = "qryInvDetail";
        paramter["invTerm"] = model.invTerm;
        paramter["UUID"] = UUID;
        paramter["type"] = model.type;
        paramter["invNum"] = model.invNum;
        paramter["generation"] = model.generation;
        paramter["invTerm"] = model.invTerm;
        paramter["invDate"] = model.invDate;
        paramter["encrypt"] = model.encrypt;
        paramter["sellerID"] = model.sellerID;
        paramter["randomNumber"] = model.randomNumber;
        paramter["appID"] = GovAppId;
        return PraramterHelper.DictionaryToParamter(paramter);
    }
}
  1. ElectronicInvoice.Service專案中 EIvoiceService 使用工廠創建Api物件將所需參數Model傳入
  2. 使用回傳物件的ExcuteApi方法將所需參數Model傳入
  3. 在appSetting中設置 以api名稱為key,請求網址為value的設定
<appSettings>
    <add key="QryWinningListApi" value="https://www.einvoice.nat.gov.tw/PB2CAPIVAN/invapp/InvApp" />
</appSettings>

<br/>

2017/11/16 新增範例程式

EInvoiceDemo專案範例:

以下範例是呼叫【撈取中獎發票API】

//設定使用哪個抓取Setting類別
var setting  = new AppsettingConfig();

//建立工廠 將配置檔傳入建構子中
InvoiceApiFactroy factory = new InvoiceApiFactroy(setting);

//建立查詢參數  
//下面範例查詢 發票民國106年7.8月中獎發票
QryWinningListModel model = new QryWinningListModel()
{
    invTerm = "10608"
};

//在工廠中藉由傳入參數 取得Api產品
var api = factory.GetProxyInstace(model);

//api回傳結果
var result = api.ExcuteApi(model);

WebConfig配置

<appSettings>
  
  <add key="QryWinningListApi" value="https://www.einvoice.nat.gov.tw/PB2CAPIVAN/invapp/InvApp" />
  
  <add key="IsMockAPI" value="0" />
  
  <add key="GovAppId" value="" />
  <add key="GovAPIKey" value=""/>
</appSettings>
Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
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
1.5.5 397 12/4/2021
1.5.4 360 9/30/2021
1.5.3 385 6/22/2021
1.5.2 428 6/20/2021
1.5.1 391 1/5/2021
1.5.0 354 12/28/2020
1.1.0.5 456 9/4/2020
1.1.0.4 482 6/5/2020
1.1.0.3 449 6/5/2020
1.1.0.2 437 6/5/2020
1.1.0.1 439 6/5/2020
1.1.0 455 5/1/2020
1.0.9.8 499 4/30/2020
1.0.9.7 722 4/2/2019
1.0.9.6 598 4/2/2019
1.0.9.5 610 4/2/2019
1.0.9.4 594 3/29/2019
1.0.9.3 596 3/25/2019
1.0.9.2 578 3/25/2019
1.0.9.1 545 3/25/2019
1.0.9 568 3/24/2019
1.0.8 642 1/29/2019
1.0.7 625 1/29/2019
1.0.6 804 1/27/2019
1.0.5 677 1/19/2019
1.0.4 673 11/26/2018
1.0.3 690 11/25/2018
1.0.2 772 11/25/2018
1.0.1 752 11/25/2018
1.0.0 756 11/25/2018

Summary of changes made in this release of the package.