浏览代码

支付修改

kevin_zhangl 2 年之前
父节点
当前提交
5e86614d32
共有 2 个文件被更改,包括 184 次插入42 次删除
  1. 64 0
      pay/pay.bak.html
  2. 120 42
      pay/pay.html

+ 64 - 0
pay/pay.bak.html

@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>pay</title>
+</head>
+<body>
+	<FORM method="post" name="ePayment" action="https://payment.ipay88.com.my/epayment/entry.asp">
+		<INPUT type="hidden" id="MerchantCode" name="MerchantCode"  value="">
+		<INPUT type="hidden" id="PaymentId" name="PaymentId" value="">
+		<INPUT type="hidden" id="RefNo" name="RefNo" value="">
+		<INPUT type="hidden" id="Amount" name="Amount"  value="">
+		<INPUT type="hidden" id="Currency" name="Currency"  value="">
+		<INPUT type="hidden" id="ProdDesc" name="ProdDesc"  value="">
+		<INPUT type="hidden" id="UserName" name="UserName"  value="">
+		<INPUT type="hidden" id="UserEmail" name="UserEmail" value="">
+		<INPUT type="hidden" id="UserContact"  name="UserContact" value="">
+		<INPUT type="hidden" id="Remark" name="Remark"  value="">
+		<INPUT type="hidden" id="Lang" name="Lang"  value="">
+		<INPUT type="hidden" id="SignatureType" name="SignatureType" value="SHA256">
+		<INPUT type="hidden" id="Signature" name="Signature" value="">
+		<INPUT type="hidden" id="ResponseURL" name="ResponseURL" value="">
+		<INPUT type="hidden" id="BackendURL" name="BackendURL" value="">
+		<span style="display: inline-block; margin: 0 auto;">因汇率波动,实际支付金额可能会有浮动</span><br /><br />
+		<INPUT type="submit" value="Proceed with Payment" name="Submit">
+	</FORM> 
+</body>
+<script type="text/javascript" src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
+<script>
+	function getQueryString(name,url) {
+		let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+		let r = url.substr(1).match(reg);
+	    if (r != null) { 
+	        return unescape(r[2]); 
+	    }
+	    return null;
+	}
+	
+	let RefNo = getQueryString('RefNo', window.location.search);
+	$(function(){
+		// test
+		// let url = 'http://16.163.228.151:8013/v1/shop/i-pay88';
+
+		// prod
+		let url = 'https://fapi.ekhkad.com/v1/shop/i-pay88';
+
+		$.post(url, {'RefNo': RefNo}, function(res) {
+			$("#Amount").val( res.paymentFields.Amount);
+			$("#BackendURL").val( res.paymentFields.BackendURL);
+			$("#Currency").val( res.paymentFields.Currency);
+			$("#Lang").val( res.paymentFields.Lang);
+			$("#MerchantCode").val( res.paymentFields.MerchantCode);
+			$("#PaymentId").val( res.paymentFields.PaymentId);
+			$("#ProdDesc").val( res.paymentFields.ProdDesc);
+			$("#RefNo").val( res.paymentFields.RefNo);
+			$("#ResponseURL").val( res.paymentFields.ResponseURL);
+			$("#Signature").val( res.paymentFields.Signature);
+			$("#UserContact").val( res.paymentFields.UserContact);
+			$("#UserEmail").val( res.paymentFields.UserEmail);
+			$("#UserName").val( res.paymentFields.UserName);
+		})
+	});
+</script>
+</html>

+ 120 - 42
pay/pay.html

@@ -1,64 +1,142 @@
 <!DOCTYPE html>
 <html>
 <head>
-<meta charset="utf-8">
-<title>pay</title>
+	<meta charset="utf-8">
+	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+	<meta name="renderer" content="webkit">
+	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
+	<meta http-equiv="cache-control" content="no-cache,no-store, must-revalidate" />
+	<meta http-equiv="pragma" content="no-cache" />
+	<meta http-equiv="Expires" content="0" />
+	<title>pay</title>
 </head>
+
 <body>
-	<FORM method="post" name="ePayment" action="https://payment.ipay88.com.my/epayment/entry.asp">
-		<INPUT type="hidden" id="MerchantCode" name="MerchantCode"  value="">
-		<INPUT type="hidden" id="PaymentId" name="PaymentId" value="">
-		<INPUT type="hidden" id="RefNo" name="RefNo" value="">
-		<INPUT type="hidden" id="Amount" name="Amount"  value="">
-		<INPUT type="hidden" id="Currency" name="Currency"  value="">
-		<INPUT type="hidden" id="ProdDesc" name="ProdDesc"  value="">
-		<INPUT type="hidden" id="UserName" name="UserName"  value="">
-		<INPUT type="hidden" id="UserEmail" name="UserEmail" value="">
-		<INPUT type="hidden" id="UserContact"  name="UserContact" value="">
-		<INPUT type="hidden" id="Remark" name="Remark"  value="">
-		<INPUT type="hidden" id="Lang" name="Lang"  value="">
-		<INPUT type="hidden" id="SignatureType" name="SignatureType" value="SHA256">
-		<INPUT type="hidden" id="Signature" name="Signature" value="">
-		<INPUT type="hidden" id="ResponseURL" name="ResponseURL" value="">
-		<INPUT type="hidden" id="BackendURL" name="BackendURL" value="">
-		<span style="display: inline-block; margin: 0 auto;">因汇率波动,实际支付金额可能会有浮动</span><br /><br />
-		<INPUT type="submit" value="Proceed with Payment" name="Submit">
-	</FORM> 
+	<div class="payment">
+		<div class="fd">
+
+			<!-- <form method="post" name="ePayment" action="https://payment.ipay88.com.my/epayment/entry.asp">
+				<INPUT type="hidden" id="MerchantCode" name="MerchantCode" value="">
+				<INPUT type="hidden" id="PaymentId" name="PaymentId" value="">
+				<INPUT type="hidden" id="RefNo" name="RefNo" value="">
+				<INPUT type="hidden" id="Amount" name="Amount" value="">
+				<INPUT type="hidden" id="Currency" name="Currency" value="">
+				<INPUT type="hidden" id="ProdDesc" name="ProdDesc" value="">
+				<INPUT type="hidden" id="UserName" name="UserName" value="">
+				<INPUT type="hidden" id="UserEmail" name="UserEmail" value="">
+				<INPUT type="hidden" id="UserContact" name="UserContact" value="">
+				<INPUT type="hidden" id="Remark" name="Remark" value="">
+				<INPUT type="hidden" id="Lang" name="Lang" value="">
+				<INPUT type="hidden" id="SignatureType" name="SignatureType" value="SHA256">
+				<INPUT type="hidden" id="Signature" name="Signature" value="">
+				<INPUT type="hidden" id="ResponseURL" name="ResponseURL" value="">
+				<INPUT type="hidden" id="BackendURL" name="BackendURL" value="">
+				<span style="display: inline-block; margin: 0 auto;">因汇率波动,实际支付金额可能会有浮动</span><br /><br />
+				<INPUT type="submit" id="submit" value="Proceed with Payment" name="Submit">
+			</form> -->
+		</div>
+		<div class="loading">
+
+		</div>
+	</div>
+
+
 </body>
+
 <script type="text/javascript" src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
 <script>
-	function getQueryString(name,url) {
+	function getQueryString(name, url) {
 		let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
 		let r = url.substr(1).match(reg);
-	    if (r != null) { 
-	        return unescape(r[2]); 
-	    }
-	    return null;
+		if (r != null) {
+			return unescape(r[2]);
+		}
+		return null;
 	}
-	
+
 	let RefNo = getQueryString('RefNo', window.location.search);
-	$(function(){
+	$(function () {
+
 		// test
 		// let url = 'http://16.163.228.151:8013/v1/shop/i-pay88';
 
 		// prod
 		let url = 'https://fapi.ekhkad.com/v1/shop/i-pay88';
 
-		$.post(url, {'RefNo': RefNo}, function(res) {
-			$("#Amount").val( res.paymentFields.Amount);
-			$("#BackendURL").val( res.paymentFields.BackendURL);
-			$("#Currency").val( res.paymentFields.Currency);
-			$("#Lang").val( res.paymentFields.Lang);
-			$("#MerchantCode").val( res.paymentFields.MerchantCode);
-			$("#PaymentId").val( res.paymentFields.PaymentId);
-			$("#ProdDesc").val( res.paymentFields.ProdDesc);
-			$("#RefNo").val( res.paymentFields.RefNo);
-			$("#ResponseURL").val( res.paymentFields.ResponseURL);
-			$("#Signature").val( res.paymentFields.Signature);
-			$("#UserContact").val( res.paymentFields.UserContact);
-			$("#UserEmail").val( res.paymentFields.UserEmail);
-			$("#UserName").val( res.paymentFields.UserName);
+		$.post(url, { 'RefNo': RefNo }, function (res) {
+			console.log(res)
+			var info = res.paymentFields
+			var form = document.createElement("form");
+			form.style = 'opacity: 0'
+			//action地址
+			form.action = 'https://payment.ipay88.com.my/epayment/entry.asp';
+			//请求方式
+			form.method = "post";
+			//添加_blank,如果是支持第三方添加_blank
+			// form.target = "_blank";
+			console.log(info)
+			form.append("Amount", info.Amount);
+			form.append("BackendURL", info.Amount);
+			form.append("Currency", info.Currency);
+			form.append("Lang", info.Lang);
+			form.append("MerchantCode", info.MerchantCode);
+			form.append("PaymentId", info.PaymentId);
+			form.append("ProdDesc", info.ProdDesc);
+			form.append("RefNo", info.RefNo);
+			form.append("ResponseURL", info.ResponseURL);
+			form.append("Signature", info.Signature);
+			form.append("UserContact", info.UserContact);
+			form.append("UserEmail", info.UserEmail);
+			form.append("UserName", info.UserName);
+			// 注入到body
+			document.body.appendChild(form);
+			// 调用表单提交
+			form.submit();
 		})
 	});
 </script>
+<style>
+	html{
+		width: 100%;
+		height: 100%;
+		overflow: hidden;
+	}
+	body{
+		width: 100%;
+		height: 100%;
+		overflow: hidden;
+
+	}
+	.payment {
+		width: 100%;
+		height: 100%;
+	}
+
+	.loading {
+		position: relative;
+		width: 100%;
+		height: 100%;
+	}
+
+	.loading::before {
+		content: '';
+		position: absolute;
+		top: 50%;
+		left: 50%;
+		transform: translate(-50%, -50%);
+		width: 50px;
+		height: 50px;
+		border-radius: 50%;
+		border: 3px solid rgba(0, 0, 0, .2);
+		border-top-color: #000;
+		animation: rotate 1s infinite linear;
+	}
+
+	@keyframes rotate {
+		to {
+			transform: translate(-50%, -50%) rotate(360deg);
+		}
+	}
+</style>
+
 </html>