我已经找到类似的主题,但我的代码不起作用。 我需要将网上商店与支付网关连接起来。 必须使用POST发送数据。问题是,当我想打开付款表单时,我只获得有关付款网关的信息网页。
以下是我的代码的一部分:
cart.gsp
<jq:jquery>
$("#buy").click(function(e) {
$.ajax({
type:'POST',
url:'${createLink(action: 'fetchPaymentForm')}',
success:function(data,textStatus) {},
error:function(XMLHttpRequest,textStatus,errorThrown) {}
});
e.preventDefault()
})
</jq:jquery>
当我点击带有ID&#34;购买&#34;。
的按钮时,这部分代码就会运行shoppingCartController.groovy
版本
def fetchPaymentForm(){
def restClient = new RESTClient("https://test.payment.com/redirect/")
def resp = restClient.post(
body: [target: "_top", mode: "form",
store_id:"${storeID}", orderNumber: "${orderNumber}",
language: "${language}", currency: "${currency}",
amount: "${amountAll}", cart: "${cart}", Hash:"${hash}", require_complete: "true"],
requestContentType: URLENC
)
}
版本
def fetchPaymentForm(){
render(template: "/layouts/paymentForm", model: [orderNumber: orderNumber, amount: amountAll, currency: currency, language: language, storeID: storeID, cart: cart, hash: hash])
}
_paymentForm.gsp
<form method="POST" action="https://test.payment.com/redirect/" name="form" id="form">
<input id="target" name="target" value="_top" type="hidden">
<input id="mode" name="mode" value="form" type="hidden">
<input id="store_id" name="store_id" value="${storeID}" type="hidden">
<input id="order_number" name="order_number" value="${orderNumber}" type="hidden">
<input id="language" name="language" value="${language}" type="hidden">
<input id="currency" name="currency" value="${currency}" type="hidden">
<input id="amount" name="amount" value="${amount}" type="hidden">
<input id="cart" name="cart" value="${cart}" type="hidden">
<input id="Hash" name="Hash" value="${hash}" type="hidden">
<input id="require_complete" name="require_complete" value="false" type="hidden">
</form>
如果有人能给我一个建议或暗示要尝试什么,我会非常感激。
编辑: 以下是重定向C#的示例,该文件显示在pdf文件中以进行付款实施。
<input id="target" ClientIDMode="Static" name="target" value="_top" hidden="true"/>
<input id="mode" ClientIDMode="Static" name="mode" value="<%=mode %>" hidden="true"/>
<input id="store_id" ClientIDMode="Static" name="store_id" value=" <%=store_id %>" hidden="true"/>
<input id="require_complete" ClientIDMode="Static" name="require_complete" value="<%=require_complete %>" hidden="true"/>
<input id="order_number" ClientIDMode="Static" name="order_number" value="<%=order_number %>" hidden="true"/>
<input id="amount" ClientIDMode="Static" name="amount" value="<%=amount %>" hidden="true"/>
<input id="hash" ClientIDMode="Static" name="hash" value="<%=hash %>" hidden="true"/>
<input id="currency" ClientIDMode="Static" name="currency" value=" <%=currency %>" hidden="true"/>
<input id="cart" ClientIDMode="Static" name="cart" value="<%=cart %>" hidden="true"/>
<input id="payment_number" ClientIDMode="Static" name="payment_number" value="<%=payment_number %>" hidden="true"/>
<input id="language" ClientIDMode="Static" name="language" value="<%=language %>" hidden="true"/>
<asp:button id="Button2" Text="testcps"
PostBackUrl="https://test.payment.com/redirect/" runat="Server" ClientIDMode="Static" OnClick="Button1_Click" />
显然我错过了一些东西,但我不知道是什么。 感谢提前提示。