Skip to content

Commit 3a5c382

Browse files
author
Craig Christenson
committed
Adding direct checkout forms
1 parent ea5f7d1 commit 3a5c382

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from distutils.core import setup
44
setup(
55
name="twocheckout",
6-
version='0.1.1',
6+
version='0.1.2',
77
description="2Checkout Python Library",
88
author="Craig Christenson",
99
author_email="christensoncraig@gmail.com",

test/test_twocheckout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_3_refund_sale(self):
8888
result = sale.refund(EXAMPLE_REFUND)
8989
self.assertEqual(result.message, "refund added to invoice")
9090
except TwocheckoutError as error:
91-
self.assertEqual(error.message, "Invoice was already refunded.")
91+
self.assertEqual(error.message, "Invoice too old to refund.")
9292

9393
def test_4_refund_invoice(self):
9494
try:
@@ -97,7 +97,7 @@ def test_4_refund_invoice(self):
9797
result = invoice.refund(EXAMPLE_REFUND)
9898
self.assertEqual(result.message, "refund added to invoice")
9999
except TwocheckoutError as error:
100-
self.assertEqual(error.message, "Invoice was already refunded.")
100+
self.assertEqual(error.message, "Invoice too old to refund.")
101101

102102
def test_5_refund_lineitem(self):
103103
try:

twocheckout/charge.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Charge:
77
def form(cls, params=None):
88
if params is None:
99
params = dict()
10-
form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/spurchase\" method=\"post\">\n"
10+
form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n"
1111
for param in params:
1212
form = form + "<input type=\"hidden\" name=\"" + param + "\" value=\"" + str(params[param]) + "\" />\n"
1313
return form + "<input type=\"submit\" value=\"Proceed to Checkout\" />\n</form>\n"
@@ -16,14 +16,24 @@ def form(cls, params=None):
1616
def submit(cls, params=None):
1717
if params is None:
1818
params = dict()
19-
form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/spurchase\" method=\"post\">\n"
19+
form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n"
2020
for param in params:
2121
form = form + "<input type=\"hidden\" name=\"" + param + "\" value=\"" + str(params[param]) + "\" />\n"
2222
return form + "<input type=\"submit\" value=\"Proceed to Checkout\" />\n</form>\n" + \
2323
"<script type=\"text/javascript\">document.getElementById('2checkout').submit();</script>"
2424

2525
@classmethod
26-
def link(cls, params=None, url="https://www.2checkout.com/checkout/spurchase?"):
26+
def direct(cls, params=None):
27+
if params is None:
28+
params = dict()
29+
form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n"
30+
for param in params:
31+
form = form + "<input type=\"hidden\" name=\"" + param + "\" value=\"" + str(params[param]) + "\" />\n"
32+
return form + "<input type=\"submit\" value=\"Proceed to Checkout\" />\n</form>\n" + \
33+
"<script src=\"https://www.2checkout.com/static/checkout/javascript/direct.min.js\"></script>"
34+
35+
@classmethod
36+
def link(cls, params=None, url="https://www.2checkout.com/checkout/purchase?"):
2737
if params is None:
2838
params = dict()
2939
param = urllib.urlencode(params)

0 commit comments

Comments
 (0)