rana-writes
شنبه 24 تیر 1391, 10:07 صبح
سلام من يه پيج دارم براي ارسال اطلاعات توي درگاه بانك ملي
با گذاشتن runat="server" تونستم به بخشهاي html دسترسي داشته باشم توي cs .منتهي وقتي باتن ميندازم تو صفحه عملا اصلا توي رويداد كليك باتن هيچ كاري انجام نميده.
حتي مجبور شدم كدهاي ارسال رو توي PageLoad بندازم تا از اونجا مستقيم به بانك ارسال بشه
كدها رو ميذارم ببينين
<form id="pardakhtsim" runat="server" method='post' action='https://Damoon.bankmelli-iran.com/MerchantsIntegrationTestController'>
<input id="HiddenValue" type="hidden" value="Initial Value" runat="server" />
<input type='hidden' runat="server" name='x_login' id='x_login' />
<input type='hidden' runat="server" name='x_amount' id='x_amount' />
<input type='hidden' runat="server" name='x_description' id='x_description' />
<input type='hidden' runat="server" name='x_invoice_num' id='x_invoice_num' />
<input type='hidden' runat="server" name='x_fp_sequence' id='x_fp_sequence' />
<input type='hidden' runat="server" name='x_fp_timestamp' id='x_fp_timestamp' />
<input type='hidden' runat="server" name='x_fp_hash' id='x_fp_hash' />
<input type='hidden' runat="server" name='x_currency_code' id="x_currency_code" />
<input type='hidden' runat="server" name='x_test_request' id='x_test_request' />
</form>
حالا وقتي توي رويداد كليك باتن هر چيزي بنويسم، اصلا انگار نه انگار، منتقل ميشه به صفحه تاييديه بانك
string loginID = "TestMer";
string transactionKey = "tstkey";
string amount = "1000";
string description = "Sample Transaction";
string label = "Submit Payment"; // The is the label on the 'submit' button
string testMode = "true";
string currency = "Rial";
// If an amount or description were posted to this page, the defaults are overidden
if (Request.Form["amount"] != null)
{ amount = Request.Form["amount"]; }
if (Request.Form["description"] != null)
{ description = Request.Form["description"]; }
// also check to see if the amount or description were sent using the GET method
if (Request.QueryString["amount"] != null)
{ amount = Request.QueryString["amount"]; }
if (Request.QueryString["description"] != null)
{ description = Request.QueryString["description"]; }
string invoice = DateTime.Now.ToString("yyyyMMddhhmmss");
Random random = new Random();
string sequence = (random.Next(0, 1000)).ToString();
string timeStamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();
//x_login^x_fp_sequence^x_fp_timestamp^x_amount^x_cu rrency_code
string fingerprint = HMAC_MD5(transactionKey, loginID + "^" + sequence + "^" + timeStamp + "^" + amount + "^" + currency );
//Print the Amount and Description to the page by placing them in the Spans
amountSpan.InnerHtml = amount;
descriptionSpan.InnerHtml = description;
//Update the fields in the actual form
x_login.Value = loginID;
x_amount.Value = amount;
x_description.Value = description;
// buttonLabel.Value = label;
x_test_request.Value = testMode;
x_invoice_num.Value = invoice;
x_fp_sequence.Value = sequence;
x_fp_timestamp.Value = timeStamp;
x_fp_hash.Value = fingerprint;
x_currency_code.Value = currency;
string PostData = "x_description=Sample Transaction&x_login=TestMer70&x_fp_sequence="+ sequence +"&x_fp_timestamp="+timeStamp+"&x_amount=1000&x_cu rrency_code=Rial&x_fp_hash="+ fingerprint;
يه حركت ديگه هم رفتم كه بجاي اينكه توي html مقادير رو پر كنم توي همون cs بهشون مقدار بدم اينطوري:
System.Web.HttpContext.Current.Response.Write(stri ng.Format("<input type='hidden' name=\"x_fp_timestamp\" value=\"{0}\"/>", timeStamp));
ولي بازم فرقي نداره، توي رويداد باتن عملا هيچ كاري انجام نميده. من ميخوام توي اين باتن قبل از ارسال اطلاعات به بانك، اطلاعات پرداخت رو ذخيره كنم.
ممنون ميشم راهنماييم كنين.
با گذاشتن runat="server" تونستم به بخشهاي html دسترسي داشته باشم توي cs .منتهي وقتي باتن ميندازم تو صفحه عملا اصلا توي رويداد كليك باتن هيچ كاري انجام نميده.
حتي مجبور شدم كدهاي ارسال رو توي PageLoad بندازم تا از اونجا مستقيم به بانك ارسال بشه
كدها رو ميذارم ببينين
<form id="pardakhtsim" runat="server" method='post' action='https://Damoon.bankmelli-iran.com/MerchantsIntegrationTestController'>
<input id="HiddenValue" type="hidden" value="Initial Value" runat="server" />
<input type='hidden' runat="server" name='x_login' id='x_login' />
<input type='hidden' runat="server" name='x_amount' id='x_amount' />
<input type='hidden' runat="server" name='x_description' id='x_description' />
<input type='hidden' runat="server" name='x_invoice_num' id='x_invoice_num' />
<input type='hidden' runat="server" name='x_fp_sequence' id='x_fp_sequence' />
<input type='hidden' runat="server" name='x_fp_timestamp' id='x_fp_timestamp' />
<input type='hidden' runat="server" name='x_fp_hash' id='x_fp_hash' />
<input type='hidden' runat="server" name='x_currency_code' id="x_currency_code" />
<input type='hidden' runat="server" name='x_test_request' id='x_test_request' />
</form>
حالا وقتي توي رويداد كليك باتن هر چيزي بنويسم، اصلا انگار نه انگار، منتقل ميشه به صفحه تاييديه بانك
string loginID = "TestMer";
string transactionKey = "tstkey";
string amount = "1000";
string description = "Sample Transaction";
string label = "Submit Payment"; // The is the label on the 'submit' button
string testMode = "true";
string currency = "Rial";
// If an amount or description were posted to this page, the defaults are overidden
if (Request.Form["amount"] != null)
{ amount = Request.Form["amount"]; }
if (Request.Form["description"] != null)
{ description = Request.Form["description"]; }
// also check to see if the amount or description were sent using the GET method
if (Request.QueryString["amount"] != null)
{ amount = Request.QueryString["amount"]; }
if (Request.QueryString["description"] != null)
{ description = Request.QueryString["description"]; }
string invoice = DateTime.Now.ToString("yyyyMMddhhmmss");
Random random = new Random();
string sequence = (random.Next(0, 1000)).ToString();
string timeStamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();
//x_login^x_fp_sequence^x_fp_timestamp^x_amount^x_cu rrency_code
string fingerprint = HMAC_MD5(transactionKey, loginID + "^" + sequence + "^" + timeStamp + "^" + amount + "^" + currency );
//Print the Amount and Description to the page by placing them in the Spans
amountSpan.InnerHtml = amount;
descriptionSpan.InnerHtml = description;
//Update the fields in the actual form
x_login.Value = loginID;
x_amount.Value = amount;
x_description.Value = description;
// buttonLabel.Value = label;
x_test_request.Value = testMode;
x_invoice_num.Value = invoice;
x_fp_sequence.Value = sequence;
x_fp_timestamp.Value = timeStamp;
x_fp_hash.Value = fingerprint;
x_currency_code.Value = currency;
string PostData = "x_description=Sample Transaction&x_login=TestMer70&x_fp_sequence="+ sequence +"&x_fp_timestamp="+timeStamp+"&x_amount=1000&x_cu rrency_code=Rial&x_fp_hash="+ fingerprint;
يه حركت ديگه هم رفتم كه بجاي اينكه توي html مقادير رو پر كنم توي همون cs بهشون مقدار بدم اينطوري:
System.Web.HttpContext.Current.Response.Write(stri ng.Format("<input type='hidden' name=\"x_fp_timestamp\" value=\"{0}\"/>", timeStamp));
ولي بازم فرقي نداره، توي رويداد باتن عملا هيچ كاري انجام نميده. من ميخوام توي اين باتن قبل از ارسال اطلاعات به بانك، اطلاعات پرداخت رو ذخيره كنم.
ممنون ميشم راهنماييم كنين.