public async Task <PaymentInfoResponse> DoTransaction(string baseUrl, PaymentInfoRequest paymentInfoRequest) { paymentInfoRequest.SystemTraceNr = RandomNumber(1000, 10000); paymentInfoRequest.ProcessingCode = RandomNumber(999, 9999).ToString(); PaymentInfoCommand paymentInfoCommand = new PaymentInfoCommand(); using (var httpClient = new HttpClient()) { using (var keyResponse = await httpClient.GetAsync(baseUrl + "/GetKey")) { string apiGetKeyResponse = await keyResponse.Content.ReadAsStringAsync(); string key = JObject.Parse(apiGetKeyResponse)["GetKeyResult"].ToString(); paymentInfoCommand.Key = key; paymentInfoCommand.EncyptedBody = _encryptionService.Encrypt(JsonConvert.SerializeObject(paymentInfoRequest), key); StringContent content = new StringContent(JsonConvert.SerializeObject(paymentInfoCommand), Encoding.UTF8, "application/json"); using (var response = await httpClient.PostAsync(baseUrl + "/Pay", content)) { string apiResponse = await response.Content.ReadAsStringAsync(); PaymentInfoResponse paymentInfoResponse = JsonConvert.DeserializeObject <PaymentInfoResponse>(apiResponse); return(paymentInfoResponse); } } } }
public PaymentInfoResponse Pay(PaymentInfoCommand paymentInfoCommand) { var decryptedPaymentInfo = new AesService().Decrypt(paymentInfoCommand.EncyptedBody, paymentInfoCommand.Key); PaymentInfo paymentInfo = JsonConvert.DeserializeObject <PaymentInfo>(decryptedPaymentInfo); string approvalCode = createApprovalCode(paymentInfo); var response = new PaymentInfoResponse() { ApprovalCode = approvalCode, DateTime = DateTime.Now, Message = "SUCCESS", ResponseCode = ResponseCode.SUCCESS.ToString() }; return(response); }
public ActionResult Complete() { //send pole display var json = Admin.GetPoleDisplay(); var response = TranCloudWebRequest.DoTranCloudRequest(json); //send credit sale json = TranCloudTransaction.GetTranCloudCreditSaleTransaction(); response = TranCloudWebRequest.DoTranCloudRequest(json); var paymentResponse = PaymentInfoResponse.MapTranCloudResponse(response); //pop cash drawer json = Admin.GetDrawerOpen(); response = TranCloudWebRequest.DoTranCloudRequest(json); paymentResponse = new PaymentInfoResponse(); return(View(paymentResponse)); }
public async Task <IActionResult> Index([Bind] PaymentInfoViewModel paymentInfo) { if (ModelState.IsValid) { PaymentInfoRequest paymentInfoRequest = new PaymentInfoRequest() { AmountTrxn = paymentInfo.AmountTrxn, CardHolder = paymentInfo.CardHolder, CurrencyCode = paymentInfo.CurrencyCode, CardNo = paymentInfo.CardNo, FunctionCode = paymentInfo.FunctionCode }; PaymentInfoResponse paymentInfoResponse = await _paymentService.DoTransaction(_configuration["PaymentServiceBaseUrl"].ToString(), paymentInfoRequest); return(RedirectToAction("SuccessPayment", new { code = paymentInfoResponse.ApprovalCode })); } else { //TODO add view error message return(View()); } }
protected void callDoPaymentPro(int pmi) { pmi = int.Parse(this.Request.QueryString["payment_method_id"]); string tm = DateTime.Now.ToString(); PaymentInfoRequest url = new PaymentInfoRequest(); url.api_username = SessionKey.apiuser; url.api_password = SessionKey.apipass; url.bank_payment_method_id = pmi.ToString(); url.bk_seller_email = SessionKey.Business; url.currency_code = "VND"; url.escrow_timeout = ""; url.extra_fields_value = ""; url.merchant_id = SessionKey.merchantid; url.order_description = ""; url.order_id = tm; url.payer_email = Session["email_payer"].ToString(); url.payer_message = ""; url.payer_name = "test"; url.payer_phone_no = Session["phone"].ToString(); url.payment_mode = "1"; url.shipping_address = ""; url.shipping_fee = ""; url.tax_fee = ""; url.total_amount = Session["price_bk"].ToString(); url.url_return = ""; //url.url_return = "http://localhost:52996/WebSite3/Baokim.aspx"; BKPaymentProService2 bk=new BKPaymentProService2(); PaymentInfoResponse baokim = new PaymentInfoResponse(); baokim=bk.DoPaymentPro(url); string link = baokim.url_redirect; if (baokim.error_code != "0") { throw new Exception(baokim.error_message); } else { Response.Redirect(baokim.url_redirect); } }