使用 Python 与 RBS WorldPay 托管支付页面(XML 重定向)集成

发布于 2024-10-08 02:57:39 字数 148 浏览 10 评论 0原文

有谁有使用 Python 与 RBS WorldPay 集成的示例代码?具体将 XML 订单发布到 WorldPay

Does anyone have any example code for integrating with RBS WorldPay using Python? Specifically posting the XML order to WorldPay

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盗心人 2024-10-15 02:57:39

这是带有基本身份验证的 HTTP POST。基本身份验证在官方使用 urllib2 HOWTO 获取互联网资源中进行了描述。因此,如果 XML 是您要发送的 XML,URL 是您要发布到的 URL,MERCHANT_CODE 和 PASSWORD 是不言自明的,则可以执行以下操作:

import urllib2
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, URL, MERCHANT_CODE, PASSWORD)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
request = Request(URL, XML, {'Content-Type': 'text/xml'})
response = opener.open(request, XML)

# do something with the response

response.close()

It's an HTTP POST with Basic Authentication. Basic Authentication is described in the official Fetch Internet Resources Using urllib2 HOWTO. So, where XML is the XML you're sending, URL is the URL you're posting to, and MERCHANT_CODE and PASSWORD are self explanatory, the following works:

import urllib2
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, URL, MERCHANT_CODE, PASSWORD)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
request = Request(URL, XML, {'Content-Type': 'text/xml'})
response = opener.open(request, XML)

# do something with the response

response.close()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文