Example #1
0
        /// <summary>
        /// Api for retriving Use Voucher - Use Voucher
        /// </summary>
        /// <param name="apipaymentvoucherusepostrequestcontent"></param>
        /// <returns>ApiPaymentVoucherUsePostOKResponseContent</returns>
        public async Task <IHttpActionResult> Post(Models.ApiPaymentVoucherUsePostRequestContent apipaymentvoucherusepostrequestcontent)
        {
            // TODO: implement Post -route: api / Payment / Voucher / Use /
            // var result = new ApiPaymentVoucherUsePostOKResponseContent();
            //return Ok(result);
            var    resultinPmtDetails = new VoucherPaymentDetails();
            var    securityData       = new model.SecurityData();
            object securityObj;

            Request.Properties.TryGetValue("securityData", out securityObj);
            securityData = (model.SecurityData)securityObj;
            // securityData.RadixxToken = "4caf1207-c744-417d-8053-5a835f7d6a00";
            try
            {
                resultinPmtDetails = this._paymentTasks.AddVoucher(apipaymentvoucherusepostrequestcontent.VoucherRefNo.Trim(), apipaymentvoucherusepostrequestcontent.VoucherPin.Trim(), securityData);
                //this.UserSessionTasks.UserSession.VoucherSequenceNumber++;
            }

            //return this.VoucherInput();
            catch (RadixxVoucherException ex)
            {
                throw new Exception();
            }
            PaymentBuilder useVoucherBuilder = new PaymentBuilder();

            return(Ok(useVoucherBuilder.BuildUseVoucherResponse(resultinPmtDetails)));
        }
        /// <summary>
        /// Api for retriving Verify Voucher - Verify Voucher
        /// </summary>
        /// <param name="apipaymentvoucherverifypostrequestcontent"></param>
        /// <returns>ApiPaymentVoucherVerifyPostOKResponseContent</returns>
        public async Task <IHttpActionResult> Post(Models.ApiPaymentVoucherVerifyPostRequestContent requestContent)
        {
            // TODO: implement Post - route: api/Payment/Voucher/Verify/
            // var result = new ApiPaymentVoucherVerifyPostOKResponseContent();
            // return Ok(result);

            var result        = new ApiPaymentVoucherVerifyPostRequestContent();
            var resultinPrice = new Price();

            //var vm = new  UseVoucherViewModel { VoucherFormModel = formModel };
            // voucher number and pin is expected to be in uppercase.  Convert it here for convenience...
            requestContent.VoucherRefNo = requestContent.VoucherRefNo == null ? null : requestContent.VoucherRefNo.Trim().ToUpper();
            requestContent.VoucherPin   = requestContent.VoucherPin == null ? null : requestContent.VoucherPin.Trim().ToUpper();
            var    securityData = new model.SecurityData();
            object securityObj;

            Request.Properties.TryGetValue("securityData", out securityObj);
            securityData = (model.SecurityData)securityObj;
            try
            {
                resultinPrice = this._paymentTasks.GetVoucherValue(requestContent.VoucherRefNo, requestContent.VoucherPin, securityData);
            }
            catch (RadixxVoucherException ex)
            {
                throw new Exception();
            }
            var response = new PaymentBuilder().BuildVerifyVoucherResponse(resultinPrice, requestContent);

            return(Ok(response));
        }