php 如何使用 WorldPay 创建返回页面设置?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8232607/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How Do I Create Returning Page Setting with WorldPay?
提问by Volomike
The docs for WorldPay are really difficult for me to understand after reading and re-reading them for hours. (In fact, many of the docs gave me the wrong Live URL and I had to look around on the web and try things with trial/error in order to find the Live URL, for instance.)
WorldPay 的文档在阅读和重读几个小时后对我来说真的很难理解。(事实上,许多文档给了我错误的 Live URL,例如,我不得不在网络上环顾四周并尝试尝试/错误以找到 Live URL。)
How do I create a returning page setting with WorldPay?By this, I mean when someone posts the payment and then pays on the WorldPay site, WorldPay would then automatically redirect the shopper back to a page on my site if successful. I want to know how to do this. I think I guessed it below, but am not certain if it works?
如何使用 WorldPay 创建返回页面设置?我的意思是,当有人发布付款然后在 WorldPay 网站上付款时,如果成功,WorldPay 会自动将购物者重定向回我网站上的页面。我想知道如何做到这一点。我想我在下面猜到了,但不确定它是否有效?
<?php ?>
<html><head><title></title></head><body>
<form action="https://secure.wp3.rbsworldpay.com/wcc/purchase" method="post">
<input type="hidden" name="testMode" value="0">
<input type="hidden" name="instId" value="<?= $this->INST_ID ?>">
<input type="hidden" name="cartId" value="<?= $this->CART_ID ?>">
<input type="hidden" name="amount" value="<?= $this->AMOUNT ?>">
<input type="hidden" name="currency" value="<?= $this->CURRENCY_CODE ?>">
<input type="hidden" name="desc" value="Photos">
<input type="hidden" name="MC_success" value="<?= $this->RETURNING_PAGE_ON_MY_SITE ?>">
<input type="submit" value="Click here for the secure payment form">
</form>
</body></html>
EDIT: WorldPay tech support said that the action must now be "https://secure.worldpay.com/wcc/purchase" and the MC_success parameter won't work. He advised me to use a wpdisplay parameter in the form post so that we tell the result page to swap header and do a meta redirect back to a page on our site. I asked for an example and he said there was none. All he could do was point me at this confusing documentationthat doesn't really describe this at all. (I don't fault the tech support guy -- he's just doing his job with the weak tools he's given.)
编辑:WorldPay 技术支持说现在操作必须是“ https://secure.worldpay.com/wcc/purchase”并且 MC_success 参数将不起作用。他建议我在表单帖子中使用 wpdisplay 参数,以便我们告诉结果页面交换标题并执行元重定向回到我们网站上的页面。我问了一个例子,他说没有。他所能做的就是向我指出这个令人困惑的文档,它根本没有真正描述过这一点。(我没有责怪技术支持人员——他只是用他提供的弱工具来完成他的工作。)
回答by www.amitpatil.me
After spending 3-4 days and reading all the confusing and poor documentation of Worldpay, somehow I found how to return to some page and process the response returned by Worldpay. I wanted to insert a record in a database with transaction details. So I was looking for solution. Well, here is the solution that worked for me:
在花了 3-4 天并阅读了 Worldpay 的所有混乱和糟糕的文档后,不知何故我找到了如何返回某个页面并处理 Worldpay 返回的响应。我想在包含事务详细信息的数据库中插入一条记录。所以我一直在寻找解决方案。好吧,这是对我有用的解决方案:
- login to Worldpay, open desired installation to edit
- Tick on "Payment Response enabled?"
- Provide "Payment Response URL" to the page which will be receiving/processing the POST data from worldpay.
- Enter same url in "Shopper redirect url"
- Tick on "Shopper Redirect button enabled"
- Tick on "Enable the Shopper Response"
- If you use print_r($_POST) (For php users) on url entered in "Payment Response URL" you can see all the details returned by Worldpay.
- After processing you can use meta refresh technique to redirect user to some other page or you can print "thank you" message to the user on same page.
- 登录 Worldpay,打开所需安装进行编辑
- 勾选“付款响应已启用?”
- 向将从 worldpay 接收/处理 POST 数据的页面提供“支付响应 URL”。
- 在“购物者重定向网址”中输入相同的网址
- 勾选“启用购物者重定向按钮”
- 勾选“启用购物者响应”
- 如果您在“付款响应 URL”中输入的 url 上使用 print_r($_POST)(对于 php 用户),您可以看到 Worldpay 返回的所有详细信息。
- 处理后,您可以使用元刷新技术将用户重定向到其他页面,或者您可以在同一页面上向用户打印“谢谢”消息。
I know this thread is 1+ year old but in case if someone finds this helpful I am posting my solution here.
我知道这个线程已经有 1 年多的历史了,但如果有人觉得这有帮助,我会在这里发布我的解决方案。
Edit : "WorldPay Payment Response Guide"documentation
编辑:“WorldPay 支付响应指南”文档
Edit : Here is a screenshot of my settings that worked for me
编辑:这是对我有用的设置的屏幕截图
回答by Chris
Can totally sympathise, this was a bit of a nightmare to setup for me too. I've not used the MC_success parameter before, but as far as I know you can't do a straight redirect, it has to display a Worldpay page after payment, but you can customise this page.
完全可以同情,这对我来说也是一场噩梦。我之前没有使用过 MC_success 参数,但据我所知你不能直接重定向,付款后它必须显示一个 Worldpay 页面,但你可以自定义这个页面。
Once the payment is successful (or not), Worldpay shows an HTML page to the user. These HTML pages are stored in your Worldpay control panel, and if you want to customise them you have to upload a new file here. The files shown on transaction success and failure are resultY.html
and resultC.html
respectively.
一旦付款成功(或不成功),Worldpay 会向用户显示一个 HTML 页面。这些 HTML 页面存储在您的 Worldpay 控制面板中,如果您想自定义它们,您必须在此处上传一个新文件。交易成功和失败显示的文件分别是resultY.html
和resultC.html
。
You need to have a look at the Advanced Customising Guide, and search for resultY.html
in the top right of that guide, this will give you some help.
您需要查看Advanced Customizing Guide,并resultY.html
在该指南的右上角进行搜索,这将为您提供一些帮助。
In these files, Worldpay automatically substitues certain tags like <wpdisplay item=cartId>
and <wpdisplay item=banner default="">
for actual data. I would login to your Worldpay control panel and download the files it currently uses, then customise from there.
在这些文件中,WorldPay的自动substitues一定的标签,如<wpdisplay item=cartId>
与<wpdisplay item=banner default="">
实际数据。我会登录到您的 Worldpay 控制面板并下载它当前使用的文件,然后从那里进行自定义。
In an installation I have I just include a line in my resultY.html page like the following...
在安装中,我只在 resultY.html 页面中包含一行,如下所示...
<p><a href="http://example.com/worldpay/cartid/<wpdisplay item=cartId>">Redirect back to my shop</a></p>
...which will take the user back to my site with their cartId in the URL, from which I pull their order details and show a success page of my own. But you can create your own tags by sending along extra post fields in your sample form above. The names of the variables must be prefixed MC_
, but you can then include them in your resultY.html file. Ie.
...这会将用户带回我的网站,在 URL 中包含他们的 cartId,我从中提取他们的订单详细信息并显示我自己的成功页面。但是您可以通过在上面的示例表单中发送额外的帖子字段来创建自己的标签。变量的名称必须以 为前缀MC_
,但随后您可以将它们包含在您的 resultY.html 文件中。IE。
<form action="https://secure.wp3.rbsworldpay.com/wcc/purchase" method="post">
<input type="hidden" name="testMode" value="0">
<input type="hidden" name="instId" value="<?= $this->INST_ID ?>">
<input type="hidden" name="cartId" value="<?= $this->CART_ID ?>">
<input type="hidden" name="amount" value="<?= $this->AMOUNT ?>">
<input type="hidden" name="currency" value="<?= $this->CURRENCY_CODE ?>">
<input type="hidden" name="desc" value="Photos">
<input type="hidden" name="MC_myText" value="This is my custom text">
<input type="submit" value="Click here for the secure payment form">
</form>
And in your resultY.html
file just include the tag <WPDISPLAY ITEM=MC_myText>
. You need to be conscious that all your form fields are visible to a user if they view the source of your payment pages, hence putting a valid MC_downloadLink
to some valuable download is a bad idea.
在您的resultY.html
文件中只包含标签<WPDISPLAY ITEM=MC_myText>
. 您需要意识到,如果用户查看您的付款页面的来源,您的所有表单字段对他们都是可见的,因此将有效MC_downloadLink
的一些有价值的下载放入一个有效的位置是一个坏主意。
Check out these pages, they're the most useful ones in the customising guide:
查看这些页面,它们是自定义指南中最有用的页面:
I hope this has been of some help, if you have any questions just add a comment. Good luck!!
我希望这对您有所帮助,如果您有任何问题,请添加评论。祝你好运!!
回答by TehInvisibleHand
Editing resultY.html is not strictly necessary, you can skip using the Payment Page Editor by using the 'Payment Response' feature.
编辑 resultY.html 不是绝对必要的,您可以通过使用“付款响应”功能跳过使用付款页面编辑器。
In the installation settings provide a URL for a script on your server and WorldPay will POST the following parameters to it once a payment has been authorised (or the shopper clicks Cancel on the payment page): http://www.worldpay.com/support/kb/bg/paymentresponse/pr5201.html
在安装设置中,为您服务器上的脚本提供一个 URL,一旦付款获得授权(或购物者在付款页面上单击“取消”),WorldPay 将向其发布以下参数:http: //www.worldpay.com/支持/kb/bg/paymentresponse/pr5201.html
If you also enable the setting "Enable the shopper response" WorldPay will download any HTML the script you specified outputs and use this as the result page (hosted on their own server). (If you want any images hosted securely they'll need to be uploaded in the Payment Page Editor)
如果您还启用“启用购物者响应”设置,WorldPay 将下载您指定的脚本输出的任何 HTML 并将其用作结果页面(托管在他们自己的服务器上)。(如果您希望安全托管任何图像,则需要将它们上传到付款页面编辑器中)
This allows you to build a dynamic results page without needing to use resultY.html (OSCommerce and may other shopping carts use this method to customise the results page)
这允许您构建动态结果页面而无需使用 resultY.html(OSCommerce 和其他购物车可能使用此方法自定义结果页面)
I believe there is no problem with using a META refresh on your results page provided it is not in anyway misleading (you need to give the shopper the outcome of the payment and not immediately send them to your home page for example).
我相信在您的结果页面上使用 META 刷新没有问题,只要它没有任何误导性(例如,您需要向购物者提供付款结果而不是立即将其发送到您的主页)。
回答by Sxc
I think worldpay eventually allow Shopper Responseredirect back to your site, through Meta refresh .
我认为 worldpay 最终允许Shopper Response通过 Meta refresh 重定向回您的网站。
All you have to do is to generate the Html response from your server-side callback.
您所要做的就是从服务器端回调生成 Html 响应。
回答by Joe
As of 2020 This is still very undocumented and many links are now broken :(
截至 2020 年,这仍然是非常无证的,现在许多链接都已损坏:(
After doing the accepted answers by @www.amitpatil.me it still did not work for me.
在完成@www.amitpatil.me 接受的答案后,它仍然对我不起作用。
I have made it work by adding this extra form field into the form post, I found this after many seeming unrelated google tabs.
我通过将这个额外的表单字段添加到表单帖子中使其工作,我在许多看似无关的谷歌标签之后发现了这一点。
<input type="hidden" name="successURL" value="https://www.example.com/thanks/">
I hope it helps someone else.
我希望它可以帮助别人。
回答by Andy Brown
I'm adding to an answer from Joe below - initially I just commented on it, but now have too much to fit into the comments box.
我正在添加下面 Joe 的答案 - 最初我只是评论它,但现在有太多内容无法放入评论框中。
You don't have to do any fiddling around with ResultYfiles any more - just specify a hidden field in your submit page with name set to successUrl, like this:
您不必再对ResultY文件进行任何摆弄- 只需在提交页面中指定一个隐藏字段,并将名称设置为successUrl,如下所示:
This can include any fields you like in the query string. After successfully submitting a payment, you get taken back to this URL. A couple of caveats:
这可以包括您在查询字符串中喜欢的任何字段。成功提交付款后,您将返回到此 URL。几个警告:
- WorldPay won't take you back to a different URL. So if (like me) you're developing a site on your local computer, you'll have to publish your changes to your live site to test this.
- You get lots of other arguments in the query string - some useful (the payment amount and response), some less so (a couple of very long arguments called macand mac2, whose meaning I know not).
- WorldPay 不会将您带回到不同的 URL。因此,如果(像我一样)您正在本地计算机上开发站点,则必须将更改发布到实时站点以进行测试。
- 您会在查询字符串中获得许多其他参数 - 一些有用(付款金额和响应),一些不太有用(几个非常长的参数,称为mac和mac2,我不知道其含义)。
I think you may be able to pass failureURLand cancelURLtoo, but I couldn't get these too work.
我认为你也可以传递failureURL和cancelURL,但我无法让这些工作。
回答by Volomike
@Chris really answered this question, but here's what I ended up doing. I did indeed use the MC_success parameter, but set it like so:
@Chris 真的回答了这个问题,但这就是我最终要做的。我确实使用了 MC_success 参数,但设置如下:
<input type="hidden" name="MC_success" value="Click here to return to the merchant: <?= $this->RETURNING_PAGE_ON_MY_SITE ?>">
Then, this requires the merchant to edit their resultY.html page on WorldPay and insert this parameter somewhere in the body section of it:
然后,这需要商家在 WorldPay 上编辑他们的 resultY.html 页面,并在它的正文部分的某处插入此参数:
<div><strong><WPDISPLAY ITEM=success></strong></div>
This will then display something like the following in their successful payment response page hosted on WorldPay:
然后,这将在 WorldPay 上托管的成功付款响应页面中显示如下内容:
Click here to return to the merchant: http://example.com/my-success-return-link-here
点击此处返回商家:http: //example.com/my-success-return-link-here
Now, not every customer is going to know how to do this. Therefore, in my payment gateway that I was building, I made it email the admin that someone paid by WorldPay and that they should manually send the photos to the customer via the Admin interface of our product.
现在,并不是每个客户都会知道如何做到这一点。因此,在我正在构建的支付网关中,我通过电子邮件向管理员发送了 WorldPay 付款的电子邮件,并且他们应该通过我们产品的管理界面手动将照片发送给客户。
Additionally, one must post this to the proper action URL, which I corrected in my original post in the EDITsection above.
此外,必须将此发布到正确的操作 URL,我在上面编辑部分的原始帖子中更正了该 URL 。
Last but not least, note that we cannot do an automatic redirection. In fact, WorldPay has a policy strictly prohibiting it, which is in red on this page:
最后但并非最不重要的一点,请注意我们无法进行自动重定向。事实上,WorldPay 有一个政策是严格禁止的,在这个页面上是红色的:
http://www.worldpay.com/support/kb/bg/paymentresponse/pr5402.html
http://www.worldpay.com/support/kb/bg/paymentresponse/pr5402.html
"Warning: Automatic redirection using the shopper response feature is prohibited and will result in a failure being logged and a possible suspension of the feature."
“警告:禁止使用购物者响应功能进行自动重定向,这将导致记录失败并可能暂停该功能。”
回答by vinay
Worldpay return URL
Worldpay 返回网址
it is very simple.
这很简单。
login to Worldpay, open desired installation to edit.
登录 Worldpay,打开所需的安装进行编辑。
Tick on "Payment Response enabled?"
勾选“付款响应已启用?”
Provide "Payment Response URL" like http://yourdomain.com/responce.php
提供“付款响应 URL”,如http://yourdomain.com/responce.php
Enter same url in "Shopper redirect url" http://yourdomain.com/responce.php
在“购物者重定向网址”中输入相同的网址http://yourdomain.com/responce.php
Tick on "Shopper Redirect button enabled"
勾选“启用购物者重定向按钮”
And put responce.php in root directory
并将responce.php放在根目录中
create test.txt file in root
在 root 中创建 test.txt 文件
file_get_contents('test.txt',$_Post);
file_get_contents('test.txt',$_Post);
you can get post data array to test.txt
您可以将发布数据数组发送到 test.txt