Beispiel #1
0
def send_ippay_request(amount, card):
    if not card.validate():
        raise CCError('invalid card info')
    (xid, xml) = cc.make_ippay_sale_xml(amount, card)
    c = pycurl.Curl()
    c.setopt(pycurl.URL, config.get('ippay-url'))
    c.setopt(pycurl.POST, 1)
    c.setopt(pycurl.HTTPHEADER, [
        'Content-type: text/xml',
        'Content-length: %d'%(len(xml))])
    c.setopt(pycurl.POSTFIELDS, xml)
    c.setopt(pycurl.SSL_VERIFYPEER, 0)
    c.setopt(pycurl.SSL_VERIFYHOST, 2)
    c.setopt(pycurl.TIMEOUT, 30)
    import StringIO
    b = StringIO.StringIO()
    c.setopt(pycurl.WRITEFUNCTION, b.write)
    try:
        c.perform()
    except:
        raise CCError('can\'t contact ippay server')
    if c.getinfo(pycurl.HTTP_CODE) != 200:
        raise CCError('ippay HTTP code %d'%(c.getinfo(pycurl.HTTP_CODE)))
    resp = b.getvalue()
    status = _parse_ippay_response(resp)
    return (xid, status)
Beispiel #2
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import cc
import pycurl

ms = open("magnetic_stripe", "r").read().rstrip().lstrip("%")
#print(ms)
c = cc.parse_magstripe(ms)

(tid, xml) = cc.make_ippay_sale_xml(0.01, c)
print(xml)
exit
c = pycurl.Curl()
c.setopt(pycurl.URL, config.get('ippay-url'))
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.HTTPHEADER, [
       'Content-type: text/xml',
       'Content-length: %d'%(len(xml))])
c.setopt(pycurl.POSTFIELDS, xml)
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.SSL_VERIFYHOST, 2)
c.setopt(pycurl.TIMEOUT, 30)
import StringIO
b = StringIO.StringIO()
c.setopt(pycurl.WRITEFUNCTION, b.write)