|
/
Zope
/
gocept svn checkins
/
Archive
/
2008
/
2008-10
/
SVN: r6894 - gocept.vendo/branches/paypal
[
SVN: r6893 - in gocept.plone.attributecondition/tr... ]
[
SVN: r6903 - in gocept.infrastructure/feature_netw... ]
SVN: r6894 - gocept.vendo/branches/paypal
Daniel Havlik <dh(at)gocept.com> |
2008-10-24 10:05:50 |
[ FULL ]
|
Author: nilo
Date: Fri Oct 24 10:05:49 2008
New Revision: 6894
Log:
removed pinning of gocept.paypal
Modified:
gocept.vendo/branches/paypal/setup.py
Modified: gocept.vendo/branches/paypal/setup.py
==============================================================================
--- gocept.vendo/branches/paypal/setup.py (original)
+++ gocept.vendo/branches/paypal/setup.py Fri Oct 24 10:05:49 2008
(at)(at) -27,7 +27,7 (at)(at)
install_requires=[
'setuptools',
'mechanize==0.1.6b',
- 'gocept.paypal==0.1.9',
+ 'gocept.paypal',
'gocept.fixedpoint',
'gocept.sequence',
# -*- Extra requirements: -*-
|
SVN: r6895 - gocept.vendo/branches/paypal/src/gocept/vendo/content
Daniel Havlik <dh(at)gocept.com> |
2008-10-24 10:06:01 |
[ FULL ]
|
Author: nilo
Date: Fri Oct 24 10:06:00 2008
New Revision: 6895
Log:
implemented efs data adapter
Modified:
gocept.vendo/branches/paypal/src/gocept/vendo/content/configure.zcml
gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/content/configure.zcml
==============================================================================
---
gocept.vendo/branches/paypal/src/gocept/vendo/content/configure.zcml (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/content/configure.zcml Fri
Oct 24 10:06:00 2008
(at)(at) -3,6 +3,8 (at)(at)
xmlns:five="http://namespaces.zope.org/five"
i18n_domain="gocept.vendo">
+ <adapter factory=".order.VendoOrderToEfsAdapter" />
+
<class class=".shop.VendoShop">
<require
permission="zope2.View"
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py
==============================================================================
--- gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py Fri Oct 24
10:06:00 2008
(at)(at) -4,10 +4,14 (at)(at)
from zope.interface import implements
import zope.annotation.interfaces
+import zope.component
from Products.Archetypes import atapi
from Products.ATContentTypes.content import base, folder
from Products.ATContentTypes.content import schemata
+import pdb
+pdb.set_trace()
+import gocept.efs.interfaces
from gocept.vendo.interfaces.order import IVendoOrder, IVendoOrderItem,\
IVendoOrderFolder
(at)(at) -15,6 +19,7 (at)(at)
from gocept.vendo import VendoMessageFactory as _
+
class VendoOrderFolder(folder.ATFolder):
"""Folder for storing the orders in."""
(at)(at) -62,6 +67,40 (at)(at)
schemata.finalizeATCTSchema(VendoOrderSchema, folderish=True,
moveDiscussion=False)
+class VendoOrderToEfsAdapter(object):
+ implements(gocept.efs.interfaces.IEfsData)
+ zope.component.adapts(IVendoOrder)
+
+ def __init__(self, context):
+ self.context = context
+ shipping = context.shipping_address
+ invoice = context.invoice_address
+ self.shipping_address = _mk_addr_dict(context.shipping_address)
+ self.billing_address = _mk_addr_dict(context.invoice_address)
+ self.shipping_method = context.getShipping_title()
+ self.order_id = context.getId()
+ orderitems = context.contentValues()
+ self.order = []
+ for orderitem in orderitems:
+ self.order.append(
+ {'ProductId': context.getFull_sku(),
+ 'Quantity':str(orderitem.getAmount())})
+
+def _mk_addr_dict(data):
+ return {
+ 'Name': '%s %s' % (data.get('firstname'),
+ data.get('lastname')),
+ 'Company': data.get('company'),
+ 'Address1': data.get('street'),
+ 'Address2': data.get('street2'),
+ 'City': data.get('city'),
+ 'State': data.get('state'),
+ 'Country': data.get('country'),
+ 'Zip': data.get('zip'),
+ 'Phone': None,
+ 'Email': data.get('mail'), }
+
+
class VendoOrder(folder.ATFolder):
"""Order object."""
|
SVN: r6896 - gocept.vendo/branches/paypal/src/gocept/vendo/content
Sebastian Wehrmann <sw(at)gocept.com> |
2008-10-24 10:06:55 |
[ FULL ]
|
Author: sweh
Date: Fri Oct 24 10:06:54 2008
New Revision: 6896
Log:
remove pdb
Modified:
gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py
==============================================================================
--- gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py Fri Oct 24
10:06:54 2008
(at)(at) -9,14 +9,13 (at)(at)
from Products.Archetypes import atapi
from Products.ATContentTypes.content import base, folder
from Products.ATContentTypes.content import schemata
-import pdb
-pdb.set_trace()
-import gocept.efs.interfaces
from gocept.vendo.interfaces.order import IVendoOrder, IVendoOrderItem,\
IVendoOrderFolder
from gocept.vendo.config import PROJECTNAME
+import gocept.efs.interfaces
+
from gocept.vendo import VendoMessageFactory as _
|
SVN: r6900 - gocept.vendo/branches/paypal/src/gocept/vendo/content
Sebastian Wehrmann <sw(at)gocept.com> |
2008-10-24 10:49:37 |
[ FULL ]
|
Author: sweh
Date: Fri Oct 24 10:49:36 2008
New Revision: 6900
Log:
use the right item id
Modified:
gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py
==============================================================================
--- gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py Fri Oct 24
10:49:36 2008
(at)(at) -82,7 +82,7 (at)(at)
self.order = []
for orderitem in orderitems:
self.order.append(
- {'ProductId': context.getFull_sku(),
+ {'ProductId': orderitem.getFull_sku(),
'Quantity':str(orderitem.getAmount())})
def _mk_addr_dict(data):
|
SVN: r6905 - in gocept.vendo/branches/paypal/src/gocept/vendo: . browser
Daniel Havlik <dh(at)gocept.com> |
2008-10-24 14:12:36 |
[ FULL ]
|
Author: nilo
Date: Fri Oct 24 14:12:35 2008
New Revision: 6905
Log:
added us-state field to form
Modified:
gocept.vendo/branches/paypal/src/gocept/vendo/address.py
gocept.vendo/branches/paypal/src/gocept/vendo/browser/cart_macros.pt
gocept.vendo/branches/paypal/src/gocept/vendo/browser/checkout.pt
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/address.py
==============================================================================
--- gocept.vendo/branches/paypal/src/gocept/vendo/address.py (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/address.py Fri Oct 24
14:12:35 2008
(at)(at) -85,7 +85,7 (at)(at)
self.phone = data.get('phone', None)
self.mail = data.get('mail', None)
self._check_county_req()
-
+ pass
def _check_county_req(self):
if self.country == 'GB':
(at)(at) -94,6 +94,12 (at)(at)
else:
if 'county' in self.required_fields:
del self.required_fields[self.required_fields.index('county')]
+ if self.country == 'US':
+ if 'us_state' not in self.required_fields:
+ self.required_fields.append('us_state')
+ else:
+ if 'us_state' in self.required_fields:
+ del
self.required_fields[self.required_fields.index('us_state')]
def is_valid(self, fieldname=None):
""" Test the address object if it contains valid data.
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/browser/cart_macros.pt
==============================================================================
---
gocept.vendo/branches/paypal/src/gocept/vendo/browser/cart_macros.pt (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/browser/cart_macros.pt Fri
Oct 24 14:12:35 2008
(at)(at) -73,6 +73,7 (at)(at)
<tal:line condition="address/zip"><span tal:content="address/zip"
/><br/></tal:line>
<tal:line condition="address/country"><span
tal:content="python:context.portal_countryutils.getCountryByIsoCode(address.country).name"
/><br/></tal:line>
<tal:line condition="address/county"><span
tal:content="address/county" /><br/></tal:line>
+ <tal:line condition="address/us-state"><span
tal:content="address/us-state" /><br/></tal:line>
<tal:line condition="address/phone"><span
tal:content="address/phone" /><br/></tal:line>
<tal:line condition="address/mail"><span
tal:content="address/mail" /><br/></tal:line>
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/browser/checkout.pt
==============================================================================
---
gocept.vendo/branches/paypal/src/gocept/vendo/browser/checkout.pt (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/browser/checkout.pt Fri Oct
24 14:12:35 2008
(at)(at) -179,16 +179,21 (at)(at)
shipping_country requires input
</div>
<script type="text/javascript">
- function checkCountry(val, fi){
+ function checkCountyState(val, fi_county, fi_state){
if (val=='GB') {
- document.getElementById(fi).style.visibility =
'visible';
+
document.getElementById(fi_county).style.display = 'block';
+
document.getElementById(fi_state).style.display = 'none';
+ } else if (val=='US') {
+
document.getElementById(fi_state).style.display = 'block';
+
document.getElementById(fi_county).style.display = 'none';
} else {
- document.getElementById(fi).style.visibility =
'hidden';
+
document.getElementById(fi_state).style.display = 'none';
+
document.getElementById(fi_county).style.display = 'none';
}
-
}
</script>
- <select onChange="checkCountry(this.value, 'countyfield');"
name="shipping_address.country:record"
+ <select onChange="checkCountyState(this.value,
'countyfield', 'statefield');"
+ name="shipping_address.country:record"
tal:define="sel_country address/country;
getCountry
nocall:context/portal_countryutils/getCountryByIsoCode;"
id="shipping-country">
<option value="" tal:condition="python: sel_country is None
or\
(at)(at) -207,9 +212,10 (at)(at)
</tr>
<tr>
<td>
- <div id="countyfield" style="visibility:hidden"
- tal:attributes="class python: errors.get('shipping_county',\
- None) and 'field error' or 'field'">
+ <div id="countyfield"
+ tal:attributes="style python:address.country=='GB' and
'display:block' or 'display:none';
+ class python: errors.get('shipping_county',\
+ None) and 'field error' or
'field'">
<label for="shipping-county" i18n:translate="">
County:
</label> *<br />
(at)(at) -226,6 +232,26 (at)(at)
</tr>
<tr>
<td>
+ <div id="statefield"
+ tal:attributes="style python:address.country=='US' and
'display:block' or 'display:none';
+ class python: errors.get('shipping_us_state',\
+ None) and 'field error' or
'field'">
+ <label for="shipping-state" i18n:translate="">
+ County:
+ </label> *<br />
+ <div class="fieldErrorBox"
+ tal:condition="python: errors.has_key('shipping_us_state')"
+ tal:content="errors/shipping_us_state">
+ shipping_state requires input
+ </div>
+ <input id="shipping-state"
+ name="shipping_address.us_state.record" type="text"
+ tal:attributes="value address/us_state"/>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td>
<div
tal:attributes="class python: errors.get('shipping_phone',\
None) and 'field error' or 'field'">
(at)(at) -434,7 +460,7 (at)(at)
id="invoice-country"
tal:define="sel_country address/country;
getCountry
nocall:context/portal_countryutils/getCountryByIsoCode;"
- onChange="checkCountry(this.value, 'countyfield-inv')">
+ onChange="checkCountyState(this.value, 'countyfield-inv',
'statefield-inv')">
<option value="" tal:condition="python: sel_country is None
or\
sel_country == ''">
-
(at)(at) -450,10 +476,11 (at)(at)
</td>
</tr>
<tr>
- <td>
- <div id="countyfield-inv" style="visibility:hidden"
- tal:attributes="class python: errors.get('invoice_county',\
- None) and 'field error' or 'field'">
+ <td>
+ <div id="countyfield-inv"
+ tal:attributes="style python:address.country=='GB' and
'display:block' or 'display:none';
+ class python: errors.get('invoice_county',\
+ None) and 'field error' or
'field'">
<label for="invoice-county" i18n:translate="">
County:
</label> *<br />
(at)(at) -469,6 +496,25 (at)(at)
</tr>
<tr>
<td>
+ <div id="statefield-inv"
+ tal:attributes="style python:address.country=='US' and
'display:block' or 'display:none';
+ class python: errors.get('invoice_us_state',\
+ None) and 'field error' or 'field'">
+ <label for="invoice-state" i18n:translate="">
+ County:
+ </label> *<br />
+ <div class="fieldErrorBox"
+ tal:condition="python: errors.has_key('invoice_us_state')"
+ tal:content="errors/invoice_us_state">
+ shipping_state requires input
+ </div>
+ <input id="invoice-state"
name="invoice_address.us_state:record" type="text"
+ tal:attributes="value address/us_state"/>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td>
<div
tal:attributes="class python: errors.get('invoice_phone',\
None) and 'field error' or 'field'">
(at)(at) -529,10 +575,6 (at)(at)
<input type="submit" class="context" name="form.button.Change"
value="Change" i18n:attributes="value" />
</form>
- <script type="text/javascript">
- checkCountry(document.getElementById('shipping-country').value,
'countyfield');
- checkCountry(document.getElementById('invoice-country').value,
'countyfield-inv');
- </script>
</tal:main-macro>
</metal:main>
|
SVN: r6906 - gocept.vendo/branches/paypal/src/gocept/vendo/content
Sebastian Wehrmann <sw(at)gocept.com> |
2008-10-24 14:37:28 |
[ FULL ]
|
Author: sweh
Date: Fri Oct 24 14:37:27 2008
New Revision: 6906
Log:
bugfix in accessing the address's content
add ability to select a payment method for a shop
Modified:
gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py
gocept.vendo/branches/paypal/src/gocept/vendo/content/shop.py
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py
==============================================================================
--- gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/content/order.py Fri Oct 24
14:37:27 2008
(at)(at) -74,8 +74,11 (at)(at)
self.context = context
shipping = context.shipping_address
invoice = context.invoice_address
- self.shipping_address = _mk_addr_dict(context.shipping_address)
- self.billing_address = _mk_addr_dict(context.invoice_address)
+ self.shipping_address = _mk_addr_dict(shipping)
+ if context.invoice_same_as_shipping:
+ self.billing_address = {}
+ else:
+ self.billing_address = _mk_addr_dict(invoice)
self.shipping_method = context.getShipping_title()
self.order_id = context.getId()
orderitems = context.contentValues()
(at)(at) -87,17 +90,17 (at)(at)
def _mk_addr_dict(data):
return {
- 'Name': '%s %s' % (data.get('firstname'),
- data.get('lastname')),
- 'Company': data.get('company'),
- 'Address1': data.get('street'),
- 'Address2': data.get('street2'),
- 'City': data.get('city'),
- 'State': data.get('state'),
- 'Country': data.get('country'),
- 'Zip': data.get('zip'),
- 'Phone': None,
- 'Email': data.get('mail'), }
+ 'Name': '%s %s' % (getattr(data, 'firstname'),
+ getattr(data, 'lastname')),
+ 'Company': getattr(data, 'company'),
+ 'Address1': getattr(data, 'street'),
+ 'Address2': getattr(data, 'street2'),
+ 'City': getattr(data, 'city'),
+ 'State': getattr(data, 'us_state'),
+ 'Country': getattr(data, 'country'),
+ 'Zip': getattr(data, 'zip'),
+ 'Phone': getattr(data, 'phone'),
+ 'Email': getattr(data, 'mail'), }
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/content/shop.py
==============================================================================
--- gocept.vendo/branches/paypal/src/gocept/vendo/content/shop.py (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/content/shop.py Fri Oct 24
14:37:27 2008
(at)(at) -19,7 +19,7 (at)(at)
required=True,
searchable=False,
storage=atapi.AnnotationStorage(),
- vocabulary=['EUR', 'GBP', 'SEK'],
+ vocabulary=['EUR', 'GBP', 'SEK', 'USD'],
widget=atapi.SelectionWidget(
label=_(u'Curreny'),
description=_(u'The currency for this shop')
(at)(at) -73,17 +73,27 (at)(at)
description=_(u'Select the terms and conditions')
)
),
- atapi.StringField('paypal_username',
+ atapi.StringField('payment',
required=True,
searchable=False,
storage=atapi.AnnotationStorage(),
+ vocabulary=['No payment',
+ 'Paypal Express Checkout',
+ 'Paypal Direct Payment'],
+ widget=atapi.SelectionWidget(
+ label=_(u'Payment system'),
+ description=_(u'Choose a payment system.'),
+ )
+ ),
+ atapi.StringField('paypal_username',
+ searchable=False,
+ storage=atapi.AnnotationStorage(),
widget=atapi.StringWidget(
label=_(u'PayPal Username'),
description=_(u'Your PayPal username.')
)
),
atapi.StringField('paypal_password',
- required=True,
searchable=False,
storage=atapi.AnnotationStorage(),
widget=atapi.StringWidget(
(at)(at) -92,7 +102,6 (at)(at)
)
),
atapi.StringField('paypal_signature',
- required=True,
searchable=False,
storage=atapi.AnnotationStorage(),
widget=atapi.StringWidget(
(at)(at) -101,7 +110,6 (at)(at)
)
),
atapi.StringField('paypal_version',
- required=True,
searchable=False,
default='3.0',
storage=atapi.AnnotationStorage(),
(at)(at) -111,7 +119,6 (at)(at)
)
),
atapi.StringField('paypal_api_endpoint',
- required=True,
searchable=False,
default='https://api-3t.sandbox.paypal.com/nvp',
storage=atapi.AnnotationStorage(),
(at)(at) -121,7 +128,6 (at)(at)
)
),
atapi.StringField('paypal_url',
- required=True,
searchable=False,
default='https://www.sandbox.paypal.com/webscr'\
'&cmd=_express-checkout&token=',
(at)(at) -159,6 +165,7 (at)(at)
vat_rate = atapi.ATFieldProperty('vat_rate')
shop_prefix = atapi.ATFieldProperty('shop_prefix')
shop_terms_conditions =
atapi.ATReferenceFieldProperty('shop_terms_conditions')
+ payment = atapi.ATFieldProperty('payment')
paypal_username = atapi.ATFieldProperty('paypal_username')
paypal_password = atapi.ATFieldProperty('paypal_password')
paypal_signature = atapi.ATFieldProperty('paypal_signature')
|
SVN: r6908 - gocept.vendo/branches/paypal/src/gocept/vendo/browser
Daniel Havlik <dh(at)gocept.com> |
2008-10-24 15:22:37 |
[ FULL ]
|
Author: nilo
Date: Fri Oct 24 15:22:36 2008
New Revision: 6908
Log:
added support for US$
Modified:
gocept.vendo/branches/paypal/src/gocept/vendo/browser/priceadapter.py
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/browser/priceadapter.py
==============================================================================
---
gocept.vendo/branches/paypal/src/gocept/vendo/browser/priceadapter.py (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/browser/priceadapter.py Fri
Oct 24 15:22:36 2008
(at)(at) -22,5 +22,7 (at)(at)
cur = u'Skr'
elif cur == 'EUR':
cur = u'€'
+ elif cur == 'USD':
+ cur = u'US$'
return u"%s %s" % (cur, raw_price)
|
SVN: r6912 - gocept.vendo/branches/paypal/src/gocept/vendo/browser
Daniel Havlik <dh(at)gocept.com> |
2008-10-24 16:23:28 |
[ FULL ]
|
Author: nilo
Date: Fri Oct 24 16:23:27 2008
New Revision: 6912
Log:
added paypal direct payment option
Modified:
gocept.vendo/branches/paypal/src/gocept/vendo/browser/callback.pt
gocept.vendo/branches/paypal/src/gocept/vendo/browser/cart_macros.pt
gocept.vendo/branches/paypal/src/gocept/vendo/browser/checkout.py
gocept.vendo/branches/paypal/src/gocept/vendo/browser/configure.zcml
gocept.vendo/branches/paypal/src/gocept/vendo/browser/finish_checkout.pt
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/browser/callback.pt
==============================================================================
---
gocept.vendo/branches/paypal/src/gocept/vendo/browser/callback.pt (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/browser/callback.pt Fri Oct
24 16:23:27 2008
(at)(at) -8,7 +8,7 (at)(at)
<body>
<metal:main fill-slot="main">
- <tal:main-macro metal:define-macro="main" tal:define="cart view/cart">
+ <tal:main-macro metal:define-macro="main">
<div id="order-finshed" i18n:translate="order_thanks_msg">
Thank you for your order. Your payment was successful.
</div>
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/browser/cart_macros.pt
==============================================================================
---
gocept.vendo/branches/paypal/src/gocept/vendo/browser/cart_macros.pt (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/browser/cart_macros.pt Fri
Oct 24 16:23:27 2008
(at)(at) -73,7 +73,7 (at)(at)
<tal:line condition="address/zip"><span tal:content="address/zip"
/><br/></tal:line>
<tal:line condition="address/country"><span
tal:content="python:context.portal_countryutils.getCountryByIsoCode(address.country).name"
/><br/></tal:line>
<tal:line condition="address/county"><span
tal:content="address/county" /><br/></tal:line>
- <tal:line condition="address/us-state"><span
tal:content="address/us-state" /><br/></tal:line>
+ <tal:line condition="address/us_state"><span
tal:content="address/us_state" /><br/></tal:line>
<tal:line condition="address/phone"><span
tal:content="address/phone" /><br/></tal:line>
<tal:line condition="address/mail"><span
tal:content="address/mail" /><br/></tal:line>
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/browser/checkout.py
==============================================================================
---
gocept.vendo/branches/paypal/src/gocept/vendo/browser/checkout.py (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/browser/checkout.py Fri Oct
24 16:23:27 2008
(at)(at) -30,10 +30,12 (at)(at)
template = ViewPageTemplateFile('finish_checkout.pt')
def __call__(self):
+ self.payment_error = ''
cartutility = getUtility(ICartUtility)
paypal = getUtility(IPayPal)
self.cart = ICartProvider(cartutility).get_cart(self.request)
shop = getUtility(IShopUtility)
+ self.payment_method = shop.getPayment()
self.invoice_address = self.cart.get_invoice_address()
shipping_address = self.shipping_address =
self.cart.get_shipping_address()
payment_address = {}
(at)(at) -46,21 +48,46 (at)(at)
payment_address['country'] = shipping_address.country
payment_address['county'] = shipping_address.county
payment_address['zip'] = shipping_address.zip
-
+
self.payment_address = payment_address
form = self.request.form
response = self.request.RESPONSE
submitted = form.get('submitted')
change_address = form.get('change_address')
change_cart = form.get('change_cart')
+ finish_order = form.get('finish_order')
final_amount = self.cart.get_total_price()
+ if shop.getPayment() == 'Paypal Express Checkout':
+ callback_url, callback_cancel_url = _get_callback_and_cancel_urls(
+ shop,
self.request)
+ token = paypal.SetExpressCheckout(final_amount, callback_url,
+ callback_cancel_url,
lang=shop.getShop_country())
+ self.paypal_url = "%s%s" % (shop.paypal_url, token)
+ elif shop.getPayment() == 'Paypal Direct Payment' and
form.get('directpayment'):
+ #XXX directpayment ausführen
+ #zu bestätigungsseite redirecten ODER fehler ausgeben
+ token = paypal.DoDirectPayment(final_amount,
+ '127.0.0.1', #XXX
+ form.get('card_number'),
+ form.get('card_expdate'),
+ form.get('card_cvc'),
+ form.get('cardholder_firstname'),
+ form.get('cardholder_lastname'),
+ form.get('card_type'),
+ ' / '.join((payment_address.get('street'),
+ payment_address.get('street2'))),
+ payment_address.get('city'),
+ payment_address.get('country'),
+ payment_address.get('zip'),
+ '','')
+ if token.get('ACK') == 'Success':
+ self._mk_order()
+ response.redirect('/%s/finished' % shop.absolute_url())
+ return
+ self.payment_error = '%s (%s)' % (token.get('L_LONGMESSAGE0'),
+ token.get('L_ERRORCODE0'))
- callback_url, callback_cancel_url = _get_callback_and_cancel_urls(
- shop, self.request)
- token = paypal.SetExpressCheckout(final_amount, callback_url,
- callback_cancel_url,
lang=shop.getShop_country())
- self.paypal_url = "%s%s" % (shop.paypal_url, token)
if submitted and change_address:
#redirect to checkout view
(at)(at) -68,9 +95,25 (at)(at)
elif submitted and change_cart:
#redirect to cart view
response.redirect('/%s/cart_view' % shop.absolute_url())
+ elif submitted and finish_order:
+ if shop.getPayment() == 'No payment':
+ self._mk_order()
+ response.redirect('/%s/finished' % shop.absolute_url())
+ return
+ else:
+ raise ValueError("Finishing order without payment is not
allowed.")
return self.template()
+ def _mk_order(self):
+ cartutility = getUtility(ICartUtility)
+ cartprovider = ICartProvider(cartutility)
+ self.cart = cartprovider.get_cart(self.request)
+ #create order
+ IOrderFactory(self.cart).create_order(self.cart)
+ #empty cart
+ cartprovider.empty_cart(self.request)
+
class CallbackView(BrowserView):
""" View for the PayPal callback. """
Modified: gocept.vendo/branches/paypal/src/gocept/vendo/browser/configure.zcml
==============================================================================
---
gocept.vendo/branches/paypal/src/gocept/vendo/browser/configure.zcml (original)
+++ gocept.vendo/branches/paypal/src/gocept/vendo/browser/configure.zcml Fri
Oct 24 16:23:27 2008
(at)(at) -25,6 +25,13 (at)(at)
/>
<browser:page
+ for="*"
+ name="finished"
+ template="callback.pt"
+ permission="zope2.View"
+ />
+
+ <browser:page
for="..interfaces.product.IVendoProductVariation"
name="view"
class=".product.ProductView"
Modified:
gocept.vendo/branches/paypal/src/gocept/vendo/browser/finish_checkout.pt
==============================================================================
---
gocept.vendo/branches/paypal/src/gocept/vendo/browser/finish_checkout.pt (original)
+++
gocept.vendo/branches/paypal/src/gocept/vendo/browser/finish_checkout.pt Fri
Oct 24 16:23:27 2008
(at)(at) -36,12 +36,30 (at)(at)
<div metal:use-macro="context/(at)(at)cart_macros/display_address"
/>
</tal:invoice>
<input type="submit" name="change_address" value="Edit address" />
- </form>
<h3 i18n:translate="">Proceed Checkout</h3>
- <form method="post" tal:attributes="
- action view/paypal_url" id="paypalform">
- <input i18n:attributes="value" type="submit"
name="form.button.Pay" value="Continue" />
+ <tal:nopayment condition="python: view.payment_method == 'No
payment'">
+ <input type="submit" name="finish_order" value="Finish order" />
+ </tal:nopayment>"
</form>
+ <tal:xpresscheckout condition="python: view.payment_method == 'Paypal
Express Checkout'">
+ <form method="post" tal:attributes="
+ action view/paypal_url" id="paypalform">
+ <input i18n:attributes="value" type="submit" name="form.button.Pay"
value="Continue" />
+ </form>
+ </tal:xpresscheckout>
+ <tal:directpayment condition="python: view.payment_method == 'Paypal
Direct Payment'">
+ <h2 tal:condition="view/payment_error"
tal:content="view/payment_error" />
+ <form tal:attributes="action
string:${context/absolute_url}/${view/__name__}">
+ <input type="hidden" name="directpayment" value="1" />
+ Cardholder firstname: <input type="text"
name="cardholder_firstname" />
+ Cardholder lastname: <input type="text"
name="cardholder_lastname" />
+ Card type: <input type="text" name="card_type" />
+ Card number: <input type="text" name="card_number"/>
+ Card expdate: <input type="text" name="card_expdate"/>
+ Card cvc: <input type="text" name="card_cvc"/>
+ <input type="submit" value="Pay" />
+ </form>
+ </tal:directpayment>
</tal:main-macro>
</metal:main>
|
|