开发者

any insight into creating an https request to submit a cart to sagepay

开发者 https://www.devze.com 2023-04-02 05:24 出处:网络
any links to tutorials for creating a https POST request to submit a cart to a payment gateway, in this case sagepay.

any links to tutorials for creating a https POST request to submit a cart to a payment gateway, in this case sagepay.

or is the best example going to be the one in the s开发者_Go百科atchmo package?


do you need to contact the server directly or redirect your user there?

# contacting server directly
import urllib, urllib2

url="https://server/endpoint"
headers ={'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
data = urllib.urlencode({'datafield1': data1, 'datafield2': data2})

request = urllib2.Request(url, data, headers)
response = urllib2.urlopener(request).open()

For getting the user there, usually the idea is to have the user click a button that POSTs the correct information. This us usually disguised as a "Confirm Order" button.

This can either be achieved with a django form with the correct fields and all the fields hidden:

class HiddenForm(Form):
    param1 = TextField(initial_hidden=True)
    param2 = textField(initial_hidden=True)

<form action="https://server/endpoint" method="POST">
   {{form.hidden_fields}}<input type="submit" value"Confirm Order">
</form>
0

精彩评论

暂无评论...
验证码 换一张
取 消