コード例 #1
0
        public EzPayInvoiceAllowanceResponse AllowanceIssueInvoice(ref EzPayInvoiceAllowanceIssueInfo ezPayInvoiceAllowanceIssueInfo, string checkcode)
        {
            var response = AllowanceIssueInvoice(ref ezPayInvoiceAllowanceIssueInfo);

            if (!Equals(response.Result.CheckCode, checkcode))
            {
                throw new Exception("CheckCode 比對失敗");
            }

            return(response);
        }
コード例 #2
0
        public EzPayInvoiceAllowanceResponse AllowanceIssueInvoice(ref EzPayInvoiceAllowanceIssueInfo ezPayInvoiceAllowanceIssueInfo)
        {
            ezPayInvoiceAllowanceIssueInfo.Version     = string.IsNullOrEmpty(ezPayInvoiceAllowanceIssueInfo.Version) ? _configService.EzPayInvoiceAllowanceIssueVersion : ezPayInvoiceAllowanceIssueInfo.Version;
            ezPayInvoiceAllowanceIssueInfo.RespondType = "JSON";
            ezPayInvoiceAllowanceIssueInfo.TimeStamp   = UnixDateTimeService.GetUNIX(DateTime.Now).ToString();

            EzPayInvoiceAllowanceResponse response = null;

            var request = new EzPayInvoiceRequest()
            {
                MerchantID_ = _configService.EzPayMerchantId,
                PostData_   = HashService.EncryptAESHex(ezPayInvoiceAllowanceIssueInfo.GetDataString(), _configService.EzPayHashKey, _configService.EzPayHashIv)
            };

            FormUrlEncodedContent formContent = new FormUrlEncodedContent(new[] {
                new KeyValuePair <string, string>(nameof(request.MerchantID_), request.MerchantID_),
                new KeyValuePair <string, string>(nameof(request.PostData_), request.PostData_)
            });

            string responseBody = HttpService.PostForm(_configService.EzPayInvoiceAllowanceIssue, formContent);

            if (!string.IsNullOrEmpty(responseBody))
            {
                var deserializeObj = JsonConvert.DeserializeObject <JObject>(responseBody);
                response = new EzPayInvoiceAllowanceResponse()
                {
                    Message = deserializeObj.GetValue("Message").ToString(),
                    Status  = deserializeObj.GetValue("Status").ToString()
                };

                if (response.IsSucceed)
                {
                    response.Result = JsonConvert.DeserializeObject <EzPayInvoiceAllowanceResult>(deserializeObj.GetValue("Result").ToString());
                }
            }

            return(response);
        }