protected void BtnPayBox_Click(object sender, EventArgs e) { RequestPayment RequestPayment = new RequestPayment(); RequestPayment.PartnerAPIId = PARTNER_API_ID; RequestPayment.PartnerAPIKey = PARTNER_API_KEY; RequestPayment.PaymentType = Convert.ToInt32(Payment_Type.Text.Trim()); RequestPayment.PgCode = PGCode.Text.Trim(); RequestPayment.OrderNo = OrderNo.Text.Trim(); RequestPayment.TransAmount = Convert.ToDouble(TransAmount.Text.Trim()); RequestPayment.NotiUrl = NotiUrl.Text.Trim(); RequestPayment.ReturnUrl = ReturnUrl.Text.Trim(); RequestPayment.CancelUrl = CancelUrl.Text.Trim(); RequestPayment.OrderInfo = OrderInfo.Text.Trim(); RequestPayment.Email = Email.Text.Trim(); RequestPayment.AdditionalInfo = AdditionalInfo.Text.Trim(); string errMsg = string.Empty; string encData = PayBoxModule.GetPaymentEncrypt(PAYMENT_ENCRYPT_URL, RequestPayment, out errMsg); StringBuilder sbHtml = new StringBuilder(); if (!string.IsNullOrEmpty(errMsg)) { sbHtml.Append("<script>alert('" + errMsg + "'); self.close();</script>"); Response.Write(sbHtml.ToString()); return; } sbHtml.Append("<form id='payboxsubmit' name='payboxsubmit' action='" + string.Format(REQUEST_PAYMENT_URL, RequestPayment.PgCode) + "' method='GET'>"); sbHtml.Append("<input type='hidden' name='param' value='" + encData + "'/>"); sbHtml.Append("<script>document.forms['payboxsubmit'].submit();</script>"); Response.Write(sbHtml.ToString()); }
protected void Page_Load(object sender, EventArgs e) { //Request Content 노티 정보 조회 string body = PayBoxModule.GetDocumentContents(Request); if (string.IsNullOrEmpty(body)) { //FAIL로 응답 시 최대 10회까지 재 전송 처리 Response.Write("<xml><returnCode><![CDATA[FAIL]]></returnCode></xml>"); return; } PartnerNotification partnerNotification = JsonConvert.DeserializeObject <PartnerNotification>(body); //확인용 //Response.Write("TransactionId=" + partnerNotification.TransactionId + "<br/>"); //Response.Write("TransactionDateTime=" + partnerNotification.TransactionDateTime + "<br/>"); //Response.Write("TransactionCurrency=" + partnerNotification.TransactionCurrency + "<br/>"); //Response.Write("TransactionPGCode=" + partnerNotification.TransactionPGCode + "<br/>"); //Response.Write("OrderNo=" + partnerNotification.OrderNo + "<br/>"); //Response.Write("OrderInfo=" + partnerNotification.OrderInfo + "<br/>"); //Response.Write("TransAmount=" + partnerNotification.TransAmount + "<br/>"); //Response.Write("Email=" + partnerNotification.Email + "<br/>"); //Response.Write("AdditionalInfo=" + partnerNotification.AdditionalInfo + "<br/>"); //Response.Write("ExchangeCurrecy=" + partnerNotification.ExchangeCurrecy + "<br/>"); //Response.Write("ExchangeAmount=" + partnerNotification.ExchangeAmount + "<br/>"); //Response.Write("ExchangeRate=" + partnerNotification.ExchangeRate + "<br/>"); Response.Write("<xml><returnCode><![CDATA[SUCCESS]]></returnCode></xml>"); }
protected void BtnPayBoxCancel_Click(object sender, EventArgs e) { CreateToken createToken = new CreateToken(); createToken.PartnerAPIId = PARTNER_API_ID; createToken.PartnerAPIKey = PARTNER_API_KEY; string errMsg = string.Empty; StringBuilder sbHtml = new StringBuilder(); //API 통신 토큰 생성 string token = PayBoxModule.CreateToken(CREATE_TOKEN_URL, createToken, out errMsg); if (string.IsNullOrEmpty(token)) { sbHtml.Append("<script>alert('" + errMsg + "'); self.close();</script>"); Response.Write(sbHtml.ToString()); return; } RequestCancelPayment requestCancelPayment = new RequestCancelPayment(); requestCancelPayment.CancelType = Convert.ToInt32(Cancel_Type.Text.Trim()); requestCancelPayment.TransactionId = TransactionId.Text.Trim(); requestCancelPayment.TransAmount = Convert.ToDouble(TransAmount.Text.Trim()); //결제 취소 통신 ReeponseCancelPayment reeponseCancelPayment = PayBoxModule.CacenlPayment(CANCEL_PAYMENT_URL, token, requestCancelPayment, out errMsg); if (reeponseCancelPayment == null) { sbHtml.Append("<script>alert('" + errMsg + "'); self.close();</script>"); Response.Write(sbHtml.ToString()); return; } sbHtml.Append("<script>alert('" + string.Format("{0}/{1}/{2}/{3}/{4}", reeponseCancelPayment.Data.ResultCode , reeponseCancelPayment.Data.ResultMessage , reeponseCancelPayment.Data.ResultNMessage , reeponseCancelPayment.Data.TransactionId , reeponseCancelPayment.Data.CancelDataTime) + "');self.close();</script>"); Response.Write(sbHtml.ToString()); }