Request by action - ShenTengTu/node-tw-e-invoice GitHub Wiki

Request by action

Common actionBusiness Entity action。您必須使用inquirer()聲明用戶身份來決定action類型。每個action都有由joi定義的特定請求參數模式。如果驗證失敗,您將得到ValidationError

There are Common action and Business Entity action.You must use inquirer() to declare user identity to decide action type.

Each action has specific request parameters schema defined by joi. You will get ValidationError if validate fail.

require('dotenv').config();
const {TaiwanEInvoice, InquirerIdentity, CarrierCardType}= require('node-tw-e-invoice');
const {Serial}= require('node-tw-e-invoice').APIUtil;
const EInvoice = new TaiwanEInvoice(process.env.APP_ID,process.env.API_KEY);
const serial = new Serial();
EInvoice.inquirer(process.env.UUID,InquirerIdentity.Common)
.action('qryCarrierAgg',{
  serial:serial.next(),
  cardType: CarrierCardType.Mobile,
  cardNo:'/AB56P5Q',
  timeStamp:1234567890,//if not use Date
  cardEncrypt:'password'
}).then((values)=>{
  let {path,method,param}  = values;
  param.timeStamp += 10;
  //start sending a request ...
}).catch((err)=>{
  let {name, details} = err;
  console.log(name);//ValidationError
  console.log(details[0].message);//"timeStamp" must be a valid date
});

All action and the its request parameters as below.

Common action

  • QryWinningList : Query prize numbers.
    /*查詢中獎發票號碼清單*/
    var parameters = {
      invTerm : '10108'//Invoice Term (yyyMM)
    }
    
  • qryInvHeader : Query invoice seller information.
    /*查詢發票表頭*/
    var parameters = {
      invDate:'2012/07/11'//Invoice Date (yyyy/MM/dd)
      invNum:'AB12345678',//Invoice number
      type:'Barcode',//Bar code type ('Barcode' | 'QRCode')
    }
    
  • qryInvDetail : Query invoice details(Only allow to query 99 time per invoice).
    /*查詢發票明細(只允許查詢每張發票99次)*/
    var parameters = {
      type:'Barcode',//Bar code type ('Barcode' | 'QRCode')
      invNum:'AB12345678',//Invoice number
      invTerm:'10108,',//Invoice Term (yyyMM) (require if type = 'Barcode')
      invDate:'2012/07/11',//Invoice Date (yyyy/MM/dd)
      encrypt:'...',//Invoice Verification code (require if type = 'QRCode')
      sellerID:'...',//Business Administration Number (require if type = 'QRCode')
      randomNumber:'0000'//4 digit random code of invoice
    }
    
  • qryLoveCode : Query registered Non-profit organizations.
    /*愛心碼查詢*/
    var parameters = {
      qKey:'621'//Query keyword of Non-profit organizations
    }
    
  • carrierInvChk : Query seller information about invoices held in the carrier.
    /*載具發票表頭查詢*/
    var parameters = {
      cardType:'3J0002',//Carrier card type
      cardNo:'/AB56P5Q',//Carrier Card barcode
      expTimeStamp:new Date(...),//Expiration Unix time stamp
      timeStamp:new Date(...),//Transfer time stamp
      startDate:'2012/07/01',//Query start time
      endDate:'2012/07/31',//Query end time
      onlyWinningInv:'Y',//Only return the winning information ('Y' | 'N')
      cardEncrypt:'password'//Carrier Card or Mobile barcode password
    }
    
  • carrierInvDetail : Query details about invoices held in the carrier.
    /*載具發票明細查詢*/
    var parameters = {
      cardType:'3J0002',//Carrier card type
      cardNo:'/AB56P5Q',//Carrier Card barcode
      expTimeStamp:new Date(...),//Expiration Unix time stamp
      timeStamp:new Date(...),//Transfer time stamp
      invNum:'AB12345678',//Invoice number
      invDate:'2012/07/11',//Invoice Date (yyyy/MM/dd)
      sellerName:'統一超商',//Seller's name (Optional)
      amount:'25',//Money amount (Optional)
      cardEncrypt:'password'//Carrier Card or Mobile barcode password
    }
    
  • carrierInvDnt : Donate the invoice to the social welfare group.
    /*載具發票捐贈*/
    var parameters = {
      serial:'0000000001',//Transfer serial number (10 digits)
      cardType:'3J0002',//Carrier card type
      cardNo:'/AB56P5Q',//Carrier Card barcode
      expTimeStamp:new Date(...),//Expiration Unix time stamp
      timeStamp:new Date(...),//Transfer time stamp
      invNum:'AB12345678',//Invoice number
      invDate:'2012/07/11',//Invoice Date (yyyy/MM/dd)
      npoBan:'81582505',//Non-profit organizations BAN
      cardEncrypt:'password',//Carrier Card or Mobile barcode password
    }
    
  • qryCarrierAgg : Query valid aggregate carriers.
    /*手機條碼歸戶載具查詢*/
    var parameters = {
      serial:'0000000001',//Transfer serial number (10 digits)
      cardType:'3J0002',//Carrier card type
      cardNo:'/AB56P5Q',//Carrier Card barcode
      timeStamp:new Date(...),//Transfer time stamp
      cardEncrypt:'password',//Carrier Card or Mobile barcode password
    }
    
  • generalCarrierReg : Mobile barcode registration without enter password.
    /*手機條碼註冊*/
    var parameters = {
      serial:'0000000001',//Transfer serial number (10 digits)
      email:'[email protected]',//E-mail for register
      isVerification:'N',//email is verified or not ('Y' | 'N')
      phoneNo:'0910000000',//Moblie number
      timeStamp:new Date(...),//Transfer time stamp
    
    }
    
  • generalCarrierBank : Binding financial account or electronic payment account.
    /*手機條碼綁定金融帳戶或電子支付帳戶*/
    var parameters = {
      serial:'0000000001',//Transfer serial number (10 digits)
      accountNo:'123456789012',//Bank account (require if updateAcc = 'Y')
      bankNo:'001',////SWIFT Code (require if updateAcc = 'Y')
      cardEncrypt:'password',//Carrier Card or Mobile barcode password
      cardNo:'/AB56P5Q',//Carrier Card barcode
      cardType:'3J0002'//Carrier card type
      enableRemit:'Y'//Enable remittance or not
      expTimeStamp:new Date(...),//Expiration Unix time stamp
      timeStamp:new Date(...),//Transfer time stamp
      rocID:'A123456789',//R.O.C. ID number (require if updateAcc = 'Y')
      updateAcc:'Y',//Upadte annotation
      userIdType:'1',//identity, '1' = Citizen | '2' = Foreigner (require if updateAcc = 'Y')
      winnerName:'王xx',//Winner name (require if updateAcc = 'Y')
      winnerPhone:'0910000000',//Winner phone (require if updateAcc = 'Y')
    
    }
    
  • getBarcode : Query mobile barcode.
    /*查詢手機條碼*/
    var parameters = {
      phoneNo:'0910000000',//Moblie number
      verificationCode:'password',//Mobile barcode password
      timeStamp:new Date(...)//Transfer time stamp
    }
    
  • pubCarVerReg : Mobile barcode registration need enter password.
    /*手機條碼及驗證碼註冊*/
    var parameters = {
      serial:'0000000001',//Transfer serial number (10 digits)
      email:'[email protected]',//E-mail for register
      isVerification:'N',//email is verified or not ('Y' | 'N')
      phoneNo:'0910000000',//Moblie number
      verify:'password1',//Mobile barcode password (8-16 length,number & alphabet need.)
      timeStamp:new Date(...),//Transfer time stamp
    
    }
    
  • changeVer : Change password.
    /*變更手機條碼驗證碼*/
    var parameters = {
      serial:'0000000001',//Transfer serial number (10 digits)
      cardNo:'/AB56P5Q',//Carrier Card barcode
      phoneNo:'0910000000',//Moblie number
      newVerify:'password2',//New Mobile barcode password (8-16 length,number & alphabet need)
      oldVerify:'password1'//Old Mobile barcode password
      timeStamp:new Date(...),//Transfer time stamp
    
    }
    
  • forgetVer : Forget password.
    /*忘記手機條碼驗證碼*/
    var parameters = {
      serial:'0000000001',//Transfer serial number (10 digits)
      email:'[email protected]',//E-mail for register
      phoneNo:'0910000000',//Moblie number
      timeStamp:new Date(...),//Transfer time stamp
    
    }
    
  • carrierAction : Carrier aggregate to mobile barcode.
    /*載具歸戶手機條碼*/
    var parameters = {
      serial:'0000000001',//Transfer serial number (10 digits)
      cardType:'CQ0001',//Carrier card type
      cardNo:'/CD12E3F',//Carrier Card barcode
      verifyCode:'password1',//Carrier Card password
      carrierName:'自訂載具名稱'//Custom carriere name
      publicCardType:'3J0002',//Public carrier Card type
      publicCardNo:'/AB56P5Q',//Public carrier Card barcode
      publicVerifyCode:'password2',//Public carrier Card password
      timeStamp:new Date(...),//Transfer time stamp
    
    }
    

Business Entity action

  • bcv : Verify whether the mobile barcode exists on the e-invoice platform.
    /*手機條碼驗證*/
    var parameters = {
      barCode:'/CD12E3F'//Mobile barcode
    }
    
  • preserveCodeCheck : Verify whether the LoveCode exists on the e-invoice platform.
    /*愛心碼驗證*/
    var parameters = {
      pCode:'/CD12E3F'//Non-profit organizations' Love Code
    }
    
  • cardBin : Query BIN of the credit card carrier.
    /*信用卡載具BIN查詢*/
    var parameters = {
      bankNo:'/CD12E3F'//SWIFT Code
    }
    
  • creditCardBan : Query bankNo of the credit card carrier.
    /*信用卡載具發卡銀行查詢*/
    var parameters = {}//just only stable parameter
    
  • qryRecvRout : Query receive route status.
    /*查詢該營業人是否設定接收方式*/
    var parameters = {
      ban:'00007102',//Business Administration Number
      serial:'0000000001',//Transfer serial number (10 digits)
      timeStamp:new Date(...),//Transfer time stamp
    }
    
  • qryBanUnitTp : Query whether is business entity.
    /*查詢該統一編號是否為營業人*/
    var parameters = {
      ban:'00007102',//Business Administration Number
      serial:'0000000001',//Transfer serial number (10 digits)
      timeStamp:new Date(...),//Transfer time stamp
    }